Tuesday, June 26, 2018

Training and Test Data for Knowledge Graph Completion


Positive Examples:

Positive examples for predicate P are any entity pairs (x,y) in DBpedia such that (x,P,y) is in it. For example, the positive example for the spouse relation are the people who are married to each other. And, the type of entities for both x and y are Person type.

The example SPARQL query to generate the positive examples for spouse relation is given below:

PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT DISTINCT ?subject ?object
FROM <http://dbpedia.org>
WHERE { ?object rdf:type dbpedia-owl:Person.
?subject rdf:type dbpedia-owl:Person. 
?subject ?targetRelation ?object.  
FILTER (?targetRelation = dbpedia-owl:spouse)
} ORDER BY RAND() LIMIT 10000