def __extractKGEntities(self, json, filter=''): entities = list() for element in json['itemListElement']: types = set() for t in element['result']['@type']: if t != 'Thing': types.add("http://schema.org/"+t) description='' if 'description' in element['result']: description = element['result']['description'] kg_entity = KGEntity( element['result']['@id'], element['result']['name'], description, types, self.getKGName() ) #We filter according to givem URI if filter=='' or element['result']['@id']==filter: entities.append(kg_entity) #print(kg_entity) #for entity in entities: # print(entity) return entities
def __extractKGEntities(self, json, filter=''): entities = list() for element in json['search']: #empty list of type from wikidata lookup types = set() description='' if 'description' in element: description = element['description'] kg_entity = KGEntity( element['concepturi'], element['label'], description, types, self.getKGName() ) #We filter according to givem URI if filter=='' or element['concepturi']==filter: entities.append(kg_entity) #for entity in entities: # print(entity) return entities
def __extractKGEntities_OLD_LOOKUP(self, json, filter=''): entities = list() for element in json['results']: types = set() for t in element['classes']: if t['uri'] != 'http://www.w3.org/2002/07/owl#Thing': if t['uri'].startswith('http://dbpedia.org/ontology/') or t['uri'].startswith('http://www.wikidata.org/entity/') or t['uri'].startswith('http://schema.org/'): types.add(t['uri']) description='' if 'description' in element: description = element['description'] kg_entity = KGEntity( element['uri'], element['label'], description, types, self.getKGName() ) #We filter according to givem URI if filter=='' or element['uri']==filter: entities.append(kg_entity) #print(kg_entity) #for entity in entities: # print(entity) return entities
def __extractKGEntities(self, json, filter=''): entities = list() for element in json['docs']: types = set() #print(element) if 'type' in element: for t in element['type']: if t != 'http://www.w3.org/2002/07/owl#Thing': if t.startswith('http://dbpedia.org/ontology/') or t.startswith('http://www.wikidata.org/entity/') or t.startswith('http://schema.org/'): types.add(t) description='' if 'comment' in element: description = element['comment'] ##Expected only one uri='' if 'resource' in element: for u in element['resource']: uri=u ##Expected only one label='' if 'label' in element: for l in element['label']: label=l kg_entity = KGEntity( uri, label, description, types, self.getKGName() ) #We filter according to give URI if filter=='' or uri==filter: entities.append(kg_entity) #print(kg_entity) #for entity in entities: # print(entity) return entities