static OntModel createModel() { return ModelFactory.createOntologyModel(spec); } }
/** * Initializes the generator with an Anno4j instance which connected repository * will receive the ontology information (including inferred statements) after a call * to {@link #build()} or {@link #generateJavaFiles(OntGenerationConfig, File)}. * @param anno4j The Anno4j instance that will receive ontology information. */ public OWLJavaFileGenerator(Anno4j anno4j) { this.anno4j = anno4j; model = ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC); }
/** * <p> * Answer a new ontology model which will process in-memory models of * ontologies expressed the default ontology language (OWL). * The default document manager * will be used to load the ontology's included documents. * </p> * <p><strong>Note:</strong>The default model chosen for OWL and RDFS * includes a weak reasoner that includes some entailments (such as * transitive closure on the sub-class and sub-property hierarchies). Users * who want either no inference at all, or alternatively * more complete reasoning, should use * one of the other <code>createOntologyModel</code> methods that allow the * preferred OntModel specification to be stated.</p> * @return A new ontology model * @see OntModelSpec#getDefaultSpec * @see #createOntologyModel(OntModelSpec, Model) */ public static OntModel createOntologyModel() { return createOntologyModel( ProfileRegistry.OWL_LANG ); }
private static Model createCDKModel() { Model model = ModelFactory.createOntologyModel(); model.setNsPrefix("cdk", "http://cdk.sourceforge.net/model.owl#"); return model; }
private static Model createCDKModel() { Model model = ModelFactory.createOntologyModel(); model.setNsPrefix("cdk", "http://cdk.sourceforge.net/model.owl#"); return model; }
/** * <p> * Answer a new ontology model which will process in-memory models of * ontologies in the given language. * The default document manager * will be used to load the ontology's included documents. * </p> * * @param languageURI The URI specifying the ontology language we want to process * @return A new ontology model * @see OntModelSpec#getDefaultSpec */ public static OntModel createOntologyModel( String languageURI ) { return createOntologyModel( OntModelSpec.getDefaultSpec( languageURI ), null ); }
private LocalWorld() { File modelFile = new File(calculateComponentsDirectory(), FILENAME); model = createOntologyModel(); try { if (modelFile.exists()) model.read(new StringReader(readFileToString(modelFile)), null, ENCODING); } catch (IOException e) { logger.error("failed to construct local annotation world", e); } }
private LocalWorld() { File modelFile = new File(calculateComponentsDirectory(), FILENAME); model = createOntologyModel(); try { if (modelFile.exists()) model.read(new StringReader(readFileToString(modelFile)), null, ENCODING); } catch (IOException e) { logger.error("failed to construct local annotation world", e); } }
private OntModel createJenaModel(Reader reader, String baseUri) { OntModel model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); final RDFReader rdfReader = new JenaReader(); rdfReader.read(model, reader, baseUri); return model; }
/** * {@inheritDoc} */ @Override public void clear() { if( model != null ) model.close(); model = ModelFactory.createOntologyModel( PelletReasonerFactory.THE_SPEC ); pellet = (PelletInfGraph) model.getGraph(); }
@Override public RestrictionNode getInputRestrictionTree() throws SADIException, IOException { return new RestrictionNode(ModelFactory.createOntologyModel().createClass()) { private static final long serialVersionUID = 1L; @Override public String toString() { return "input"; } }; } @Override
/** * <p> * Answer a new ontology model which will process in-memory models of * ontologies expressed the default ontology language (OWL). * The default document manager * will be used to load the ontology's included documents. * </p> * * @param spec An ontology model specification that defines the language and reasoner to use * @param maker A model maker that is used to get the initial store for the ontology (unless * the base model is given), * and create addtional stores for the models in the imports closure * @param base The base model, which contains the contents of the ontology to be processed * @return A new ontology model * @see OntModelSpec */ public static OntModel createOntologyModel( OntModelSpec spec, ModelMaker maker, Model base ) { OntModelSpec _spec = new OntModelSpec( spec ); _spec.setImportModelMaker( maker ); return createOntologyModel( _spec, base ); }
@Override public RestrictionNode getOutputRestrictionTree() throws SADIException, IOException { return new RestrictionNode(ModelFactory.createOntologyModel().createClass()) { private static final long serialVersionUID = 1L; @Override public String toString() { return "output"; } }; } };
@Override public Model openEmptyModel( Assembler a, Resource root, Mode mode ) { checkType( root, JA.OntModel ); Model baseModel = getBase( a, root, mode ); OntModelSpec oms = getOntModelSpec( a, root ); OntModel om = ModelFactory.createOntologyModel( oms, baseModel ); addSubModels( a, root, mode, om ); return om; }
public OntologyHandler() { OntDocumentManager mgr = new OntDocumentManager(); mgr.setProcessImports(false); OntModelSpec s = new OntModelSpec( OntModelSpec.OWL_MEM ); s.setDocumentManager( mgr ); ontModel = ModelFactory.createOntologyModel(s); ontModel.setStrictMode(false); }
public static OWLKnowledgeBase newKB() { if (!OWLSConfigurations.instance().usePellet()) { BSDFLogger.getLogger().info("Creates a KB using OWLMicroReasoner"); OWLKnowledgeBase kb = OWLFactory.createKB(); kb.setReasoner(ReasonerRegistry.getOWLMicroReasoner()); return kb; } else { BSDFLogger.getLogger().info("Creates a KB using Pellet"); return ObjectOWLSTranslator.jenaModelToOWLKnowledgeBase(ModelFactory.createOntologyModel(PelletReasonerFactory.THE_SPEC)); } }
public OntModel getContentAsModel() { OntModel result = createOntologyModel(); try { populateModelFromString(result, getContentAsString()); // Check it is not still called changeme List<Individual> individuals = result.listIndividuals(clazz) .toList(); if (individuals.isEmpty()) { errors.setText("No valid individuals"); return null; } for (Individual i : individuals) if (i.getURI().endsWith("changeme")) { errors.setText("Name has not been changed"); return null; } errors.setText("No errors found"); return result; } catch (Throwable ex) { // syntax error? errors.setText(ex.getMessage()); return null; } }
public RDFModel read(String uri, boolean loadImports) { RDFModel m = new RDFModel(); OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); model.getDocumentManager().setProcessImports( loadImports ); FileManager.get().readModel( model, uri ); StmtIterator stmtIter = model.listStatements(); while( stmtIter.hasNext() ) { Statement stmt = stmtIter.nextStatement(); m.addStatement( stmt ); } return m; } }
public RDFModel read(String uri, boolean loadImports) { RDFModel m = new RDFModel(); OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM ); model.getDocumentManager().setProcessImports( loadImports ); FileManager.get().readModel( model, uri ); StmtIterator stmtIter = model.listStatements(); while( stmtIter.hasNext() ) { Statement stmt = stmtIter.nextStatement(); m.addStatement( stmt ); } return m; } }
public static Model toNIF(ComplexProof proof, Evidence evidence, Triple triple) { OntModel model = ModelFactory.createOntologyModel(); model.setNsPrefix("nif", "http://persistence.uni-leipzig.org/nlp2rdf/ontologies/nif-core#"); model.setNsPrefix("prov", PROV_NAMESPACE); WebSite webSite = proof.getWebSite(); String contextString = proof.getProofPhrase(); String text = webSite.getText(); // nif int start = webSite.getText().indexOf(contextString); int end = start + contextString.length(); Individual contextIndividual = nifConverter.createContextIndividual(DEFACTO_NAMESPACE, text, new ContextHashBasedString(), model); Individual cStringIndividual = nifConverter.createCStringIndividual(DEFACTO_NAMESPACE, contextIndividual, new Span(start, end), new ContextHashBasedString(), model); ObjectProperty sourceURL = NIFObjectProperties.sourceUrl.getObjectProperty(model); contextIndividual.addProperty(sourceURL, webSite.getUrl()); // prov model.add(ProvenanceInformationGenerator.generateProvenanceInformation(webSite, triple.getSubject().toString(), triple.getPredicate().toString(), triple.getObject().toString())); return model; }