-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #160 from TheRazorace/main
Morph-KGC in-memory extension
- Loading branch information
Showing
219 changed files
with
6,575 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[DataSource] | ||
mappings=./mapping_rml.ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
__author__ = "Ioannis Dasoulas" | ||
__credits__ = ["Julián Arenas-Guerrero","Ioannis Dasoulas"] | ||
|
||
__license__ = "Apache-2.0" | ||
__maintainer__ = "Ioannis Dasoulas" | ||
__email__ = "ioannis.dasoulas@kuleuven.be" | ||
|
||
import morph_kgc | ||
import pandas as pd | ||
|
||
users_df = pd.DataFrame({'Id': [1,2,3,4],\ | ||
'Username': ["@jude","@emily","@wayne","@jordan1"], \ | ||
'Name': ["Jude", "Emily", "Wayne", "Jordan"],\ | ||
'Surname': ["White", "Van de Beeck", "Peterson", "Stones"]}) | ||
|
||
followers_df = pd.DataFrame({'Id': [1,2,3,4],\ | ||
'Followers': [344, 456, 1221, 23]}) | ||
|
||
data_dict = {"variable1": users_df, | ||
"variable2": followers_df} | ||
|
||
g_rdflib = morph_kgc.materialize('./config.ini', data_dict) | ||
|
||
print("Knowledge graphs triples:") | ||
for s,p,o in g_rdflib.triples((None, None, None)): | ||
print(s,p,o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
@prefix insta: <http://instagram.com/data/>. | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@base <http://example.com/ns#>. | ||
@prefix schema: <http://schema.org/>. | ||
@prefix sd: <https://w3id.org/okn/o/sd/>. | ||
@prefix kg4di: <https://w3id.org/kg4di/definedBy>. | ||
|
||
|
||
<people_0> a rr:TriplesMap; | ||
|
||
rml:logicalSource [ | ||
a rml:LogicalSource; | ||
rml:source [ | ||
a sd:DatasetSpecification; | ||
sd:name "variable1"; | ||
sd:hasDataTransformation [ | ||
sd:hasSoftwareRequirements "pandas>=1.1.0"; | ||
sd:hasSourceCode [ | ||
sd:programmingLanguage "Python3.9"; | ||
]; | ||
]; | ||
]; | ||
rml:referenceFormulation ql:DataFrame; | ||
]; | ||
rr:subjectMap [ | ||
a rr:SubjectMap; | ||
rr:template "http://instagram.com/data/user{Id}"; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant rdf:type; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:constant insta:User; | ||
]; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:username; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rml:reference "Username"; | ||
]; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:name; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:template "{Name} {Surname}"; | ||
rr:datatype rdfs:Literal | ||
]; | ||
]. | ||
|
||
|
||
<followers_0> a rr:TriplesMap; | ||
|
||
rml:logicalSource [ | ||
a rml:LogicalSource; | ||
rml:source [ | ||
a sd:DatasetSpecification; | ||
sd:name "variable2"; | ||
sd:hasDataTransformation [ | ||
sd:hasSoftwareRequirements "pandas>=1.1.0"; | ||
sd:hasSourceCode [ | ||
sd:programmingLanguage "Python3.9"; | ||
]; | ||
]; | ||
]; | ||
rml:referenceFormulation ql:DataFrame; | ||
]; | ||
rr:subjectMap [ | ||
a rr:SubjectMap; | ||
rr:template "http://instagram.com/data/user{Id}"; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:followersNumber; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rml:reference "Followers"; | ||
]; | ||
]. | ||
|
||
ql:DataFrame a rml:ReferenceFormulation; | ||
kg4di:definedBy "Pandas". | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[DataSource] | ||
mappings=./mapping_rml.ttl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
__author__ = "Ioannis Dasoulas" | ||
__credits__ = ["Julián Arenas-Guerrero","Ioannis Dasoulas"] | ||
|
||
__license__ = "Apache-2.0" | ||
__maintainer__ = "Ioannis Dasoulas" | ||
__email__ = "ioannis.dasoulas@kuleuven.be" | ||
|
||
import morph_kgc | ||
|
||
users_dict = {"users": [ | ||
{ | ||
"id": 1, | ||
"username": "@jude", | ||
"name": "Jude", | ||
"surname": "White" | ||
}, | ||
{ | ||
"id": 2, | ||
"username": "@emily", | ||
"name": "Emily", | ||
"surname": "Van de Beeck" | ||
}, | ||
{ | ||
"id": 3, | ||
"username": "@wayne", | ||
"name": "Wayne", | ||
"surname": "Peterson" | ||
}, | ||
{ | ||
"id": 4, | ||
"username": "@jordan1", | ||
"name": "Jordan", | ||
"surname": "Stones" | ||
} | ||
]} | ||
|
||
|
||
followers_dict = {"followers": [ | ||
{ | ||
"id": 1, | ||
"follows": [2,3], | ||
"followed_by": 2 | ||
}, | ||
{ | ||
"id": 2, | ||
"follows": [3,5], | ||
"followed_by": [1,3,4,5] | ||
}, | ||
{ | ||
"id": 3, | ||
"follows": [1,2], | ||
"followed_by": 1 | ||
}, | ||
{ | ||
"id": 4, | ||
"follows": [1,2,3], | ||
"followed_by": [2,3] | ||
} | ||
]} | ||
|
||
data_dict = {"variable1": users_dict, | ||
"variable2": followers_dict} | ||
|
||
g_rdflib = morph_kgc.materialize('./config.ini', data_dict) | ||
|
||
print("Knowledge graphs triples:") | ||
for s,p,o in g_rdflib.triples((None, None, None)): | ||
print(s,p,o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
@prefix insta: <http://instagram.com/data/>. | ||
@prefix rr: <http://www.w3.org/ns/r2rml#>. | ||
@prefix rml: <http://semweb.mmlab.be/ns/rml#>. | ||
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>. | ||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>. | ||
@prefix xsd: <http://www.w3.org/2001/XMLSchema#>. | ||
@prefix ql: <http://semweb.mmlab.be/ns/ql#>. | ||
@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#>. | ||
@prefix foaf: <http://xmlns.com/foaf/0.1/>. | ||
@base <http://example.com/ns#>. | ||
@prefix schema: <http://schema.org/>. | ||
@prefix sd: <https://w3id.org/okn/o/sd/>. | ||
@prefix kg4di: <https://w3id.org/kg4di/definedBy>. | ||
|
||
|
||
<people_0> a rr:TriplesMap; | ||
|
||
rml:logicalSource [ | ||
a rml:LogicalSource; | ||
rml:source [ | ||
a sd:DatasetSpecification; | ||
sd:name "variable1"; | ||
sd:hasDataTransformation [ | ||
sd:hasSourceCode [ | ||
sd:programmingLanguage "Python3.9"; | ||
]; | ||
]; | ||
]; | ||
rml:referenceFormulation ql:Dictionary; | ||
rml:iterator "$.users[*]"; | ||
]; | ||
rr:subjectMap [ | ||
a rr:SubjectMap; | ||
rr:template "http://instagram.com/data/user{id}"; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant rdf:type; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:constant insta:User; | ||
]; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:username; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rml:reference "username"; | ||
]; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:name; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:template "{name} {surname}"; | ||
rr:datatype rdfs:Literal | ||
]; | ||
]. | ||
|
||
|
||
<followers_0> a rr:TriplesMap; | ||
|
||
rml:logicalSource [ | ||
a rml:LogicalSource; | ||
rml:source [ | ||
a sd:DatasetSpecification; | ||
sd:name "variable2"; | ||
sd:hasDataTransformation [ | ||
sd:hasSourceCode [ | ||
sd:programmingLanguage "Python3.9"; | ||
]; | ||
]; | ||
]; | ||
rml:referenceFormulation ql:Dictionary; | ||
rml:iterator "$.followers[*]"; | ||
]; | ||
rr:subjectMap [ | ||
a rr:SubjectMap; | ||
rr:template "http://instagram.com/data/user{id}"; | ||
]; | ||
rr:predicateObjectMap [ | ||
rr:predicateMap [ | ||
a rr:PredicateMap; | ||
rr:constant insta:follows; | ||
]; | ||
rr:objectMap [ | ||
a rr:ObjectMap; | ||
rr:template "http://instagram.com/data/user{follows}"; | ||
rr:termType rr:IRI | ||
]; | ||
]. | ||
|
||
ql:Dictionary a rml:ReferenceFormulation; | ||
kg4di:definedBy "Python". | ||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.