本文整理汇总了Java中org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat类的典型用法代码示例。如果您正苦于以下问题:Java FunctionalSyntaxDocumentFormat类的具体用法?Java FunctionalSyntaxDocumentFormat怎么用?Java FunctionalSyntaxDocumentFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
FunctionalSyntaxDocumentFormat类属于org.semanticweb.owlapi.formats包,在下文中一共展示了FunctionalSyntaxDocumentFormat类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSuffix
点赞 3
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; //导入依赖的package包/类
private String getSuffix(OWLDocumentFormat format) {
if (format instanceof RDFXMLDocumentFormat) {
return "owl";
}
if (format instanceof FunctionalSyntaxDocumentFormat) {
return "ofn";
}
if (format instanceof OWLXMLDocumentFormat) {
return "owx";
}
if (format instanceof ManchesterSyntaxDocumentFormat) {
return "omn";
}
return "owl";
}
开发者ID:owlcollab,
项目名称:owltools,
代码行数:17,
代码来源:BridgeExtractor.java
示例2: main
点赞 2
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; //导入依赖的package包/类
public static void main(String[] args) throws OWLOntologyStorageException,
OWLOntologyCreationException {
OWLOntologyManager inputOntologyManager = OWLManager.createOWLOntologyManager();
OWLOntologyManager outputOntologyManager = OWLManager.createOWLOntologyManager();
// Load your ontology.
OWLOntology ont = inputOntologyManager.loadOntologyFromOntologyDocument(new File("path-to-ontology"));
// Create an ELK reasoner.
OWLReasonerFactory reasonerFactory = new ElkReasonerFactory();
OWLReasoner reasoner = reasonerFactory.createReasoner(ont);
// Classify the ontology.
reasoner.precomputeInferences(InferenceType.CLASS_HIERARCHY);
// To generate an inferred ontology we use implementations of
// inferred axiom generators
List<InferredAxiomGenerator<? extends OWLAxiom>> gens = new ArrayList<InferredAxiomGenerator<? extends OWLAxiom>>();
gens.add(new InferredSubClassAxiomGenerator());
gens.add(new InferredEquivalentClassAxiomGenerator());
// Put the inferred axioms into a fresh empty ontology.
OWLOntology infOnt = outputOntologyManager.createOntology();
InferredOntologyGenerator iog = new InferredOntologyGenerator(reasoner,
gens);
iog.fillOntology(outputOntologyManager.getOWLDataFactory(), infOnt);
// Save the inferred ontology.
outputOntologyManager.saveOntology(infOnt,
new FunctionalSyntaxDocumentFormat(),
IRI.create((new File("path-to-output").toURI())));
// Terminate the worker threads used by the reasoner.
reasoner.dispose();
}
开发者ID:liveontologies,
项目名称:elk-reasoner,
代码行数:36,
代码来源:SavingInferredAxioms.java
示例3: gaf2OwlSimple
点赞 2
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; //导入依赖的package包/类
/**
* Created to mimic the translation to OWL for GAF checks
*
* @param opts
* @throws Exception
*/
@CLIMethod("--gaf2owl-simple")
public void gaf2OwlSimple(Opts opts) throws Exception {
opts.info("-o FILE", "translates previously loaded GAF document into OWL, requires a loaded ontology to lookup ids");
String out = null;
while (opts.hasOpts()) {
if (opts.nextEq("-o")) {
out = opts.nextOpt();
}
else
break;
}
if (g == null) {
LOG.error("An ontology is required.");
exit(-1);
}
else if (gafdoc == null) {
LOG.error("A GAF document is required.");
exit(-1);
}
else if (out == null) {
LOG.error("An output file is required.");
exit(-1);
}
LOG.info("Creating OWL represenation of annotations.");
GAFOWLBridge bridge = new GAFOWLBridge(g);
bridge.setGenerateIndividuals(false);
bridge.setBasicAboxMapping(false);
bridge.setBioentityMapping(BioentityMapping.CLASS_EXPRESSION);
bridge.setSkipNotAnnotations(true);
OWLOntology translated = bridge.translate(gafdoc);
File outputFile = new File(out);
OWLOntologyManager manager = translated.getOWLOntologyManager();
OWLDocumentFormat ontologyFormat= new FunctionalSyntaxDocumentFormat();
manager.saveOntology(translated, ontologyFormat, IRI.create(outputFile));
}
开发者ID:owlcollab,
项目名称:owltools,
代码行数:43,
代码来源:GafCommandRunner.java
示例4: main
点赞 2
import org.semanticweb.owlapi.formats.FunctionalSyntaxDocumentFormat; //导入依赖的package包/类
public static void main(String[] args) throws OWLOntologyCreationException, OWLOntologyStorageException {
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLDataFactory factory = manager.getOWLDataFactory();
// create new empty ontology
OWLOntology ontology = manager.createOntology(IRI.create(DOCUMENT_IRI));
//set up prefixes
DefaultPrefixManager pm = new DefaultPrefixManager();
pm.setDefaultPrefix(DOCUMENT_IRI + "#");
pm.setPrefix("var:", "urn:swrl#");
//class declarations
OWLClass personClass = factory.getOWLClass(":Person", pm);
manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(personClass));
OWLClass manClass = factory.getOWLClass(":Man", pm);
manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(manClass));
OWLClass englishProgrammerClass = factory.getOWLClass(":EnglishProgrammer", pm);
manager.addAxiom(ontology, factory.getOWLDeclarationAxiom(englishProgrammerClass));
//named individuals declarations
OWLNamedIndividual english = createIndividual(ontology, pm, manager, ":English");
OWLNamedIndividual comp = createIndividual(ontology, pm, manager, ":Computer-Programming");
OWLNamedIndividual john = createIndividual(ontology, pm, manager, ":John");
//annotated subclass axiom
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI());
OWLAnnotationValue value = factory.getOWLLiteral("States that every man is a person.");
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, value);
OWLSubClassOfAxiom subClassOfAxiom = factory.getOWLSubClassOfAxiom(manClass, personClass, Collections.singleton(annotation));
manager.addAxiom(ontology, subClassOfAxiom);
//object property declaration
OWLObjectProperty speaksLanguageProperty = createObjectProperty(ontology, pm, manager, ":speaksLanguage");
OWLObjectProperty hasKnowledgeOfProperty = createObjectProperty(ontology, pm, manager, ":hasKnowledgeOf");
//axiom - John is a Person
manager.addAxiom(ontology, factory.getOWLClassAssertionAxiom(personClass, john));
//axiom - John speaksLanguage English
manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(speaksLanguageProperty, john, english));
//axiom - John hasKnowledgeOf Computer-Programming
manager.addAxiom(ontology, factory.getOWLObjectPropertyAssertionAxiom(hasKnowledgeOfProperty, john, comp));
//axiom - EnglishProgrammers is equivalent to intersection of classes
OWLObjectHasValue c1 = factory.getOWLObjectHasValue(speaksLanguageProperty, english);
OWLObjectHasValue c2 = factory.getOWLObjectHasValue(hasKnowledgeOfProperty, comp);
OWLObjectIntersectionOf andExpr = factory.getOWLObjectIntersectionOf(personClass, c1, c2);
manager.addAxiom(ontology, factory.getOWLEquivalentClassesAxiom(englishProgrammerClass, andExpr));
//SWRL rule - Person(?x),speaksLanguage(?x,English),hasKnowledgeOf(?x,Computer-Programming)->englishProgrammer(?x)
SWRLVariable varX = factory.getSWRLVariable(pm.getIRI("var:x"));
Set<SWRLAtom> body = new LinkedHashSet<>();
body.add(factory.getSWRLClassAtom(personClass, varX));
body.add(factory.getSWRLObjectPropertyAtom(speaksLanguageProperty, varX, factory.getSWRLIndividualArgument(english)));
body.add(factory.getSWRLObjectPropertyAtom(hasKnowledgeOfProperty, varX, factory.getSWRLIndividualArgument(comp)));
Set<? extends SWRLAtom> head = Collections.singleton(factory.getSWRLClassAtom(englishProgrammerClass, varX));
SWRLRule swrlRule = factory.getSWRLRule(body, head);
manager.addAxiom(ontology, swrlRule);
//save to a file
FunctionalSyntaxDocumentFormat ontologyFormat = new FunctionalSyntaxDocumentFormat();
ontologyFormat.copyPrefixesFrom(pm);
manager.saveOntology(ontology, ontologyFormat, IRI.create(new File("example.owl").toURI()));
//reason
OWLReasonerFactory reasonerFactory = PelletReasonerFactory.getInstance();
OWLReasoner reasoner = reasonerFactory.createReasoner(ontology, new SimpleConfiguration());
for (OWLNamedIndividual person : reasoner.getInstances(personClass, false).getFlattened()) {
System.out.println("person : " + renderer.render(person));
}
for (OWLNamedIndividual englishProgrammer : reasoner.getInstances(englishProgrammerClass, false).getFlattened()) {
System.out.println("englishProgrammer : " + renderer.render(englishProgrammer));
}
}
开发者ID:martin-kuba,
项目名称:owl2-swrl-tutorial,
代码行数:78,
代码来源:CreateOntologyInCodeExample.java