當前位置: 首頁>>代碼示例>>Java>>正文


Java IRI.create方法代碼示例

本文整理匯總了Java中org.semanticweb.owlapi.model.IRI.create方法的典型用法代碼示例。如果您正苦於以下問題:Java IRI.create方法的具體用法?Java IRI.create怎麽用?Java IRI.create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.semanticweb.owlapi.model.IRI的用法示例。


在下文中一共展示了IRI.create方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testOWLClassHashCode

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
/**
 * Test that two {@code OWLClass}es that are equal have a same hashcode, 
 * because the OWLGraphEdge bug get me paranoid. 
 */
@Test
public void testOWLClassHashCode()
{
	 OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
	 OWLDataFactory factory = manager.getOWLDataFactory(); 
	 IRI iri = IRI.create("http://www.foo.org/#A");
	 OWLClass class1 = factory.getOWLClass(iri);
	 //get the class by another way, even if if I suspect the two references 
	 //will point to the same object
	 PrefixManager pm = new DefaultPrefixManager("http://www.foo.org/#"); 
	 OWLClass class2 = factory.getOWLClass(":A", pm);
	 
	 assertTrue("The two references point to different OWLClass objects", 
			 class1 == class2);
	 //then of course the hashcodes will be the same...
	 assertTrue("Two OWLClasses are equal but have different hashcode", 
			 class1.equals(class2) && class1.hashCode() == class2.hashCode());
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:23,代碼來源:OWLGraphManipulatorTest.java

示例2: getLabelFromBuiltIn

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
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;
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:27,代碼來源:DefaultIRIConverter.java

示例3: getLabelFromBuiltIn

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
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;
}
 
開發者ID:dice-group,項目名稱:RDF2PT,代碼行數:26,代碼來源:DefaultIRIConverterFrench.java

示例4: getOntologyFromName

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:IGNF,項目名稱:geoxygene,代碼行數:26,代碼來源:OwlUtil.java

示例5: getExistingProperty

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
private OWLProperty getExistingProperty(String relationName) {
	for (String relationNamewithCase : generateCaseCombinationsSimple(relationName)) {
		for (String nameSpace : nameSpaces.values()) {
			IRI fetchIRI = IRI.create(nameSpace + relationNamewithCase);
			if (ontology.containsDataPropertyInSignature(fetchIRI)) {
				// consider properties as new if they are not present in the initial ontology
				if (initialProperties.contains(dataFactory.getOWLObjectProperty(fetchIRI))) {
					existingRelations.add(fetchIRI.toString() + "\n");
				}
				countExistingRelations += 1; // for a current axiom, take into account current state of
												// the ontology
				return dataFactory.getOWLDataProperty(fetchIRI);
			}
			if (ontology.containsObjectPropertyInSignature(fetchIRI)) {
				// consider properties as new if they are not present in the initial ontology
				if (initialProperties.contains(dataFactory.getOWLObjectProperty(fetchIRI))) {
					existingRelations.add(fetchIRI.toString() + "\n");
				}
				countExistingRelations += 1;
				return dataFactory.getOWLObjectProperty(fetchIRI);
			}
		}
	}
	return null; // return null if nothing matches.
}
 
開發者ID:ModelWriter,項目名稱:Source,代碼行數:26,代碼來源:OntoModel.java

示例6: getOneOfAuxiliaryClass

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
/**
 * For a One-of Object {a,b,c,...} create and auxiliary class oo1, and
 * and axiom <code>oo1 subSetOf guard_i_a or guard_i_b or ...</code>
 * @param objectOneOf
 * @return
 */
