RevSampler¶
- class pybind11_ke.data.RevSampler(in_path: str = './', ent_file: str = 'entity2id.txt', rel_file: str = 'relation2id.txt', train_file: str = 'train2id.txt')[源代码]¶
在训练集中增加相反关系.
对于每一个三元组 (h, r, t),生成相反关系三元组 (t, r`, h): r` = r + rel_tol。
- __init__(in_path: str = './', ent_file: str = 'entity2id.txt', rel_file: str = 'relation2id.txt', train_file: str = 'train2id.txt')[源代码]¶
创建 RevSampler 对象。
- __weakref__¶
list of weak references to the object (if defined)
- get_hr2t_rt2h_from_train()¶
获得
hr2t_train和rt2h_train。
- get_train_triples_id()¶
读取
train_file文件。
- hr2t_train: collections.defaultdict[set]¶
训练集中所有 h-r 对对应的 t 集合
- rt2h_train: collections.defaultdict[set]¶
训练集中所有 r-t 对对应的 h 集合