construct_type_constrain¶
- unike.utils.construct_type_constrain(in_path: str = './', train_file: str = 'train2id.txt', valid_file: str = 'valid2id.txt', test_file: str = 'test2id.txt')[源代码]¶
构建 type_constrain.txt 文件
type_constrain.txt: 类型约束文件, 第一行是关系的个数
下面的行是每个关系的类型限制 (训练集、验证集、测试集中每个关系存在的 head 和 tail 的类型)
每个关系有两行:
第一行:rel_id heads_num head1 head2 …
第二行: rel_id tails_num tail1 tail2 …
如 benchmarks/FB15K 的 id 为 1200 的关系,它有 4 种类型头实体(3123,1034,58 和 5733)和 4 种类型的尾实体(12123,4388,11087 和 11088)。
1200 4 3123 1034 58 5733
1200 4 12123 4388 11087 11088
- 参数:
in_path (str) – 数据集目录
train_file (str) – train2id.txt
valid_file (str) – valid2id.txt
test_file (str) – test2id.txt