예제 #1
0
 def setUp(self):
     register('json-ld', Parser, 'rdflib_jsonld.parser', 'JsonLDParser')
     # self.graph = Graph()
     #self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3.json'
     self.proj_context_uri = '/127.0.0.1:8000/contexts/projects/3.json'
     self.context_file = settings.STATIC_IMPORTS_ROOT + '3-context.json'
     self.data_file = settings.STATIC_IMPORTS_ROOT + 'dt-bone.json'
     self.context_str = self.request_json_str(self.proj_context_uri)
     self.data_str = self.load_json_file_str(self.data_file)
     g_context = ConjunctiveGraph(identifier=self.proj_context_uri)
     g_context.parse(data=self.context_str, format='json-ld')
     proj_graph_obj = URIRef(self.proj_context_uri)
     print('N3: ' + str(g_context.__str__()))
     for c in g_context.contexts():
         print(str(c))
     print('-------Triples for context-graph------')
     self.test_type_linking(g_context)
     g_data = ConjunctiveGraph().parse(data=self.data_str, format='json-ld')
     print('-------Triples for data-record--------')
     self.test_type_linking(g_data)
예제 #2
0
 def setUp(self):
     register('json-ld',
              Parser,
              'rdflib_jsonld.parser',
              'JsonLDParser')
     # self.graph = Graph()
     self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3.json'
     self.context_file = settings.STATIC_IMPORTS_ROOT + '3-context.json'
     self.data_file = settings.STATIC_IMPORTS_ROOT + 'dt-bone.json'
     self.context_str = self.request_json_str(self.proj_context_uri)
     self.data_str = self.load_json_file_str(self.data_file)
     g_context = ConjunctiveGraph(identifier=self.proj_context_uri)
     g_context.parse(data=self.context_str, format='json-ld')
     proj_graph_obj = URIRef(self.proj_context_uri)
     print('N3: ' + str(g_context.__str__()))
     for c in g_context.contexts():
         print(str(c))
     print('-------Triples for context-graph------')
     self.test_type_linking(g_context)
     g_data = ConjunctiveGraph().parse(data=self.data_str, format='json-ld')
     print('-------Triples for data-record--------')
     self.test_type_linking(g_data)
예제 #3
0
 def setUp(self):
     register('json-ld', Parser, 'rdflib_jsonld.parser', 'JsonLDParser')
     # self.graph = Graph()
     # self.proj_context_uri = 'http://127.0.0.1:8000/contexts/projects/3FAAA477-5572-4B05-8DC1-CA264FE1FC10.json'
     self.proj_context_uri = '/contexts/projects/3FAAA477-5572-4B05-8DC1-CA264FE1FC10.json'
     self.context_file = settings.STATIC_IMPORTS_ROOT + '3-context.json'
     self.data_file = settings.STATIC_IMPORTS_ROOT + 'dt-bone.json'
     #self.context_str = self.request_json_str(self.proj_context_uri)
     client = Client()
     response = client.get(self.proj_context_uri, follow=True)
     assert response.status_code in [200, 301]
     self.context_str = response.content
     self.data_str = self.load_json_file_str(self.data_file)
     g_context = ConjunctiveGraph(identifier=self.proj_context_uri)
     g_context.parse(data=self.context_str, format='json-ld')
     proj_graph_obj = URIRef(self.proj_context_uri)
     print('N3: ' + str(g_context.__str__()))
     for c in g_context.contexts():
         print(str(c))
     print('-------Triples for context-graph------')
     self.test_type_linking(g_context)
     g_data = ConjunctiveGraph().parse(data=self.data_str, format='json-ld')
     print('-------Triples for data-record--------')
     self.test_type_linking(g_data)