KGReader¶
- class pybind11_ke.data.KGReader(in_path: str = './', ent_file: str = 'entity2id.txt', rel_file: str = 'relation2id.txt', train_file: str = 'train2id.txt')[源代码]¶
从文件中读取知识图谱。
- __init__(in_path: str = './', ent_file: str = 'entity2id.txt', rel_file: str = 'relation2id.txt', train_file: str = 'train2id.txt')[源代码]¶
创建 KGReader 对象。
- __weakref__¶
list of weak references to the object (if defined)
- get_hr2t_rt2h_from_train()[源代码]¶
获得
hr2t_train和rt2h_train。
- get_hr_train()[源代码]¶
用于
CompGCN[VSNT20] 训练,因为CompGCN[VSNT20] 的组合运算仅需要头实体和关系。如果想获得更详细的信息请访问 CompGCN。
- get_train_triples_id()[源代码]¶
读取
train_file文件。
- hr2t_train: defaultdict[set]¶
训练集中所有 h-r 对对应的 t 集合
- rt2h_train: defaultdict[set]¶
训练集中所有 r-t 对对应的 h 集合