本文整理汇总了Java中org.openrdf.model.vocabulary.OWL类的典型用法代码示例。如果您正苦于以下问题:Java OWL类的具体用法?Java OWL怎么用?Java OWL使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OWL类属于org.openrdf.model.vocabulary包,在下文中一共展示了OWL类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setUp
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
Repository fromrepo = new SailRepository( new MemoryStore() );
Repository torepo = new SailRepository( new MemoryStore() );
fromrepo.initialize();
torepo.initialize();
from = fromrepo.getConnection();
to = torepo.getConnection();
from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
new LiteralImpl( "test" ) ) );
from.add( new StatementImpl( RDFS.DOMAIN, RDFS.LABEL,
new LiteralImpl( "test2" ) ) );
from.setNamespace( OWL.PREFIX, OWL.NAMESPACE );
}
示例2: refreshPropertyRestrictions
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private void refreshPropertyRestrictions() throws QueryEvaluationException {
// Get a set of all property restrictions of any type
final CloseableIteration<Statement, QueryEvaluationException> iter = RyaDAOHelper.query(ryaDAO, null, OWL.ONPROPERTY, null, conf);
final Map<Resource, URI> restrictions = new HashMap<>();
try {
while (iter.hasNext()) {
final Statement st = iter.next();
restrictions.put(st.getSubject(), (URI) st.getObject());
}
} finally {
if (iter != null) {
iter.close();
}
}
// Query for specific types of restriction and add their details to the schema
refreshHasValueRestrictions(restrictions);
refreshSomeValuesFromRestrictions(restrictions);
refreshAllValuesFromRestrictions(restrictions);
refreshHasSelfRestrictions(restrictions);
}
示例3: refreshSomeValuesFromRestrictions
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private void refreshSomeValuesFromRestrictions(final Map<Resource, URI> restrictions) throws QueryEvaluationException {
someValuesFromByRestrictionType.clear();
ryaDaoQueryWrapper.queryAll(null, OWL.SOMEVALUESFROM, null, new RDFHandlerBase() {
@Override
public void handleStatement(final Statement statement) throws RDFHandlerException {
final Resource restrictionClass = statement.getSubject();
if (restrictions.containsKey(restrictionClass) && statement.getObject() instanceof Resource) {
final URI property = restrictions.get(restrictionClass);
final Resource valueClass = (Resource) statement.getObject();
// Should also be triggered by subclasses of the value class
final Set<Resource> valueClasses = new HashSet<>();
valueClasses.add(valueClass);
if (valueClass instanceof URI) {
valueClasses.addAll(getSubClasses((URI) valueClass));
}
for (final Resource valueSubClass : valueClasses) {
if (!someValuesFromByRestrictionType.containsKey(restrictionClass)) {
someValuesFromByRestrictionType.put(restrictionClass, new ConcurrentHashMap<>());
}
someValuesFromByRestrictionType.get(restrictionClass).put(valueSubClass, property);
}
}
}
});
}
示例4: refreshAllValuesFromRestrictions
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private void refreshAllValuesFromRestrictions(final Map<Resource, URI> restrictions) throws QueryEvaluationException {
allValuesFromByValueType.clear();
ryaDaoQueryWrapper.queryAll(null, OWL.ALLVALUESFROM, null, new RDFHandlerBase() {
@Override
public void handleStatement(final Statement statement) throws RDFHandlerException {
final Resource directRestrictionClass = statement.getSubject();
if (restrictions.containsKey(directRestrictionClass) && statement.getObject() instanceof Resource) {
final URI property = restrictions.get(directRestrictionClass);
final Resource valueClass = (Resource) statement.getObject();
// Should also be triggered by subclasses of the property restriction
final Set<Resource> restrictionClasses = new HashSet<>();
restrictionClasses.add(directRestrictionClass);
if (directRestrictionClass instanceof URI) {
restrictionClasses.addAll(getSubClasses((URI) directRestrictionClass));
}
for (final Resource restrictionClass : restrictionClasses) {
if (!allValuesFromByValueType.containsKey(valueClass)) {
allValuesFromByValueType.put(valueClass, new ConcurrentHashMap<>());
}
allValuesFromByValueType.get(valueClass).put(restrictionClass, property);
}
}
}
});
}
示例5: getReplaceJoin
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private InferJoin getReplaceJoin(Set<Resource> uris, boolean subSubj, Var subjVar, Var objVar, Var predVar, Var cntxtVar){
String s = UUID.randomUUID().toString();
Var dummyVar = new Var(s);
StatementPattern origStatement;
Var subVar;
if (subSubj){
subVar = subjVar;
origStatement = new DoNotExpandSP(dummyVar, predVar, objVar, cntxtVar);
}
else {
subVar = objVar;
origStatement = new DoNotExpandSP(subjVar, predVar, dummyVar, cntxtVar);
}
FixedStatementPattern fsp = new FixedStatementPattern(dummyVar, new Var("c-" + s, OWL.SAMEAS), subVar, cntxtVar);
for (Resource sameAs : uris){
NullableStatementImpl newStatement = new NullableStatementImpl(sameAs, OWL.SAMEAS, (Resource)subVar.getValue(), getVarValue(cntxtVar));
fsp.statements.add(newStatement);
}
InferJoin join = new InferJoin(fsp, origStatement);
join.getProperties().put(InferConstants.INFERRED, InferConstants.TRUE);
return join;
}
示例6: testSingleStatementPattern
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
@Test
public void testSingleStatementPattern() throws Exception {
// Insert data
insert(OWL.THING, RDF.TYPE, OWL.CLASS);
insert(FOAF.PERSON, RDF.TYPE, OWL.CLASS, 1);
insert(FOAF.PERSON, RDFS.SUBCLASSOF, OWL.THING);
insert(VF.createURI("urn:Alice"), RDF.TYPE, FOAF.PERSON);
dao.flush();
// Define query and expected results
final String query = "SELECT * WHERE {\n"
+ " ?individual a ?type .\n"
+ "}";
List<String> varNames = Arrays.asList("individual", "type");
Multiset<BindingSet> expectedSolutions = HashMultiset.create();
expectedSolutions.add(new ListBindingSet(varNames, OWL.THING, OWL.CLASS));
expectedSolutions.add(new ListBindingSet(varNames, FOAF.PERSON, OWL.CLASS));
expectedSolutions.add(new ListBindingSet(varNames, VF.createURI("urn:Alice"), FOAF.PERSON));
// Execute pipeline and verify results
testPipelineQuery(query, expectedSolutions);
}
示例7: testMultiConstruct
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
@Test
public void testMultiConstruct() throws Exception {
// Insert data
URI alice = VF.createURI("urn:Alice");
URI bob = VF.createURI("urn:Bob");
URI eve = VF.createURI("urn:Eve");
URI friend = VF.createURI("urn:friend");
URI knows = VF.createURI("urn:knows");
URI person = VF.createURI("urn:Person");
insert(alice, friend, bob);
insert(bob, knows, eve);
insert(eve, knows, alice);
// Define query and expected results
final String query = "CONSTRUCT {\n"
+ " ?x rdf:type owl:Thing .\n"
+ " ?x rdf:type <urn:Person> .\n"
+ "} WHERE { ?x <urn:knows> ?y }";
final Multiset<BindingSet> expected = HashMultiset.create();
List<String> varNames = Arrays.asList("subject", "predicate", "object");
expected.add(new ListBindingSet(varNames, bob, RDF.TYPE, OWL.THING));
expected.add(new ListBindingSet(varNames, bob, RDF.TYPE, person));
expected.add(new ListBindingSet(varNames, eve, RDF.TYPE, OWL.THING));
expected.add(new ListBindingSet(varNames, eve, RDF.TYPE, person));
// Test query
testPipelineQuery(query, expected);
}
示例8: interfaceHeader
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private void interfaceHeader(JavaMessageBuilder builder)
throws ObjectStoreConfigException {
String pkg = builder.getPackageName(this.getURI());
String simple = builder.getSimpleName(this.getURI());
if (pkg == null) {
builder.imports(simple);
} else {
builder.pkg(pkg);
builder.imports(pkg + '.' + simple);
}
builder.comment(this);
if (this.isA(OWL.DEPRECATEDCLASS)) {
builder.annotate(Deprecated.class);
}
builder.annotationProperties(this);
if (!builder.isAnonymous(this.getURI())) {
builder.annotateURI(Iri.class, "value", builder.getType(this.getURI()));
}
builder.interfaceName(simple);
for (RDFClass sups : this.getRDFClasses(RDFS.SUBCLASSOF)) {
if (sups.getURI() == null || sups.equals(this))
continue;
builder.extend(builder.getClassName(sups.getURI()));
}
}
示例9: testGeneralConsequent
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
@Test
public void testGeneralConsequent() throws Exception {
String text = "CONSTRUCT {\n"
+ " ?x ?p2 ?y"
+ "} WHERE {\n"
+ " ?x ?p1 ?y .\n"
+ " ?p1 rdfs:subPropertyOf ?p2 .\n"
+ "}";
ParsedGraphQuery query = (ParsedGraphQuery) PARSER.parseQuery(text, null);
SpinConstructRule rule = new SpinConstructRule(OWL.THING, RL_PRP_SPO1, query);
Multiset<StatementPattern> expectedAntecedents = HashMultiset.create(Arrays.asList(
new StatementPattern(new Var("p1"), ac(RDFS.SUBPROPERTYOF), new Var("p2")),
new StatementPattern(new Var("x"), new Var("p1"), new Var("y"))));
Multiset<StatementPattern> expectedConsequents = HashMultiset.create(Arrays.asList(
new StatementPattern(new Var("subject"), new Var("predicate"), new Var("object"))));
Assert.assertEquals(expectedAntecedents, HashMultiset.create(rule.getAntecedentPatterns()));
Assert.assertEquals(expectedConsequents, HashMultiset.create(rule.getConsequentPatterns()));
Assert.assertFalse(rule.hasAnonymousConsequent());
// Basic pattern matches
Assert.assertTrue(rule.canConclude(new StatementPattern(new Var("a"), new Var("b"), new Var("c"))));
// Narrower patterns match (constants in place of variables)
Assert.assertTrue(rule.canConclude(new StatementPattern(new Var("x"), c(RDFS.SUBPROPERTYOF), c(OWL.THING))));
Assert.assertTrue(rule.canConclude(new StatementPattern(c(OWL.NOTHING), new Var("prop"), c(OWL.THING))));
Assert.assertTrue(rule.canConclude(new StatementPattern(c(FOAF.PERSON), c(RDFS.SUBCLASSOF), new Var("x"))));
Assert.assertTrue(rule.canConclude(new StatementPattern(c(OWL.NOTHING), c(RDFS.SUBCLASSOF), c(FOAF.PERSON))));
}
示例10: getMessageName
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
private String getMessageName(RDFClass msg) {
List<? extends Value> list = msg.getList(OWL.INTERSECTIONOF);
if (list != null) {
for (Value value : list) {
if (value instanceof URI) {
RDFClass rc = new RDFClass(msg.getModel(), (URI) value);
if (rc.isMessageClass()) {
String name = getMessageName(rc);
if (name != null)
return name;
}
}
}
}
if (resolver.isAnonymous(msg.getURI()))
return null;
return resolver.getMethodName(msg.getURI());
}
示例11: testConcreteSP
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
@Test
public void testConcreteSP() {
Extension extension = new Extension(new SingletonSet(),
new ExtensionElem(new ValueConstant(FOAF.PERSON), "x"),
new ExtensionElem(new ValueConstant(RDF.TYPE), "y"),
new ExtensionElem(new ValueConstant(OWL.CLASS), "z"));
Projection projection = new Projection(extension, new ProjectionElemList(
new ProjectionElem("x", "subject"),
new ProjectionElem("y", "predicate"),
new ProjectionElem("z", "object")));
ConstructConsequentVisitor visitor = new ConstructConsequentVisitor();
projection.visit(visitor);
Set<StatementPattern> expected = Sets.newHashSet(
new StatementPattern(s(FOAF.PERSON), p(RDF.TYPE), o(OWL.CLASS)));
Assert.assertEquals(expected, visitor.getConsequents());
}
示例12: triviallyTrue
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
/**
* Determine that a statement is trivially true for purposes of entailment
* tests, such as an implicit "[bnode] type Ontology" triple or a
* "[class] type Class" triple as long as the class exists.
*/
boolean triviallyTrue(final Statement triple, final Schema schema) {
final Resource s = triple.getSubject();
final URI p = triple.getPredicate();
final Value o = triple.getObject();
if (p.equals(RDF.TYPE)) {
if (o.equals(OWL.ONTOLOGY)) {
return true;
}
else if (o.equals(OWL.CLASS)) {
return schema.hasClass(s);
}
else if ((o.equals(OWL.OBJECTPROPERTY)
|| o.equals(OWL.DATATYPEPROPERTY))
&& s instanceof URI) {
// Distinction not maintained, irrelevant to RL rules
return schema.hasProperty((URI) s);
}
}
return false;
}
示例13: addPropertyType
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
/**
* Add a particular characteristic to a property.
*/
private void addPropertyType(URI p, Resource t) {
OwlProperty prop = getProperty(p);
if (t.equals(OWL.TRANSITIVEPROPERTY)) {
prop.setTransitive();
}
else if (t.equals(OWL.SYMMETRICPROPERTY)) {
prop.setSymmetric();
}
else if (t.equals(OWL2.ASYMMETRICPROPERTY)) {
prop.setAsymmetric();
}
else if (t.equals(OWL.FUNCTIONALPROPERTY)) {
prop.setFunctional();
}
else if (t.equals(OWL.INVERSEFUNCTIONALPROPERTY)) {
prop.setInverseFunctional();
}
else if (t.equals(OWL2.IRREFLEXIVEPROPERTY)) {
prop.setIrreflexive();
}
}
示例14: testHasValueSubProp
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
/**
* scm-hv
*/
@Test
public void testHasValueSubProp() throws Exception {
Resource c1 = TestUtils.bnode("c1");
Resource c2 = TestUtils.bnode("c2");
schema.processTriple(TestUtils.statement(c1, OWL.HASVALUE,
TestUtils.stringLiteral("big data")));
schema.processTriple(TestUtils.statement(c1, OWL.ONPROPERTY,
TestUtils.uri("researchSpecialty")));
schema.processTriple(TestUtils.statement(c2, OWL.HASVALUE,
TestUtils.stringLiteral("big data")));
schema.processTriple(TestUtils.statement(c2, OWL.ONPROPERTY,
TestUtils.uri("researchInterest")));
schema.closure();
Assert.assertTrue("[hasValue x on <subproperty>] should be subclass of"
+ " [hasValue x on <superproperty>]",
schema.getClass(c1).getSuperClasses().contains(c2));
}
示例15: testSomeValuesSubClass
import org.openrdf.model.vocabulary.OWL; //导入依赖的package包/类
/**
* scm-svf1
*/
@Test
public void testSomeValuesSubClass() throws Exception {
Resource c1 = TestUtils.bnode("c1");
Resource c2 = TestUtils.bnode("c2");
schema.processTriple(TestUtils.statement(c1, OWL.SOMEVALUESFROM,
TestUtils.uri("ResearchGroup")));
schema.processTriple(TestUtils.statement(c1, OWL.ONPROPERTY,
TestUtils.uri("worksFor")));
schema.processTriple(TestUtils.statement(c2, OWL.SOMEVALUESFROM,
TestUtils.uri("Organization")));
schema.processTriple(TestUtils.statement(c2, OWL.ONPROPERTY,
TestUtils.uri("worksFor")));
schema.closure();
Assert.assertTrue("[someValuesFrom <subclass> on p] should be subclass of"
+ " [someValuesFrom <superclass> on p]",
schema.getClass(c1).getSuperClasses().contains(c2));
}