Java Code Examples for org.semanticweb.owlapi.apibinding.OWLManager#getOWLDataFactory()
The following examples show how to use
org.semanticweb.owlapi.apibinding.OWLManager#getOWLDataFactory() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Report.java From robot with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Create a new report object with a QuotedEntityChecker loaded with entries from the label map. * Use labels for report output. * * @param labelMap Map of IRI to label for all entities in the ontology * @throws IOException on problem creating IOHelper */ public Report(Map<IRI, String> labelMap) throws IOException { this.ioHelper = new IOHelper(); checker = new QuotedEntityChecker(); checker.setIOHelper(ioHelper); checker.addProvider(new SimpleShortFormProvider()); checker.addProperty(OWLManager.getOWLDataFactory().getRDFSLabel()); if (labelMap != null) { useLabels = true; OWLDataFactory df = OWLManager.getOWLDataFactory(); for (Entry<IRI, String> entry : labelMap.entrySet()) { // Set all the entities as class - will not matter for retrieving label OWLEntity e = df.getOWLEntity(EntityType.CLASS, entry.getKey()); checker.add(e, entry.getValue()); } } }
Example 2
Source File: RetrievingProofsForEntailment.java From elk-reasoner with Apache License 2.0 | 5 votes |
private static OWLAxiom getEntailment() { // Let's pick some class subsumption we want to explain OWLDataFactory factory = OWLManager.getOWLDataFactory(); OWLClass subsumee = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#LiquidFood")); OWLClass subsumer = factory.getOWLClass(IRI.create("http://www.co-ode.org/ontologies/galen#Food")); return factory.getOWLSubClassOfAxiom(subsumee, subsumer); }
Example 3
Source File: OwlReader2.java From EventCoreference with Apache License 2.0 | 5 votes |
static public void main (String[] args) throws OWLException, InstantiationException, IllegalAccessException, ClassNotFoundException { String reasonerFactoryClassName = null; String pathToOwlOntology = "/Users/piek/Desktop/NWR/NWR-ontology/version-0.6/ESO_version_0.6.owl"; OWLOntologyManager m = (OWLOntologyManager) OWLManager.getOWLDataFactory(); @SuppressWarnings("null") //@Nonnull IRI documentIRI = IRI.create(pathToOwlOntology); OWLOntology ontology = m .loadOntologyFromOntologyDocument(documentIRI); // Report information about the ontology System.out.println("Ontology Loaded..."); System.out.println("Document IRI: " + documentIRI); System.out.println("Ontology : " + ontology.getOntologyID()); System.out.println("Format : " + m.getOntologyFormat(ontology)); @SuppressWarnings("null") OwlReader2 simpleHierarchy = new OwlReader2( (OWLReasonerFactory) Class.forName(reasonerFactoryClassName) .newInstance(), ontology); // Get Thing OWLClass clazz = m.getOWLDataFactory().getOWLThing(); System.out.println("Class : " + clazz); // Print the hierarchy below thing simpleHierarchy.printHierarchy(clazz); }
Example 4
Source File: ProofTest.java From elk-reasoner with Apache License 2.0 | 4 votes |
@Before public void initialize() { factory = OWLManager.getOWLDataFactory(); }
Example 5
Source File: ExplainCommand.java From robot with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public CommandState execute(CommandState state, String[] args) throws Exception { CommandLine line = CommandLineHelper.getCommandLine(getUsage(), getOptions(), args); if (line == null) { return null; } if (state == null) { state = new CommandState(); } IOHelper ioHelper = CommandLineHelper.getIOHelper(line); state = CommandLineHelper.updateInputOntology(ioHelper, state, line); OWLOntology ontology = state.getOntology(); QuotedEntityChecker checker = new QuotedEntityChecker(); checker.setIOHelper(ioHelper); checker.addProvider(new SimpleShortFormProvider()); checker.addProperty(OWLManager.getOWLDataFactory().getRDFSLabel()); checker.addAll(ontology); String maxString = CommandLineHelper.getDefaultValue(line, "max", "1"); final int max; try { max = Integer.parseInt(maxString); } catch (NumberFormatException e) { throw new Exception(String.format(maxTypeError, maxString)); } OWLReasonerFactory reasonerFactory = CommandLineHelper.getReasonerFactory(line, true); ManchesterOWLSyntaxInlineAxiomParser parser = new ManchesterOWLSyntaxInlineAxiomParser(OWLManager.getOWLDataFactory(), checker); String expression = CommandLineHelper.getRequiredValue(line, "axiom", "an --axiom is required"); OWLAxiom axiom = parser.parse(expression); Set<Explanation<OWLAxiom>> explanations = ExplainOperation.explain(axiom, ontology, reasonerFactory, max); if (line.hasOption("explanation")) { File output = new File(line.getOptionValue("explanation")); String result = explanations .stream() .map( e -> ExplainOperation.renderExplanationAsMarkdown( e, ontology.getOWLOntologyManager())) .collect(Collectors.joining("\n\n\n")); Writer writer = Files.newBufferedWriter(output.toPath(), StandardCharsets.UTF_8); writer.write(result); writer.close(); } Set<OWLAxiom> explanationsAxioms = explanations.stream().flatMap(e -> e.getAxioms().stream()).collect(Collectors.toSet()); Set<IRI> explanationTerms = explanationsAxioms .stream() .flatMap(ax -> ax.getSignature().stream().map(e -> e.getIRI())) .collect(Collectors.toSet()); Set<OWLAnnotationAssertionAxiom> annotations = OntologyHelper.getAnnotationAxioms( ontology, Collections.singleton(OWLManager.getOWLDataFactory().getRDFSLabel()), explanationTerms); explanationsAxioms.addAll(annotations); state.setOntology(ontology.getOWLOntologyManager().createOntology(explanationsAxioms)); CommandLineHelper.maybeSaveOutput(line, ontology); return state; }
Example 6
Source File: AbstractElkObjectConverter.java From elk-reasoner with Apache License 2.0 | 2 votes |
/** * Creates an {@link AbstractElkObjectConverter} that uses the default * {@link OWLDataFactory} for creating the corresponding {@link OWLObject}s */ public AbstractElkObjectConverter() { this(OWLManager.getOWLDataFactory()); }