Java 类org.semanticweb.owlapi.model.IRI 实例源码
项目:RDF2PT
文件:DefaultIRIConverter.java
private String getLabelFromBuiltIn(String uri){
try {
IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
// if IRI is built-in entity
if(iri.isReservedVocabulary()) {
// use the short form
String label = sfp.getShortForm(iri);
// if it is a XSD numeric data type, we attach "value"
if(uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())
){
label += " value";
}
return label;
}
} catch (UnsupportedEncodingException e) {
logger.error("Getting short form of " + uri + "failed.", e);
}
return null;
}
项目:RDF2PT
文件:DefaultIRIConverterFrench.java
private String getLabelFromBuiltIn(String uri) {
try {
IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
// if IRI is built-in entity
if (iri.isReservedVocabulary()) {
// use the short form
String label = sfp.getShortForm(iri);
// if it is a XSD numeric data type, we attach "value"
if (uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())) {
label += " value";
}
return label;
}
} catch (UnsupportedEncodingException e) {
logger.error("Getting short form of " + uri + "failed.", e);
}
return null;
}
项目:RDF2PT
文件:DefaultIRIConverterPortuguese.java
private String getLabelFromBuiltIn(String uri) {
try {
IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
// if IRI is built-in entity
if (iri.isReservedVocabulary()) {
// use the short form
String label = sfp.getShortForm(iri);
// if it is a XSD numeric data type, we attach "value"
if (uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())) {
label += " value";
}
return label;
}
} catch (UnsupportedEncodingException e) {
logger.error("Getting short form of " + uri + "failed.", e);
}
return null;
}
项目:BENGAL
文件:Verbalizer.java
/**
* Returns the most specific type of a given individual.
*
* @param ind
* @return
*/
private OWLClass getMostSpecificType(OWLIndividual ind) {
logger.debug("Getting the most specific type of " + ind);
String query = String.format("PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
+ "select distinct ?type where {" + " <%s> a ?type ." + "?type rdfs:label []."
// + "?type a owl:Class ." // too strict, thus currently omitted
+ "filter not exists {?subtype ^a <%s> ; rdfs:subClassOf ?type .filter(?subtype != ?type)}}",
ind.toStringID(), ind.toStringID());
SortedSet<OWLClass> types = new TreeSet<OWLClass>();
QueryExecution qe = qef.createQueryExecution(query);
ResultSet rs = qe.execSelect();
while (rs.hasNext()) {
QuerySolution qs = rs.next();
if (qs.get("type").isURIResource()) {
types.add(new OWLClassImpl(IRI.create(qs.getResource("type").getURI())));
}
}
qe.close();
// of more than one type exists, we have to choose one
// TODO
return types.first();
}
项目:BENGAL
文件:DefaultIRIConverter.java
private String getLabelFromBuiltIn(String uri) {
try {
IRI iri = IRI.create(URLDecoder.decode(uri, "UTF-8"));
// if IRI is built-in entity
if (iri.isReservedVocabulary()) {
// use the short form
String label = sfp.getShortForm(iri);
// if it is a XSD numeric data type, we attach "value"
if (uri.equals(XSD.nonNegativeInteger.getURI()) || uri.equals(XSD.integer.getURI())
|| uri.equals(XSD.negativeInteger.getURI()) || uri.equals(XSD.decimal.getURI())
|| uri.equals(XSD.xdouble.getURI()) || uri.equals(XSD.xfloat.getURI())
|| uri.equals(XSD.xint.getURI()) || uri.equals(XSD.xshort.getURI())
|| uri.equals(XSD.xbyte.getURI()) || uri.equals(XSD.xlong.getURI())) {
label += " value";
}
return label;
}
} catch (UnsupportedEncodingException e) {
logger.error("Getting short form of " + uri + "failed.", e);
}
return null;
}
项目:geoxygene
文件:OwlUtil.java
/**
* Open the OWL ontology (from the ontology resources of CartAGen) whose name
* is passed as parameter.
* @param name
* @return
* @throws OWLOntologyCreationException
*/
public static OWLOntology getOntologyFromName(String name)
throws OWLOntologyCreationException {
// create the URI from the name and the CartAGen ontologies folder path
String uri = FOLDER_PATH + "/" + name + ".owl";
InputStream stream = OwlUtil.class.getResourceAsStream(uri);
File file = new File(stream.toString());
String path = file.getAbsolutePath().substring(0,
file.getAbsolutePath().lastIndexOf('\\'));
path = path.replaceAll(new String("\\\\"), new String("//"));
path = path + "//src/main//resources//ontologies//" + name + ".owl";
// create the ontology from the URI using an OWLOntologyManager
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
IRI physicalURI = IRI.create(new File(path));
OWLOntology ontology = manager
.loadOntologyFromOntologyDocument(physicalURI);
return ontology;
}
项目:Resource2Vec
文件:R2VManager.java
/**
* @param filename
* @return
*/
private static OWLOntology getOntology(String filename) {
File file = new File(filename);
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology o;
try {
o = m.loadOntologyFromOntologyDocument(IRI.create(file.toURI()));
} catch (OWLOntologyCreationException e) {
fail("Cannot load ontology.");
return null;
}
assertNotNull(o);
return o;
}
项目:Resource2Vec
文件:R2VManager.java
/**
* @param superclass
* @param o
* @return
*/
private static Set<OWLIndividual> getIndividuals(String superclass,
OWLOntology o) {
OWLReasoner reasoner = PelletReasonerFactory.getInstance()
.createReasoner(o);
Set<OWLNamedIndividual> instances = reasoner.getInstances(
OWL.Class(IRI.create(superclass)), false).getFlattened();
// filter out all owl:sameAs instances...
Set<OWLIndividual> ind = new TreeSet<>();
for (OWLNamedIndividual i : instances) {
ind.add(i);
}
logger.info("|I| = " + ind.size());
logger.debug("I = " + ind);
return ind;
}
项目:owltools
文件:LocalMirrorIRIMapper.java
/**
* Parse the inputStream as a partial redirect mapping file and extract IRI mappings.
*
* Optional: Resolve relative file paths with the given parent folder.
*
* @param inputStream input stream (never null)
* @param parentFolder folder or null
* @return mappings
* @throws IOException
* @throws IllegalArgumentException if input stream is null
*/
static Map<IRI, IRI> parseDirectoryMappingFile(InputStream inputStream, final File parentFolder) throws IOException {
if (inputStream == null) {
throw new IllegalArgumentException("InputStream should never be null, missing resource?");
}
try {
final Map<IRI, IRI> mappings = new HashMap<IRI, IRI>();
for (String line : IOUtils.readLines(inputStream)) {
if (line.startsWith("#")) {
continue;
}
String[] toks = line.split(" ", 2);
if (toks.length != 2) {
throw new IOException("Each line must have 1 space: "+line);
}
mappings.put(IRI.create(toks[0]),
IRI.create(toks[1]));
}
return mappings;
} finally {
inputStream.close();
}
}
项目:minerva
文件:DataPropertyTest.java
@Test
public void testDataPropertyMetadata() throws Exception {
OWLOntologyManager m = OWLManager.createOWLOntologyManager();
OWLOntology ontology = m.createOntology(IRI.generateDocumentIRI());
{
// create a test ontology with one data property
OWLDataFactory f = m.getOWLDataFactory();
IRI propIRI = IRI.generateDocumentIRI();
OWLDataProperty prop = f.getOWLDataProperty(propIRI);
m.addAxiom(ontology, f.getOWLDeclarationAxiom(prop));
m.addAxiom(ontology, f.getOWLAnnotationAssertionAxiom(propIRI, f.getOWLAnnotation(f.getRDFSLabel(), f.getOWLLiteral("fake-data-property"))));
}
OWLGraphWrapper graph = new OWLGraphWrapper(ontology);
MolecularModelManager<?> mmm = createM3(graph);
Pair<List<JsonRelationInfo>,List<JsonRelationInfo>> pair = MolecularModelJsonRenderer.renderProperties(mmm, null, curieHandler);
List<JsonRelationInfo> dataProperties = pair.getRight();
assertEquals(1, dataProperties.size());
}
项目:darceo
文件:ServicesConstructorBean.java
/**
* Extracts data manipulation service information from the ontology.
*
* @param service
* service individual found in ontology.
* @param ontology
* searched ontology.
* @return extracted data manipulation service.
* @throws EntryCreationException
* should any problems with extraction of data manipulation service information occur.
*/
private DataManipulationService extractService(OWLIndividual service, OWLOntology ontology)
throws EntryCreationException {
DataManipulationService dataManipulationService = new DataManipulationService();
Set<OWLIndividual> profiles = service.getObjectPropertyValues(ontologyManager.getOWLDataFactory()
.getOWLObjectProperty(PRESENTS_PROPERTY_IRI), ontology);
for (OWLIndividual profile : profiles) {
String profilePath = profile.asOWLNamedIndividual().getIRI().getStart();
profilePath = profilePath.substring(0, profilePath.length() - 1);
OWLOntology profileOntology = ontologyManager.getOntology(IRI.create(profilePath));
dataManipulationService.setIri(extractServiceIri(service));
dataManipulationService.setName(extractServiceName(profile, profileOntology));
dataManipulationService.setDescription(extractServiceDescription(profile, profileOntology));
dataManipulationService.setType(extractServiceType(profile, profileOntology));
}
return dataManipulationService;
}
项目:pronto
文件:PKBXMLSerializer.java
protected void addPTBoxConstraints(OWLOntology ontology, PTBox ptbox,
OWLOntologyManager manager, OWLDataFactory factory) {
ConceptConverter converter = new ConceptConverter(ptbox.getClassicalKnowledgeBase(), factory);
for (ConditionalConstraint cc : ptbox.getDefaultConstraints()) {
OWLAnnotationProperty annProp = factory.getOWLAnnotationProperty( IRI.create(Constants.CERTAINTY_ANNOTATION_URI ));
OWLAnnotationValue annValue = factory.getOWLStringLiteral( cc.getLowerBound() + ";" + cc.getUpperBound() );
OWLAnnotation annotation = factory.getOWLAnnotation( annProp, annValue );
OWLClassExpression clsEv = (OWLClassExpression)converter.convert( cc.getEvidence() );
OWLClassExpression clsCn = (OWLClassExpression)converter.convert( cc.getConclusion() );
OWLAxiom axiom = factory.getOWLSubClassOfAxiom( clsEv, clsCn, Collections.singleton( annotation ) );
try {
manager.applyChange( new AddAxiom(ontology, axiom) );
} catch( OWLOntologyChangeException e ) {
e.printStackTrace();
}
}
}
项目:Wolpertinger
文件:WolpertingerTest.java
/**
* Atomic clash
*/
public void testUnsatifiabilityDueToClashInABoxAssertions() {
OWLDataFactory factory = OWLManager.getOWLDataFactory();
OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
OWLClassExpression expr1 = factory.getOWLClass(IRI.create(String.format("%s#%s", PREFIX, "A")));
OWLClassExpression expr2 = factory.getOWLObjectComplementOf(expr1);
OWLNamedIndividual indiv = factory.getOWLNamedIndividual(IRI.create(String.format("%s#%s", PREFIX, "a")));
OWLIndividualAxiom fact1 = factory.getOWLClassAssertionAxiom(expr1, indiv);
OWLIndividualAxiom fact2 = factory.getOWLClassAssertionAxiom(expr2, indiv);
try {
OWLOntology ontology = manager.createOntology();
manager.addAxiom(ontology, fact1);
manager.addAxiom(ontology, fact2);
Wolpertinger wolpertinger = new Wolpertinger(ontology);
assertFalse(wolpertinger.isConsistent());
} catch (OWLOntologyCreationException e) {
e.printStackTrace();
fail();
}
}
项目:logmap-matcher
文件:ModuleExtractorManager.java
/**
* Necessary toi construct a module for an arbitriary set of axioms
* @param moduleAxioms
* @param moduleUri
* @return
*/
public OWLOntology getModuleFromAxioms(Set<OWLAxiom> moduleAxioms, IRI moduleIri) {
OWLOntologyManager ontologyManager = OWLManager.createOWLOntologyManager();
OWLOntology module=null;
try {
module = ontologyManager.createOntology(moduleIri);
List<OWLOntologyChange> ontoChanges = new ArrayList<OWLOntologyChange>();
for(OWLAxiom axiom : moduleAxioms) {
ontoChanges.add(new AddAxiom(module, axiom));
}
ontologyManager.applyChanges(ontoChanges);
}
catch(Exception e) {
System.out.println("Error creating module ontology from extende set of axioms.");
}
//System.out.println("Time create OWLOntology for module (s): " + (double)((double)fin-(double)init)/1000.0);
return module;
}
项目:owltools
文件:DanglingReferenceCheck.java
private void handleUnionOf(List<CheckWarning> warnings, Set<OWLOntology> allOntologies,
OWLEquivalentClassesAxiom axiom, OWLObjectUnionOf union, OWLPrettyPrinter pp)
{
List<OWLClassExpression> operands = union.getOperandsAsList();
for(OWLClassExpression operand : operands) {
if (!operand.isAnonymous()) {
OWLClass operandCls = operand.asOWLClass();
if (isDangling(operandCls, allOntologies)) {
final IRI iri = operandCls.getIRI();
String message = "Dangling reference "+iri+" in UNION_OF axiom: "+pp.render(axiom);
warnings.add(new CheckWarning(getID(), message , isFatal(), iri, OboFormatTag.TAG_UNION_OF.getTag()));
}
}
else {
// not translatable to OBO
handleGeneric(warnings, allOntologies, axiom, operand, pp);
}
}
}
项目:owltools
文件:OWLHandler.java
private Set<OWLClass> resolveClassList(Param p) {
Set<OWLClass> objs = new HashSet<OWLClass>();
if (getParams(p) != null) {
ArrayList<String> ids = new ArrayList<String>(Arrays.asList(getParams(p)));
LOG.info("Param "+p+" IDs: "+ids.toString());
for (String id : ids) {
// we allow resolution by altId, if present; in future we
// may want to check the altId map at this level so we can
// provide metadata in the payload about any mappings provided.
// See: https://github.com/monarch-initiative/monarch-app/issues/97
OWLClass c = graph.getOWLClassByIdentifier(id, true);
if (c == null) {
// TODO - strict mode - for now we include unresolvable classes
IRI iri = graph.getIRIByIdentifier(id);
c = graph.getDataFactory().getOWLClass(iri);
LOG.info("Unresolvable id:"+id+". Making temp class element:"+c.toString());
}
objs.add(c);
}
}
LOG.info("Num objs: "+objs.size());
return objs;
}
项目:owltools
文件:SelfReferenceInDefinitionTest.java
@Test
public void testSelfReferences() throws Exception {
ParserWrapper parser = new ParserWrapper();
IRI iri = IRI.create(getResource("verification/self_references.obo").getAbsoluteFile()) ;
OWLGraphWrapper graph = parser.parseToOWLGraph(iri.toString());
OntologyCheck check = new SelfReferenceInDefinition();
Collection<CheckWarning> warnings = check.check(graph, graph.getAllOWLObjects());
assertEquals(2, warnings.size());
for (CheckWarning warning : warnings) {
boolean found = false;
if (warning.getIris().contains(IRI.create("http://purl.obolibrary.org/obo/FOO_0004")) ||
warning.getIris().contains(IRI.create("http://purl.obolibrary.org/obo/FOO_0006"))) {
found = true;
}
assertTrue(found);
}
}
项目:owltools
文件:InferenceBuilder.java
@Override
public int compare(PotentialRedundant o1, PotentialRedundant o2) {
IRI p1 = o1.getProperty().getIRI();
IRI p2 = o2.getProperty().getIRI();
int compareTo = p1.compareTo(p2);
if (compareTo != 0) {
return compareTo;
}
IRI a1 = o1.getClassA().getIRI();
IRI a2 = o2.getClassA().getIRI();
compareTo = a1.compareTo(a2);
if (compareTo != 0) {
return compareTo;
}
IRI b1 = o1.getClassB().getIRI();
IRI b2 = o2.getClassB().getIRI();
compareTo = b1.compareTo(b2);
return compareTo;
}
项目:owltools
文件:MgiGAFOWLBridgeTest.java
@Test
public void testConversion() throws Exception{
ParserWrapper pw = new ParserWrapper();
OWLOntology ont = pw.parse(getResourceIRIString("go_xp_predictor_test_subset.obo"));
OWLGraphWrapper g = new OWLGraphWrapper(ont);
g.addSupportOntology(pw.parse(getResourceIRIString("gorel.owl")));
GafObjectsBuilder builder = new GafObjectsBuilder();
GafDocument gafdoc = builder.buildDocument(getResource("mgi-exttest.gaf"));
GAFOWLBridge bridge = new GAFOWLBridge(g);
bridge.setGenerateIndividuals(false);
OWLOntology gafOnt = g.getManager().createOntology();
bridge.setTargetOntology(gafOnt);
bridge.translate(gafdoc);
OWLDocumentFormat owlFormat = new RDFXMLDocumentFormat();
g.getManager().saveOntology(gafOnt, owlFormat, IRI.create(new File("target/gaf.owl")));
for (OWLAxiom ax : gafOnt.getAxioms()) {
//LOG.info("AX:"+ax);
}
}
项目:Hermit_1.3.8_android
文件:EntailmentChecker.java
public Boolean visit(OWLDatatypeDefinitionAxiom axiom) {
reasoner.throwInconsistentOntologyExceptionIfNecessary();
if (!reasoner.isConsistent())
return true;
if (reasoner.m_dlOntology.hasDatatypes()) {
OWLDataFactory factory=reasoner.getDataFactory();
OWLIndividual freshIndividual=factory.getOWLAnonymousIndividual("fresh-individual");
OWLDataProperty freshDataProperty=factory.getOWLDataProperty(IRI.create("fresh-data-property"));
OWLDataRange dataRange=axiom.getDataRange();
OWLDatatype dt=axiom.getDatatype();
OWLDataIntersectionOf dr1=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dataRange),dt);
OWLDataIntersectionOf dr2=factory.getOWLDataIntersectionOf(factory.getOWLDataComplementOf(dt),dataRange);
OWLDataUnionOf union=factory.getOWLDataUnionOf(dr1,dr2);
OWLClassExpression c=factory.getOWLDataSomeValuesFrom(freshDataProperty,union);
OWLClassAssertionAxiom ax=factory.getOWLClassAssertionAxiom(c,freshIndividual);
Tableau tableau=reasoner.getTableau(ax);
return !tableau.isSatisfiable(true,true,null,null,null,null,null,ReasoningTaskDescription.isAxiomEntailed(axiom));
}
else
return false;
}
项目:pronto
文件:KBStandaloneLoader.java
private void addAutoGeneratedClassNames(OWLOntologyManager manager,
OWLOntology ontology,
Map<String, OWLClassExpression> nameMap) {
OWLDataFactory factory = manager.getOWLDataFactory();
List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
for (Map.Entry<String, OWLClassExpression> entry : nameMap.entrySet()) {
OWLClass subClass = factory.getOWLClass( IRI.create(entry.getKey()) );
OWLAxiom declAxiom = factory.getOWLEquivalentClassesAxiom( subClass, entry.getValue() );
changes.addAll( manager.addAxiom( ontology, declAxiom ) );
}
manager.applyChanges( changes );
}
项目:minerva
文件:LegoModelWalker.java
protected LegoModelWalker(OWLDataFactory df) {
this.f = df;
partOf = OBOUpperVocabulary.BFO_part_of.getObjectProperty(f);
occursIn = OBOUpperVocabulary.BFO_occurs_in.getObjectProperty(f);
enabledBy = OBOUpperVocabulary.GOREL_enabled_by.getObjectProperty(f);
shortIdProp = df.getOWLAnnotationProperty(IRI.create(Obo2OWLConstants.OIOVOCAB_IRI_PREFIX+"id"));
contributor = f.getOWLAnnotationProperty(AnnotationShorthand.contributor.getAnnotationProperty());
date = f.getOWLAnnotationProperty(AnnotationShorthand.date.getAnnotationProperty());
group = f.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/group")); // TODO place holder
axiomHasEvidence = f.getOWLAnnotationProperty(IRI.create("http://purl.obolibrary.org/obo/RO_0002612"));
hasSupportingRef = f.getOWLObjectProperty(IRI.create("http://purl.obolibrary.org/obo/SEPIO_0000124"));
withSupportFrom = f.getOWLObjectProperty(IRI.create("http://purl.obolibrary.org/obo/RO_0002614"));
evidenceOld = f.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence"));
source_old = f.getOWLAnnotationProperty(AnnotationShorthand.source.getAnnotationProperty());
with_old = f.getOWLAnnotationProperty(IRI.create("http://geneontology.org/lego/evidence-with"));
}
项目:Source
文件:OntoModel.java
private OWLClass getExistingConcept(String className) {
for (String classNamewithCase : generateCaseCombinationsSimple(className)) {
for (String nameSpace : nameSpaces.values()) {
IRI fetchIRI = IRI.create(nameSpace + classNamewithCase);
if (ontology.containsClassInSignature(fetchIRI)) {
// consider classes as new if they are not present in the initial ontology
if (initialClasses.contains(dataFactory.getOWLClass(fetchIRI))) {
existingConcepts.add(fetchIRI.toString() + "\n");
}
countExistingConcepts += 1; // for a current axiom, take into account current state of the
// ontology
return dataFactory.getOWLClass(fetchIRI); // Settle on the first match found
}
}
}
return null; // return none if nothing matches.
}
项目:darceo
文件:TechnicalDescriptorConstructorBean.java
/**
* Finds the service address in the given WADL using the information contained in semantic descriptor.
*
* @param ontology
* currently browsed ontology.
* @param technicalDesc
* individual from the ontology representing technical descriptor.
* @param techDescriptorUrl
* location of technical descriptor.
* @return URL specifying the service address (location).
* @throws EntryCreationException
* should any problems with parsing WADL document occur.
*/
private String getServiceUrlFromWadl(OWLOntology ontology, OWLIndividual technicalDesc, String techDescriptorUrl)
throws EntryCreationException {
Set<OWLIndividual> resourceMethods = technicalDesc.getObjectPropertyValues(ontologyManager.getOWLDataFactory()
.getOWLObjectProperty(IRI.create(WADL_GROUNDING_PREFIX + "wadlResourceMethod")), ontology);
for (OWLIndividual resourceMethod : resourceMethods) {
Set<OWLLiteral> resources = resourceMethod.getDataPropertyValues(ontologyManager.getOWLDataFactory()
.getOWLDataProperty(IRI.create(WADL_GROUNDING_PREFIX + "resource")), ontology);
for (OWLLiteral resource : resources) {
String[] split = resource.getLiteral().split("#");
String id = split[split.length - 1].trim();
String xpath = "//" + TechnicalNamespaceContext.WADL_PREFIX + ":resource[@id='" + id + "']";
NodeList nodes = getNode(techDescriptorUrl, xpath);
String path = constructUrl(nodes.item(0));
return path;
}
}
throw new EntryCreationException("Could not find location of the service specified in grounding.");
}
项目:minerva
文件:GafToLegoTranslator.java
/**
* Translate the given {@link GafDocument} into an OWL representation of the LEGO model.
* Additionally minimize the lego model and imports into one ontology module.
*
* @param gaf
* @return minimized lego ontology
*/
public OWLOntology minimizedTranslate(GafDocument gaf) {
OWLOntology all = translate(gaf);
final OWLOntologyManager m = all.getOWLOntologyManager();
SyntacticLocalityModuleExtractor sme = new SyntacticLocalityModuleExtractor(m, all, ModuleType.BOT);
Set<OWLEntity> sig = new HashSet<OWLEntity>(all.getIndividualsInSignature());
Set<OWLAxiom> moduleAxioms = sme.extract(sig);
try {
OWLOntology module = m.createOntology(IRI.generateDocumentIRI());
m.addAxioms(module, moduleAxioms);
return module;
} catch (OWLException e) {
throw new RuntimeException("Could not create minimized lego model.", e);
}
}
项目:owltools
文件:Similarity.java
protected String[] splitIRI(IRI x) {
String s = x.toString();
String id = null;
if (s.startsWith(Obo2OWLConstants.DEFAULT_IRI_PREFIX)) {
id = s.replaceAll(Obo2OWLConstants.DEFAULT_IRI_PREFIX, "");
return new String[]{Obo2OWLConstants.DEFAULT_IRI_PREFIX,id};
}
for (String del : new String[]{"#","/",":"}) {
if (s.contains(del)) {
String[] r = s.split(del,2);
r[0] = r[0]+del;
return r;
}
}
return new String[]{"",s};
}
项目:owltools
文件:OWLGraphWrapperBasic.java
/**
* Merge a specific ontology from the import closure into the main ontology.
* Removes the import statement.
*
* @param ontologyIRI id of the ontology to merge
* @throws OWLOntologyCreationException
*/
public void mergeSpecificImport(IRI ontologyIRI) throws OWLOntologyCreationException {
OWLOntologyManager manager = getManager();
Set<OWLOntology> imports = sourceOntology.getImportsClosure();
for (OWLOntology o : imports) {
if (o.equals(sourceOntology))
continue;
Optional<IRI> currentIRI = o.getOntologyID().getOntologyIRI();
if (currentIRI.isPresent() && currentIRI.get().equals(ontologyIRI)) {
String comment = "Includes "+summarizeOntology(o);
LOG.info(comment);
addCommentToOntology(sourceOntology, comment);
manager.addAxioms(sourceOntology, o.getAxioms());
}
}
Set<OWLImportsDeclaration> oids = sourceOntology.getImportsDeclarations();
for (OWLImportsDeclaration oid : oids) {
if (ontologyIRI.equals(oid.getIRI())) {
RemoveImport ri = new RemoveImport(sourceOntology, oid);
getManager().applyChange(ri);
}
}
}
项目:minerva
文件:JsonTools.java
private static JsonAnnotation create(final String key, OWLAnnotationValue value, final CurieHandler curieHandler) {
return value.accept(new OWLAnnotationValueVisitorEx<JsonAnnotation>() {
@Override
public JsonAnnotation visit(IRI iri) {
String iriString = curieHandler.getCuri(iri);
return JsonAnnotation.create(key, iriString, VALUE_TYPE_IRI);
}
@Override
public JsonAnnotation visit(OWLAnonymousIndividual individual) {
return null; // do nothing
}
@Override
public JsonAnnotation visit(OWLLiteral literal) {
return JsonAnnotation.create(key, literal.getLiteral(), getType(literal));
}
});
}
项目:owltools
文件:ClassTaxonMatrixShortTest.java
@BeforeClass
public static void beforeClass() throws Exception {
ParserWrapper pw = new ParserWrapper();
IRI iri = IRI.create(new File("src/test/resources/simple_taxon_check.owl").getCanonicalFile());
all = new OWLGraphWrapper(pw.parseOWL(iri));
animal = all.getOWLClass(IRI.create("http://foo.bar/animal"));
vertebrate = all.getOWLClass(IRI.create("http://foo.bar/vertebrate"));
mammal = all.getOWLClass(IRI.create("http://foo.bar/mammal"));
mouse = all.getOWLClass(IRI.create("http://foo.bar/mouse"));
human = all.getOWLClass(IRI.create("http://foo.bar/human"));
bird = all.getOWLClass(IRI.create("http://foo.bar/bird"));
chicken = all.getOWLClass(IRI.create("http://foo.bar/chicken"));
hair = all.getOWLClass(IRI.create("http://foo.bar/hair"));
hair_root = all.getOWLClass(IRI.create("http://foo.bar/hair_root"));
whisker = all.getOWLClass(IRI.create("http://foo.bar/whisker"));
tip_of_whisker = all.getOWLClass(IRI.create("http://foo.bar/tip_of_whisker"));
relevant = new HashSet<OWLClass>(Arrays.asList(hair, hair_root, whisker, tip_of_whisker));
taxa = new HashSet<OWLClass>(Arrays.asList(animal, vertebrate, mammal, mouse, human, bird, chicken));
}
项目:owltools
文件:ExtendedReasonerTest.java
@Test
public void testQuery() throws Exception{
g = getOntologyWrapper("extended-reasoner-test.omn");
parser = new ManchesterSyntaxTool(g.getSourceOntology(), g.getSupportOntologySet());
reasoner = new ExpressionMaterializingReasoner(g.getSourceOntology(),
new ElkReasonerFactory(), BufferingMode.NON_BUFFERING);
reasoner.flush();
IRI piri;
piri = IRI.create("http://x.org/part_of");
OWLObjectProperty p =
g.getDataFactory().getOWLObjectProperty(piri);
findAncestors("digit", p, true, 1);
findAncestors("digit", p, false, 2);
findAncestors("toe", p, true, 1);
findAncestors("toe", p, false, 4);
findAncestors("phalanx", p, true, 1);
findAncestors("phalanx", p, false, 4);
findAncestors("mouse_phalanx", p, true, 2);
findAncestors("brachialis", p, true, 1);
}
项目:RDF2PT
文件:SimpleIRIConverter.java
@Override
public String convert(String iri) {
// get short form
String shortForm = sfp.getShortForm(IRI.create(iri));
// normalize
shortForm = normalize(shortForm);
return shortForm;
}
项目:RDF2PT
文件:SPARQLFunctionalityDetector.java
@Override
public boolean isFunctional(String uri) {
try {
return sparqlReasoner.isFunctional(new OWLObjectPropertyImpl(IRI.create(uri)));
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
项目:OntoBench
文件:DcIdentifierFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "identifier"));
Optional<IRI> optionalIri = ontology.getOntologyID().getOntologyIRI();
if (optionalIri.isPresent()) {
String iri = optionalIri.get().toString();
OWLAnnotation identifier = factory.getOWLAnnotation(property, factory.getOWLLiteral(iri));
addChangeToOntology(new AddOntologyAnnotation(ontology, identifier));
}
}
项目:OntoBench
文件:DcContributorFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "contributor"));
OWLAnnotation contributor = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getContributor()));
addChangeToOntology(new AddOntologyAnnotation(ontology, contributor));
}
项目:OntoBench
文件:DcDescriptionFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "description"));
OWLAnnotation description = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getDescription()));
addChangeToOntology(new AddOntologyAnnotation(ontology, description));
}
项目:OntoBench
文件:DcDateFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "date"));
OWLAnnotation date = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getGenerationDate()));
addChangeToOntology(new AddOntologyAnnotation(ontology, date));
}
项目:OntoBench
文件:DcTitleFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "title"));
OWLAnnotation title = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getTitle()));
addChangeToOntology(new AddOntologyAnnotation(ontology, title));
}
项目:OntoBench
文件:DcPublisherFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "publisher"));
OWLAnnotation publisher = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getCreator()));
addChangeToOntology(new AddOntologyAnnotation(ontology, publisher));
}
项目:OntoBench
文件:DcCreatorFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty property = factory.getOWLAnnotationProperty(IRI.create(Namespaces.DC + "creator"));
OWLAnnotation creator = factory.getOWLAnnotation(property, factory.getOWLLiteral(ontologyConstants.getCreator()));
addChangeToOntology(new AddOntologyAnnotation(ontology, creator));
}
项目:OntoBench
文件:RdfsSeeAlsoFeature.java
@Override
public void addToOntology() {
OWLAnnotationProperty annotationProperty = factory.getOWLAnnotationProperty(RDFS_SEE_ALSO, pm);
OWLAnnotation annotation = factory.getOWLAnnotation(annotationProperty, IRI.create(requestInformation.getGeneratorIri()));
addChangeToOntology(new AddOntologyAnnotation(ontology, annotation));
}