pycitydata.urbankg.kg¶
Module Contents¶
Classes¶
城市知识图谱 Urban knowledge graph |
Data¶
API¶
- pycitydata.urbankg.kg.__all__¶
[‘UrbanKG’]
- class pycitydata.urbankg.kg.UrbanKG(mongo_uri: str, mongo_db: str, mongo_entity_coll: str, mongo_relation_coll: str, cache_size: int = 100)¶
城市知识图谱 Urban knowledge graph
Initialization
Args:
mongo_uri: MongoDB URI
mongo_db: MongoDB数据库名。MongoDB database name.
mongo_entity_coll: MongoDB实体集合名。MongoDB entity collection name.
mongo_relation_coll: MongoDB关系集合名。MongoDB relation collection name.
cache_size: LRU缓存大小。LRU cache size.
- CLASSES¶
[‘Region’, ‘POI’, ‘Cate3’, ‘Brand’, ‘Ba’, ‘Cate2’, ‘Cate1’]
- RELATIONS¶
[‘SubCateOf_3to2’, ‘RelatedBrand’, ‘NearBy’, ‘LocateAt’, ‘LargeOD’, ‘Competitive_zhishi’, ‘CoCheckin…
- get_entity(id: str) Optional[dict]¶
查询实体 query entity
Args:
id: 实体ID。entity ID.
Returns:
Optional[dict]: 实体,为None表示不存在。Entity, None means it does not exist.
- query_object(subject_id: str, relation: str) List[str]¶
根据主体(subject)和关系(relation)查询客体(object) Query objects based on subject and relationship
Args:
subject_id: 主体ID。subject ID.
relation: 关系。relation.
Returns
List[str]: 客体ID列表
- query_subject(object_id: str, relation: str) List[str]¶
根据客体(object)和关系(relation)查询主体(subject) Query the subject based on the object and relationship
Args:
object_id: 客体ID。object ID.
relation: 关系。relation.
Returns
List[str]: 主体ID列表。List of subject IDs.
- explore(subject_id: str, relations: List[str]) List[Tuple[str, dict]]¶
根据主体(subject)和要探索的关系列表(relations)查询所有有关的客体(object) Query all related objects based on the subject and the list of relationships to be explored.
Args:
subject_id: 主体ID。subject ID.
relations: 要探索的关系列表。The list of relationships to be explored.
Returns:
List[Tuple[str, dict]]: 结果列表,Tuple第一项为关系,第二项为客体。Result list, the first item of Tuple is the relationship, the second item is the object.