package uk.ac.man.cs.lethe.logicalDifference

import uk.ac.man.cs.lethe.internal.dl.owlapi.ModuleExtractor

import java.io.File
import java.net.URL
import java.util.{Date, HashSet, Set}
import scala.collection.JavaConversions._
import scala.collection.mutable.{HashMap, MultiMap, Set => mutSet}
import org.semanticweb.owlapi.apibinding.OWLManager
import org.semanticweb.owlapi.model.{IRI, OWLAxiom, OWLEntity, OWLLogicalAxiom, OWLOntology, OWLOntologyManager}
import uk.ac.man.cs.lethe.ontologies._
import uk.ac.man.cs.lethe.interpolation._

object ExampleJieLiu {
  def main(args: Array[String]) = { 

    // Initialise managers, factories, and stuff
    val manager = OWLManager.createOWLOntologyManager()
    val dataFactory = manager.getOWLDataFactory()

    val prefix_url = "http://www.owl-ontologies.com/unnamed.owl#"

    // Load Ontology
    val file = new File("univ-cs.owl")
    val ontology = manager.loadOntologyFromOntologyDocument(file)
    

    // Initialise LogicalDifference computer
    val interpolator = new AlchTBoxInterpolator()
    val logicalDifferences = new IncrementalLogicalDifferences(ontology,
							       interpolator,
							       2)


    // Construct ontology change
    val addedAxioms = new HashSet[OWLLogicalAxiom]()
    
    val leftClass1 = dataFactory.getOWLClass(IRI.create(prefix_url, "Article"))
    val rightClass1 = dataFactory.getOWLClass(IRI.create(prefix_url, "HumanXX"))

    val leftClass2 = dataFactory.getOWLClass(IRI.create(prefix_url, "HumanXX"))
    val rightClass2 = dataFactory.getOWLClass(IRI.create(prefix_url, "Person"))

    addedAxioms.add(dataFactory.getOWLSubClassOfAxiom(leftClass1, rightClass1))
    addedAxioms.add(dataFactory.getOWLSubClassOfAxiom(leftClass2, rightClass2))



    val removedAxioms = new HashSet[OWLLogicalAxiom]()

    val emptyClass = dataFactory.getOWLClass(IRI.create(prefix_url, ""))

//    removedAxioms.add(dataFactory.getOWLSubClassOfAxiom(emptyClass, emptyClass))
    


    val change = new OWLOntologyChange(removedAxioms,
				       addedAxioms)

    println("Change: "+change)

    // Evaluate Change
    val logicalDifference = logicalDifferences.evaluateChange(change)

    println("New: "+logicalDifference.newEntailments)
    println("Lost: "+logicalDifference.lostEntailments)
  }
}