private OWLClass getOneOfAuxiliaryClass(OWLObjectOneOf objectOneOf) {
	if (oneOfAuxClasses.containsKey(objectOneOf))
		return oneOfAuxClasses.get(objectOneOf);

	OWLClass auxOneOf = new OWLClassImpl(IRI.create(INTERNAL_IRI_PREFIX + "#oneOfaux" + (oneOfAuxClasses.size()+1)));
	OWLClassExpression[] inclusion = new OWLClassExpression[2];

	inclusion[0] = new OWLObjectComplementOfImpl(auxOneOf);
	inclusion[1] = objectOneOf;

	//translateInclusion(inclusion);
	newInclusions.add(inclusion);

	// add to the set of class which needs to be guessed
	// auxClasses.add(auxOneOf);
	oneOfAuxClasses.put(objectOneOf, auxOneOf);
	return auxOneOf;
}
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:25,代碼來源:DebugTranslation.java

示例7: getExistingConcept

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
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.
}
 
開發者ID:ModelWriter,項目名稱:Source,代碼行數:18,代碼來源:OntoModel.java

示例8: test

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void test() throws Exception {
	ParserWrapper parser = new ParserWrapper();
	IRI iri = IRI.create(getResource("verification/altid_in_signature.obo").getAbsoluteFile());
	OWLGraphWrapper graph = parser.parseToOWLGraph(iri.toString());
	
	AltIdInSignature check = new AltIdInSignature();
	
	Collection<CheckWarning> warnings = check.check(graph, graph.getAllOWLObjects());
	assertEquals(2, warnings.size());
	final IRI offendingIRI = IRI.create("http://purl.obolibrary.org/obo/FOO_0003");
	for (CheckWarning warning : warnings) {
		assertTrue(warning.getIris().contains(offendingIRI));
		assertFalse(warning.isFatal());
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:17,代碼來源:AltIdInSignatureTest.java

示例9: isOntologyURI

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
private boolean isOntologyURI(String token) {
	try {
		final URI uri = new URI(token);
		if (uri.isAbsolute()) {
			IRI iri = IRI.create(uri);
			OWLOntology ont = getOWLModelManager().getOWLOntologyManager().getOntology(iri);
			if (getOWLModelManager().getActiveOntologies().contains(ont)) {
				return true;
			}
		}
	} catch (URISyntaxException e) {
		// just dropthough
	}
	return false;
}
 
開發者ID:md-k-sarker,項目名稱:OWLAx,代碼行數:16,代碼來源:OWLCellRenderer.java

示例10: convertOntology

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
public OWLOntology convertOntology(Map<Object,Object> m) throws OWLOntologyCreationException {
	Set<OWLAxiom> axioms = null;
	IRI ontologyIRI = null;
	List<OWLOntologyChange> changes = new ArrayList<OWLOntologyChange>();
	List<IRI> importsIRIs = new ArrayList<IRI>();
	for (Object k : m.keySet()) {
		if (k.equals("axioms")) {
			axioms = convertAxioms((Object[]) m.get(k));			
		}
		else if (k.equals("iri")) {
			ontologyIRI = IRI.create((String) m.get(k));
		}
		else if (k.equals("annotations")) {
			// TODO
		}
		else if (k.equals("imports")) {
			IRI importIRI = IRI.create((String) m.get(k));
			importsIRIs.add(importIRI);
			
		}
	}
	OWLOntology ont = manager.createOntology(ontologyIRI);
	for (IRI importsIRI : importsIRIs) {
		AddImport ai = new AddImport(ont, manager.getOWLDataFactory().getOWLImportsDeclaration(importsIRI));
		changes.add(ai);
	}
	manager.applyChanges(changes);
	return ont;
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:30,代碼來源:OWLGsonParser.java

示例11: getAuxClass

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
private OWLClass getAuxClass(OWLClassExpression complexExpression) {
	if (auxiliaryMappings.containsKey(complexExpression))
		return auxiliaryMappings.get(complexExpression);
	OWLClass auxClass = new OWLClassImpl(IRI.create(INTERNAL_IRI_PREFIX + "#aux" + complexExpression.hashCode()));
	auxiliaryMappings.put(complexExpression, auxClass);
	return auxClass;
}
 
開發者ID:wolpertinger-reasoner,項目名稱:Wolpertinger,代碼行數:8,代碼來源:DirectTranslation.java

示例12: testNonCycle2

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testNonCycle2() throws Exception {
	ParserWrapper parser = new ParserWrapper();
	IRI iri = IRI.create(getResource("verification/name_redundancy.obo").getAbsoluteFile()) ;
	OWLGraphWrapper graph = parser.parseToOWLGraph(iri.toString());
	
	OntologyCheck check = new CycleCheck();
	
	Collection<CheckWarning> warnings = check.check(graph, graph.getAllOWLObjects());
	assertTrue(warnings.isEmpty());
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:12,代碼來源:CycleCheckTest.java

示例13: testPValue

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testPValue() throws Exception {
	ParserWrapper pw = new ParserWrapper();
	sourceOntol = pw.parseOBO(getResource("sim/mp-subset-1.obo").getAbsolutePath());
	g =  new OWLGraphWrapper(sourceOntol);
	parseAssociations(getResource("sim/mgi-gene2mp-subset-1.tbl"), g);

	LOG.info("Initialize OwlSim ..");

	OWLReasoner reasoner = new ElkReasonerFactory().createReasoner(sourceOntol);
	reasoner.flush();
	
	try {
		owlsim = owlSimFactory.createOwlSim(sourceOntol);
		owlsim.createElementAttributeMapFromOntology();
		owlsim.computeSystemStats();
	} catch (UnknownOWLClassException e) {
		e.printStackTrace();
	} finally {
		reasoner.dispose();
	}

	// Source sourceOntol and g are used as background knowledge ... 
	OWLSimReferenceBasedStatistics refBasedStats = new OWLSimReferenceBasedStatistics(owlsim, sourceOntol, g);
	
	IRI iri = IRI.create("http://purl.obolibrary.org/obo/MGI_101761");
	
	String[] testClasses = new String[] {"MP:0002758", "MP:0002772", "MP:0005448", "MP:0003660"};
	Set<OWLClass> testClassesSet = new HashSet<OWLClass>();
	for (String testClass : testClasses) {
		testClassesSet.add(this.getOBOClass(testClass));
	}

	PValue pValue = refBasedStats.getPValue(testClassesSet, iri);
	LOG.info(pValue.getSimplePValue());

}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:38,代碼來源:OwlSimVarianceTest.java

示例14: testIsURI

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
@Test
public void testIsURI() 
{
	QueryArgument arg = new QueryArgument(IRI.create("http://example.com"));
	assertTrue(arg.isURI());
	QueryArgument arg2 = new QueryArgument(new Var("x"));
	assertFalse(arg2.isURI());
}
 
開發者ID:protegeproject,項目名稱:sparql-dl-api,代碼行數:9,代碼來源:QueryArgumentTest.java

示例15: makeDefaultIndividuals

import org.semanticweb.owlapi.model.IRI; //導入方法依賴的package包/類
/**
 * Creates a "fake" individual for every class.
 * 
 * ABox IRI = TBox IRI + suffix
 * 
 * if suffix == null, then we are punning
 * 
 * @param srcOnt
 * @param iriSuffix
 * @throws OWLOntologyCreationException
 */
public static void makeDefaultIndividuals(OWLOntology srcOnt, String iriSuffix) throws OWLOntologyCreationException {
	OWLOntologyManager m = srcOnt.getOWLOntologyManager();
	OWLDataFactory df = m.getOWLDataFactory();
	for (OWLClass c : srcOnt.getClassesInSignature(Imports.INCLUDED)) {
		IRI iri;
		if (iriSuffix == null || iriSuffix.equals(""))
		  iri = c.getIRI();
		else
			iri = IRI.create(c.getIRI().toString()+iriSuffix);
		OWLNamedIndividual ind = df.getOWLNamedIndividual(iri);
		m.addAxiom(srcOnt, df.getOWLDeclarationAxiom(ind));
		m.addAxiom(srcOnt, df.getOWLClassAssertionAxiom(c, ind));
	}
}
 
開發者ID:owlcollab,項目名稱:owltools,代碼行數:26,代碼來源:ABoxUtils.java


注:本文中的org.semanticweb.owlapi.model.IRI.create方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。