Created
May 14, 2019 03:30
-
-
Save nooperpudd/e74b2c5ba40697897c39600bcf20cf1c to your computer and use it in GitHub Desktop.
graph database
This file contains hidden or 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
import os | |
import rdflib | |
from rdflib import Graph, Literal | |
from rdflib.namespace import RDFS, FOAF | |
PLACE = rdflib.Namespace("http://example.com/place/") | |
PATH = rdflib.Namespace("http://example.com/path/") | |
DEFAULT = rdflib.Namespace("http://www.example.com/default/") | |
graph = Graph() | |
graph.bind("foaf", FOAF) | |
graph.bind("rdfs", RDFS) | |
graph.bind("place", PLACE) | |
graph.bind("path", PATH) | |
country = PLACE["niga"] | |
sub_city = PLACE["xxxx"] | |
sub_city_2 = PLACE["BBBB"] | |
sub_word = PLACE["EEEEE"] | |
graph.add((country, PATH.city, sub_city)) | |
graph.add((country, PATH.city, sub_city_2)) | |
graph.add((country, RDFS.label, Literal("niga"))) | |
graph.add((sub_city, RDFS.label, Literal("xxxx"))) | |
graph.add((sub_city, PATH.wod, sub_word)) | |
graph.add((sub_city_2, RDFS.label, Literal("BBBB"))) | |
graph.add((sub_word, RDFS.label, Literal("EEEEE"))) | |
graph.serialize(os.path.join("city_test.ttl"), format='turtle') | |
# country = BNode() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment