Пример #1
0
def get_profile(uri):
    types = types_for_uri(uri)

    if 'http://dbpedia.org/ontology/Company' in types:
        profile = get_company_profile(uri)
        profile['type'] = 'company'
        return profile
    elif 'http://dbpedia.org/ontology/Place' in types:
        profile = get_place_profile(uri, types)
        profile['type'] = 'place'
        return profile
    else:
        return {}
Пример #2
0
def get_profile(uri):
    types = types_for_uri(uri)

    if 'http://dbpedia.org/ontology/Company' in types:
        profile = get_company_profile(uri)
        profile['type'] = 'company'
        return profile
    elif 'http://dbpedia.org/ontology/Place' in types:
        profile = get_place_profile(uri, types)
        profile['type'] = 'place'
        return profile
    else:
        return {}
Пример #3
0
 def test_types_for_uri(self):
     self.mock_resp.read.return_value = b'''
         {
           "head": {
             "vars": [ "type" ]
           } ,
           "results": {
             "bindings": [
               {
                 "type": { "type": "uri" , "value": "http://schema.org/Organization" }
               } ,
               {
                 "type": { "type": "uri" , "value": "http://dbpedia.org/ontology/Company" }
               }
             ]
           }
         }
     '''
     types = knowledge.types_for_uri('http://dbpedia.org/resource/Google')
     self.assertEqual(types, ['http://schema.org/Organization', 'http://dbpedia.org/ontology/Company'])
Пример #4
0
 def test_types_for_uri(self):
     self.mock_resp.read.return_value = b'''
         {
           "head": {
             "vars": [ "type" ]
           } ,
           "results": {
             "bindings": [
               {
                 "type": { "type": "uri" , "value": "http://schema.org/Organization" }
               } ,
               {
                 "type": { "type": "uri" , "value": "http://dbpedia.org/ontology/Company" }
               }
             ]
           }
         }
     '''
     types = knowledge.types_for_uri('http://dbpedia.org/resource/Google')
     self.assertEqual(types, [
         'http://schema.org/Organization',
         'http://dbpedia.org/ontology/Company'
     ])