Mercurial > repos > mikel-egana-aranguren > oppl
annotate OPPL/src/GalaxyOWLAPI.java @ 14:68c4ae500a13
XML files changed for more flexible inputs (oppl, query and inference)
author | Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu> |
---|---|
date | Sat, 31 Mar 2012 12:54:09 +0200 |
parents | 7e6604a5ee55 |
children | 622cde484f4c |
rev | line source |
---|---|
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
1 /** |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
2 * |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
3 */ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
4 package es.upm.fi.dia.oeg.oppl.galaxy; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
5 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
6 import java.io.BufferedWriter; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
7 import java.io.File; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
8 import java.io.IOException; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
9 import java.io.OutputStreamWriter; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
10 import java.util.ArrayList; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
11 import java.util.List; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
12 import java.util.Scanner; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
13 import java.util.Set; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
14 |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
15 import org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
16 import org.coode.owlapi.obo.parser.OBOOntologyFormat; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
17 import org.coode.parsers.BidirectionalShortFormProviderAdapter; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
18 import org.semanticweb.HermiT.Reasoner; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
19 import org.semanticweb.owlapi.apibinding.OWLManager; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
20 import org.semanticweb.owlapi.expression.OWLEntityChecker; |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
21 import org.semanticweb.owlapi.expression.ParserException; |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
22 import org.semanticweb.owlapi.expression.ShortFormEntityChecker; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
23 import org.semanticweb.owlapi.io.RDFXMLOntologyFormat; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
24 import org.semanticweb.owlapi.io.SystemOutDocumentTarget; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
25 import org.semanticweb.owlapi.model.AddAxiom; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
26 import org.semanticweb.owlapi.model.IRI; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
27 import org.semanticweb.owlapi.model.OWLAnnotation; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
28 import org.semanticweb.owlapi.model.OWLAnnotationProperty; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
29 import org.semanticweb.owlapi.model.OWLAxiom; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
30 import org.semanticweb.owlapi.model.OWLClass; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
31 import org.semanticweb.owlapi.model.OWLClassExpression; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
32 import org.semanticweb.owlapi.model.OWLDataFactory; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
33 import org.semanticweb.owlapi.model.OWLLiteral; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
34 import org.semanticweb.owlapi.model.OWLNamedIndividual; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
35 import org.semanticweb.owlapi.model.OWLOntology; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
36 import org.semanticweb.owlapi.model.OWLOntologyChange; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
37 import org.semanticweb.owlapi.model.OWLOntologyCreationException; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
38 import org.semanticweb.owlapi.model.OWLOntologyManager; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
39 import org.semanticweb.owlapi.model.OWLOntologyStorageException; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
40 import org.semanticweb.owlapi.reasoner.InferenceType; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
41 import org.semanticweb.owlapi.reasoner.NodeSet; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
42 import org.semanticweb.owlapi.reasoner.OWLReasoner; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
43 import org.semanticweb.owlapi.reasoner.OWLReasonerFactory; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
44 import org.semanticweb.owlapi.util.BidirectionalShortFormProvider; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
45 import org.semanticweb.owlapi.util.InferredAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
46 import org.semanticweb.owlapi.util.InferredClassAssertionAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
47 import org.semanticweb.owlapi.util.InferredDisjointClassesAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
48 import org.semanticweb.owlapi.util.InferredOntologyGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
49 import org.semanticweb.owlapi.util.InferredSubClassAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
50 import org.semanticweb.owlapi.util.InferredSubDataPropertyAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
51 import org.semanticweb.owlapi.util.InferredSubObjectPropertyAxiomGenerator; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
52 import org.semanticweb.owlapi.util.OWLEntityRenamer; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
53 import org.semanticweb.owlapi.util.OWLOntologyMerger; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
54 import org.semanticweb.owlapi.util.SimpleShortFormProvider; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
55 import org.semanticweb.owlapi.vocab.OWL2Datatype; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
56 import org.semanticweb.owlapi.vocab.OWLRDFVocabulary; |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
57 import org.semanticweb.owlapi.reasoner.Node; |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
58 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
59 import uk.ac.manchester.cs.factplusplus.owlapiv3.FaCTPlusPlusReasonerFactory; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
60 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
61 import com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
62 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
63 /** |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
64 * A wrapper of the OWL API |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
65 * |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
66 * @author Mikel Egaña Aranguren |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
67 */ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
68 public class GalaxyOWLAPI { |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
69 private OWLOntologyManager manager; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
70 private OWLOntology ontology; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
71 private OWLReasonerFactory reasonerFactory; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
72 private OWLReasoner reasoner; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
73 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
74 public GalaxyOWLAPI (){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
75 manager = OWLManager.createOWLOntologyManager(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
76 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
77 public OWLOntologyManager getOWLManager(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
78 return manager; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
79 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
80 public OWLOntology getMainOntology(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
81 return ontology; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
82 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
83 public OWLReasoner getReasoner(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
84 return reasoner; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
85 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
86 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
87 public void loadMainOntology(String OWLFilePath) throws OWLOntologyCreationException{ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
88 File owl_file = new File(OWLFilePath); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
89 ontology = manager.loadOntologyFromOntologyDocument(owl_file); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
90 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
91 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
92 // public void loadImportedOntology(IRI importedOntologyIRI) throws OWLOntologyCreationException{ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
93 // manager.loadOntologyFromOntologyDocument(importedOntologyIRI); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
94 // } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
95 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
96 // OWLLink: The problem is that Racer, for example, listens in 8080, the same port as Galaxy |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
97 // I have to change Racer settings and OWLLink settings |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
98 // OWLlinkHTTPXMLReasonerFactory factory = new OWLlinkHTTPXMLReasonerFactory(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
99 // reasoner = factory.createReasoner(OWL_ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
100 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
101 public void setReasonerPellet (){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
102 reasonerFactory = new PelletReasonerFactory(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
103 reasoner = reasonerFactory.createReasoner(ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
104 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
105 public void setReasonerFaCT (){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
106 reasonerFactory = new FaCTPlusPlusReasonerFactory(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
107 reasoner = reasonerFactory.createReasoner(ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
108 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
109 public void setReasonerHermit (){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
110 reasonerFactory = new Reasoner.ReasonerFactory(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
111 reasoner = reasonerFactory.createReasoner(ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
112 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
113 public void merge () throws OWLOntologyCreationException{ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
114 OWLOntologyMerger merger = new OWLOntologyMerger(manager); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
115 IRI mergedOntologyIRI = IRI.create("http://oeg-upm.net/oppl_galaxy/merged.owl"); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
116 ontology = merger.createMergedOntology(manager, mergedOntologyIRI); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
117 } |
13
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
118 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
119 public OWLClassExpression parseMOSClassExpression (String expr) throws ParserException{ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
120 Set<OWLOntology> importsClosure = ontology.getImportsClosure(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
121 BidirectionalShortFormProvider bidiShortFormProvider = new BidirectionalShortFormProviderAdapter(manager, importsClosure, new SimpleShortFormProvider()); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
122 OWLEntityChecker entityChecker = new ShortFormEntityChecker(bidiShortFormProvider); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
123 ManchesterOWLSyntaxEditorParser MOSparser = new ManchesterOWLSyntaxEditorParser(manager.getOWLDataFactory(), expr); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
124 MOSparser.setOWLEntityChecker(entityChecker); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
125 return MOSparser.parseClassExpression(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
126 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
127 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
128 public Set<OWLNamedIndividual> getIndividuals (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
129 return (reasoner.getInstances(expr, false)).getFlattened(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
130 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
131 public Set<OWLClass> getEquivalentClasses (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
132 Node<OWLClass> equivalentClasses = reasoner.getEquivalentClasses(expr); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
133 Set<OWLClass> result; |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
134 if (expr.isAnonymous()) { |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
135 result = equivalentClasses.getEntities(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
136 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
137 else { |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
138 result = equivalentClasses.getEntitiesMinus(expr.asOWLClass()); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
139 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
140 return result; |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
141 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
142 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
143 public Set<OWLClass> getDirectSuperClasses (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
144 return (reasoner.getSuperClasses(expr, true)).getFlattened(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
145 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
146 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
147 public Set<OWLClass> getAncestors (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
148 return (reasoner.getSuperClasses(expr, false)).getFlattened(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
149 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
150 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
151 public Set<OWLClass> getDirectSubClasses (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
152 return (reasoner.getSubClasses(expr, true)).getFlattened(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
153 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
154 |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
155 public Set<OWLClass> getDescendants (OWLClassExpression expr){ |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
156 return (reasoner.getSubClasses(expr, false)).getFlattened(); |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
157 } |
7e6604a5ee55
New query tool added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
11
diff
changeset
|
158 |
11
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
159 // CLASS_ASSERTIONS Denotes the computation of the direct types of individuals for each individual in the signature of the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
160 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
161 public void addCLASS_ASSERTIONS(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
162 reasoner.precomputeInferences(InferenceType.CLASS_ASSERTIONS); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
163 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
164 gens.add(new InferredClassAssertionAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
165 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
166 iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
167 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
168 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
169 // CLASS_HIERARCHY Denotes the computation of the class hierarchy. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
170 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
171 public void addCLASS_HIERARCHY(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
172 reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
173 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
174 gens.add(new InferredSubClassAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
175 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
176 iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
177 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
178 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
179 // DATA_PROPERTY_ASSERTIONS Denotes the computation of relationships between individuals and data property values for each individual in the signature of the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
180 // public void addDATA_PROPERTY_ASSERTIONS(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
181 // reasoner.precomputeInferences(InferenceType.DATA_PROPERTY_ASSERTIONS); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
182 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
183 // gens.add(new InferredDataPropertyAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
184 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
185 // iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
186 // } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
187 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
188 // DATA_PROPERTY_HIERARCHY Denotes the computation of the data property hierarchy. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
189 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
190 public void addDATA_PROPERTY_HIERARCHY(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
191 reasoner.precomputeInferences(InferenceType.DATA_PROPERTY_HIERARCHY); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
192 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
193 gens.add(new InferredSubDataPropertyAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
194 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
195 iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
196 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
197 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
198 // DIFFERENT_INDIVIDUALS Denotes the computation of sets of individuals that are different from each individual in the signature of the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
199 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
200 // public void addDIFFERENT_INDIVIDUALS(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
201 // reasoner.precomputeInferences(InferenceType.DIFFERENT_INDIVIDUALS); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
202 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
203 // gens.add(new Inferred); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
204 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
205 // iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
206 // } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
207 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
208 // DISJOINT_CLASSES Denotes the computation of sets of classes that are disjoint for each class in the signature of the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
209 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
210 public void addDISJOINT_CLASSES(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
211 reasoner.precomputeInferences(InferenceType.DISJOINT_CLASSES); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
212 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
213 gens.add(new InferredDisjointClassesAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
214 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
215 iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
216 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
217 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
218 // OBJECT_PROPERTY_ASSERTIONS Denotes the computation of relationships between individuals in the signature of the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
219 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
220 // public void addOBJECT_PROPERTY_ASSERTIONS(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
221 // reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_ASSERTIONS); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
222 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
223 // gens.add(new InferredObjectPropertyAxiomGenerator<OWLAxiom>() { |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
224 // };()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
225 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
226 // iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
227 // } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
228 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
229 // OBJECT_PROPERTY_HIERARCHY Denotes the computation of the object property hierarchy. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
230 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
231 public void addOBJECT_PROPERTY_HIERARCHY(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
232 reasoner.precomputeInferences(InferenceType.OBJECT_PROPERTY_HIERARCHY); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
233 List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
234 gens.add(new InferredSubObjectPropertyAxiomGenerator()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
235 InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
236 iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
237 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
238 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
239 // SAME_INDIVIDUAL Denotes the computation of individuals that are interpreted as the same object for each individual in the imports closure of the root ontology. |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
240 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
241 // public void addSAME_INDIVIDUAL(){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
242 // reasoner.precomputeInferences(InferenceType.SAME_INDIVIDUAL); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
243 // List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
244 // gens.add(new Infer); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
245 // InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner, gens); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
246 // iog.fillOntology(manager, ontology); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
247 // } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
248 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
249 public void saveOntology (boolean OWL) throws OWLOntologyStorageException, IOException, OWLOntologyCreationException{ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
250 // OWL format |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
251 if(OWL){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
252 manager.saveOntology(ontology, new RDFXMLOntologyFormat(), new SystemOutDocumentTarget()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
253 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
254 // OBO format |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
255 else{ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
256 // OWL API generates bad OBO but OBOformat doesn't work either so I correct the OWL API problems (More predictable) in a temporary file |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
257 // Very inefficient but no time for another solution |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
258 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
259 OWLDataFactory factory = manager.getOWLDataFactory(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
260 OWLEntityRenamer renamer = new OWLEntityRenamer (manager, manager.getOntologies()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
261 OWLAnnotationProperty label = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
262 for(OWLClass cls : ontology.getClassesInSignature()){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
263 // Remove annotations (OWL API generates bad OBO annotations) |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
264 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
265 // Keep rdfs:label |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
266 String class_name = null; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
267 for (OWLAnnotation annotation : cls.getAnnotations(ontology, label)){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
268 if (annotation.getValue() instanceof OWLLiteral) { |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
269 OWLLiteral val = (OWLLiteral) annotation.getValue(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
270 class_name = val.getLiteral(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
271 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
272 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
273 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
274 // I have to remove all the annotations cause I don't know which ones are rendered properly |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
275 manager.removeAxioms(ontology,ontology.getAnnotationAssertionAxioms(cls.getIRI())); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
276 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
277 // Add rdfs:label again |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
278 OWLAnnotation labelAnno = factory.getOWLAnnotation(factory.getOWLAnnotationProperty( |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
279 OWLRDFVocabulary.RDFS_LABEL.getIRI()),factory.getOWLLiteral(class_name,OWL2Datatype.XSD_STRING)); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
280 OWLAxiom ax = factory.getOWLAnnotationAssertionAxiom(cls.getIRI(), labelAnno); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
281 manager.applyChange(new AddAxiom(ontology, ax)); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
282 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
283 // Rename entities |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
284 String cls_IRI = cls.getIRI().toString(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
285 String cls_proper_IRI = cls_IRI.replace("_", ":"); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
286 List<OWLOntologyChange> changes = renamer.changeIRI(cls, IRI.create(cls_proper_IRI)); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
287 manager.applyChanges(changes); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
288 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
289 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
290 File file = new File("tmp.obo"); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
291 manager.saveOntology(ontology, new OBOOntologyFormat(), IRI.create(file.toURI())); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
292 BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
293 Scanner input = new Scanner(file); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
294 String buffer = ""; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
295 |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
296 while(input.hasNext()){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
297 String nextLine = input.nextLine(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
298 if(nextLine.contains("[Term]") || nextLine.contains("[Typedef]")){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
299 if(buffer.isEmpty()){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
300 bw.write(buffer); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
301 bw.newLine(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
302 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
303 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
304 if(!nextLine.contains("is_a: Thing") && !nextLine.contains("auto-generated-by:") && !nextLine.contains("id_space:") && !nextLine.contains("! ----")){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
305 if(!nextLine.isEmpty() && !buffer.contains("relationship:")){ |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
306 bw.write(nextLine); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
307 bw.newLine(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
308 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
309 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
310 buffer = nextLine; |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
311 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
312 input.close(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
313 bw.close(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
314 file.delete(); |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
315 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
316 } |
6ca67b155e32
Imports simplified, new tool for inference added
Mikel Egaña Aranguren <mikel-egana-aranguren@toolshed.g2.bx.psu.edu>
parents:
diff
changeset
|
317 } |