本文整理汇总了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());
}
示例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;
}
示例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;
}
示例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;
}
示例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.
}
示例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;
}
示例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.
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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());
}
示例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());
}
示例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());
}
示例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));
}
}