将多关系图的节点和边映射为整数
edgelist-mapper的Python项目详细描述
概要
edgelist mapper是一个简单的工具,它读取表示一个图的边列表文件,并将每个节点和关系映射到整数。 指定的映射是这样的,在图中出现更频繁的实体和关系被映射到更小的数值。在
这个工具对于预处理一些公共可用的知识图数据集特别有用,这些数据集通常用于relation prediction的机器学习任务。在
输入格式
该工具将一个文件(edgelist.tsv
)作为输入,该文件将图形表示为(head, relation, tail)
的三元组,并生成三个新文件,即mapped_edgelist.tsv
、entities_map.tsv
和{
san_marino locatedin europe
belgium locatedin europe
russia locatedin europe
monaco locatedin europe
croatia locatedin europe
poland locatedin europe
^{pr2}$Example content of the
edgelist.tsv
file.
Content of the
entities_map.tsv
generated from theedgelist.tsv
file.
0 locatedin
Content of the
relations_map.tsv
generated from theedgelist.tsv
file.
1 0 0
6 0 0
2 0 0
4 0 0
5 0 0
3 0 0
Content of the
mapped_edgelist.tsv
generated from theedgelist.tsv
file.
CLI使用
CLI采用以下位置参数:
edgelist Path of the edgelist file
output Path of the output directory
用法示例:
pip install edgelist-mapper python -m edgelist_mapper.bin.run \ edgelist.tsv \ .
NB: You need Python 3 to run the CLI.
展示
此工具已用于创建this collection of datasets。在
作者
- Simone Primarosa-simonepri
另请参阅参与本项目的contributors人员名单。在
许可证
这个项目是在麻省理工学院许可下授权的-有关详细信息,请参阅license文件。在
- 项目
标签: