DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
The Latest "Software Integration: The Intersection of APIs, Microservices, and Cloud-Based Systems" Trend Report
Get the report

How to Generate New Relationships With RDFS+ Inferencing in AnzoGraph

This article explains how to generate inferences with AnzoGraph and describes the supported inference vocabularies.

Erin Martin user avatar by
Erin Martin
·
Mar. 20, 19 · Tutorial
Like (1)
Save
Tweet
Share
7.04K Views

Join the DZone community and get the full member experience.

Join For Free

AnzoGraph includes an RDFS+ inference engine that can create new relationships based on the vocabularies or ontologies in the existing data.

The following example from the W3C Semantic Web Inference documentation illustrates the inference concept:

A data set might include the relationship "Flipper isA Dolphin." An ontology might declare that "every Dolphin is also a Mammal." An inference program that understands the notion of "X is also Y" adds the statement "Flipper isA Mammal" to the set of relationships even though it was not specified in the original data.

When AnzoGraph creates inferences, it scans the specified graph for any of the supported RDFS and OWL ontologies and generates new triples according to the W3C OWL 2 RL rules.

This article explains how to generate inferences with AnzoGraph and describes the supported inference vocabularies. You can download a free trial of AnzoGraph and try the inference example that follows.

Generating Inferences With AnzoGraph

In AnzoGraph, run the following command to generate inferences from an existing graph:

 CREATE INFERENCES [ FROM source_graph ] INTO GRAPH target_graph 

When you run the CREATE INFERENCES command, AnzoGraph runs rules for each of the following RDFS and OWL ontologies that it finds and inserts the inferred triples into the specified target graph:

  • owl:equivalentClass: Indicates that two classes are synonymous.
  • owl:equivalentProperty: Indicates that two properties are synonymous.
  • owl:intersectionOf: Indicates that an instance belongs to every one of the specified classes.
  • owl:inverseOf: Indicates that two properties are the inverse of each other.
  • owl:sameAs: Indicates that two instances are equal and have the same meaning. All statements about one instance are true for the other instance.
  • owl:someValuesFrom: Indicates that at least one object of a property is a member of the specified class.
  • owl:SymmetricProperty: Indicates that the inverse is true for a property. If a property relates A to B then it also relates B to A.
  • owl:TransitiveProperty: Indicates that chains of relationships collapse into a single relationship. If property A links to B and B links to C, then A links to C.
  • rdfs:domain: Indicates that the subject of a triple is classified into the domain of the predicate.
  • rdfs:range: Indicates that the object of the triple is classified into the range of the predicate.
  • rdfs:subClassOf: Indicates that members of a subclass are also members of the superclass.
  • rdfs:subPropertyOf: Indicates that relationships that are described by a subproperty also hold for the superproperty.

Inference Example

The following simple example demonstrates the inferences that AnzoGraph generates to infer friendships from a sample "Friends" data set below. The example Turtle file loads data about people, including a person’s name, a list of their likes and dislikes, and their friends. In the file, the friend relationship is described as an owl:TransitiveProperty type (<friend> a owl:TransitiveProperty):

# friends.ttl
PREFIX owl: <http://www.w3.org/2002/07/owl#> .
<friend> a owl:TransitiveProperty .
<person1>
rdf:type <person>
;<name> "Rafael Taylor"
;<like> "sports","theatre","classical","vegas","musicals"
;<dislike> "jazz","broadway"
;<friend> <person2>,<person4>
.
<person2>
rdf:type <person>
;<name> "Vladimir Humphrey"
;<like> "jazz","classical","vegas","musicals"
;<dislike> "broadway"
;<friend> <person3>
.
<person3>
rdf:type <person>
;<name> "Lars Ratliff"
;<like> "sports","rock","musicals"
;<dislike> "theatre","jazz","opera"
;<friend> <person1>
.
<person4>
rdf:type <person>
;<name> "Barry Roy"
;<like> "theatre"
;<dislike> "sports","jazz","musicals"
;<friend> <person5>
.
<person5>
rdf:type <person>
;<name> "Reagan Hodge"
;<like> "concerts","rock","vegas","musicals"
;<dislike> "jazz","broadway"
;<friend> <person1>
.

Loading friends.ttl into a graph named friends and querying the new graph for a list of friendships produces the following results. The query returns 6 friendships:

SELECT *
FROM <friends>
WHERE { ?person <friend> ?friend . }
ORDER BY ?person
person  | friend
--------+---------
person1 | person4
person1 | person2
person2 | person3
person3 | person1
person4 | person5
person5 | person1
6 rows

The query below generates inferences for the friends graph based on the rules for owl:TransitiveProperty. The query creates the inferences in a graph named more-friends:

 CREATE INFERENCES FROM INTO GRAPH <friends> INTO GRAPH <more-friends>

When the inferencing is complete, the following query returns the friend triples in the more-friends graph. The query filters out triples for which the same person is the subject (?person) and object (?friend):

SELECT *
FROM <more-friends>
WHERE {
  ?person <friend> ?friend.
  FILTER(?person != ?friend).
}
ORDER BY ?person
person  | friend
--------+---------
person1 | person5
person1 | person3
person2 | person5
person2 | person4
person2 | person1
person3 | person5
person3 | person2
person3 | person4
person4 | person2
person4 | person3
person4 | person1
person5 | person2
person5 | person4
person5 | person3
14 rows

Following the OWL 2 TL rules for owl:TransitiveProperty, AnzoGraph inferred 8 new friendships from the 6 friendships in the original friend graph.

Let us know your thoughts in the comments.

Graph (Unix)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Host Hack Attempt Detection Using ELK
  • How To Best Use Java Records as DTOs in Spring Boot 3
  • Detecting Network Anomalies Using Apache Spark
  • 4 Best dApp Frameworks for First-Time Ethereum Developers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: