Skip to content

Triple pattern matching over non-RDF datasources with inference

License

Notifications You must be signed in to change notification settings

benj-moreau/odmtp-tpf

Repository files navigation

ODMTP TPF Server

odmtp-tpf is a Triple Pattern Fragment server using Python, Django and ODMTP.

ODMTP (On Demand Mapper with Triple pattern matching) enables triple pattern matching over non-RDF datasources.

ODMTP support inference (see Semantic Reasoner (Inference) section)

Online demo

ODMTP's implemented for Twitter API, Github API and Linkedin API are available online. You can run SPARQL queries using the online TPF client demo: Here for Twitter, Here for Github (limited to 60 request per hour) and Here for your Linkedin profile (you will need to login to access your personal LI profile).

ODMTP approach is already used on OpenDataSoft Plateform and can be tested Here.

Instructions

Installation

macOS

You need to install Homebrew.

and then install Python 2.7:

brew install python

Ubuntu

sudo apt-get install python-dev python-setuptools

Dependencies

You need to install dependencies with pip:

pip install -r requirements.txt

Running The Platform

macOS & Ubuntu

From ~/odmtp-tpf run the comand:

python manage.py runserver

The TPF server should run at: http://127.0.0.1:8000/

Semantic Reasoner (Inference)

RDF data contains explicit and implicit triples that can be inferred using rules described in ontologies. To support inference, ODMTP use ontologies to materialize implicit triples of mappings (extended mappings). Each API can be queried using extended mappings at: http://127.0.0.1:8000/{api}/extended Example: http://127.0.0.1:8000/twitter/extended

However, mappings only contains schema of the corresponding RDF dataset. Thus, rules that apply on RDF instances cannot be applied on mappings.

Supported rules

All rules that apply to schema (class and properties) are supported by ODMTP Semantic Reasoner.

Implemented rules

Rule Name if dataset contains ... ... then add
rdfs2 (domain) aaa rdfs:domain xxx .
uuu aaa yyy .
uuu rdf:type xxx .
rdfs3 (range) aaa rdfs:range xxx .
uuu aaa vvv .
vvv rdf:type xxx .
rdfs5 (subProperty transitivity) uuu rdfs:subPropertyOf vvv .
vvv rdfs:subPropertyOf xxx .
uuu rdfs:subPropertyOf xxx .
rdfs7 (subProperty) aaa rdfs:subPropertyOf bbb .
uuu aaa yyy .
uuu bbb yyy .
rdfs9 (subClassOf) uuu rdfs:subClassOf xxx .
vvv rdf:type uuu .
vvv rdf:type xxx .
rdfs11 (subClassOf transitivity) uuu rdfs:subClassOf vvv .
vvv rdfs:subClassOf xxx .
uuu rdfs:subClassOf xxx .
owl sameAs Class uuu owl:sameAs xxx .
vvv rdf:type uuu .
vvv rdf:type xxx .
owl sameAs Property aaa owl:sameAs bbb .
uuu aaa yyy .
uuu bbb yyy .
owl equivalentClass uuu owl:equivalentClass xxx .
vvv rdf:type uuu .
vvv rdf:type xxx .
owl equivalentProperty aaa owl:equivalentProperty bbb .
uuu aaa yyy .
uuu bbb yyy .

Not implemented rules

Not all supported rules are yet implemented. Complete list of RDFS and OWL-LD rules.

Not supported rules

Rules that applies on instances are not supported by ODMTP Semantic Reasoner. examples:

Rule Name if data contains ... ... then add Comment
owl-ld eq-rep-subject subj1 owl:sameAs subj2 .
subj1 aaa obj1 .
subj2 aaa obj1 . Not supported if one of the two subject
is not defined in ontology or mapping
owl-ld eq-rep-object obj1 owl:sameAs obj2 .
subj1 aaa obj1 .
subj1 aaa obj2 . Not supported if subject or objects are
not defined in ontology or mapping

Mappings

Mappings are accessible at: http://127.0.0.1:8000/{api}/mapping Example: http://127.0.0.1:8000/twitter/mapping

Extended mapping are accessible at http://127.0.0.1:8000/{api}/mapping/extended Example: http://127.0.0.1:8000/twitter/mapping/extended

Examples of Simple Queries

You can use any Triple Pattern Fragment client: http://linkeddatafragments.org/software/ to run SPARQL queries over twitter API and github Repo API V3

SPARQL queries over Twitter API

You can run this SPARQL query over http://127.0.0.1:8000/twitter/ to retrieve tweets using #iswc2017 hashtag.

PREFIX it: <http://www.influencetracker.com/ontology#>

SELECT ?s WHERE {
 ?s it:includedHashtag "SemanticWeb".
}

Retrieve tweets from a specific user.

PREFIX schema: <http://schema.org/>

SELECT ?s WHERE {
 ?s schema:author "NantesTech".
}

SPO query to browse tweets

SELECT ?s ?p ?o WHERE {
 ?s ?p ?o
}

To retrieve a specific tweet by ID

SELECT ?p ?o WHERE {
 <https://twitter.com/statuses/889775221452005377> ?p ?o
}

SPARQL queries over Github API

You can run this SPARQL query over http://127.0.0.1:8000/github/ to retrieve repositories using Java programming language.

PREFIX schema: <http://schema.org/>

SELECT ?repo
WHERE {
?repo schema:language "Java"
}

SPO query to browse repositories

SELECT ?s ?p ?o WHERE {
 ?s ?p ?o
}

Extras

To understand how ODTMP approach is working, the ISWC 2017 poster is available here.

This is just a prototype, feel free to optimize it, improve mapping files, work on new api's etc.

About

Triple pattern matching over non-RDF datasources with inference

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages