如何使用添加带日期的列语料库.sli

2024-09-27 19:27:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我真的是一个编程新手,这就是为什么我的问题可能会很无聊或愚蠢,抱歉!我正在尝试用Gephi(graphml格式)构建合著关系图。一切都很好,但我不明白,如何导入同一个文件中的日期。我的代码如下:

from tethne.readers import wos
MyCorpus = wos.corpus_from_dir(datapath)
from tethne.networks import authors
ca_graph = authors.coauthors(MyCorpus.all_papers())
from tethne.writers import graph
graph.to_graphml(ca_graph, './file.graphml')`

所以,在这个文件.graphml我有作者机构,但我没有任何(这部作品出版时)。我找到了一段代码here

MyCorpus.slice('date', 'time_period', window_size=1, cumulative=True)

但我不知道,怎么把所有的东西都写在一个文件里。我将感谢所有的帮助!你知道吗


Tags: 文件代码fromimport格式编程authorsca
1条回答
网友
1楼 · 发布于 2024-09-27 19:27:44

由于tethne.writers.graph使用networkx图形,您的问题归结为writing attributes to networkx nodes

你可以尝试以下方法:

for author, attribs in ca_graph:
    # somehow calculate a year_value
    ca_graph.node[author]['year'] = year_value

相关问题 更多 >

    热门问题