【发布时间】:2019-10-29 21:56:59
【问题描述】:
我觉得我有一个愚蠢的问题,但不管怎样…… 我正在尝试从看起来像这样的数据:
a word form lemma POS count of occurrance
same word form lemma Not the same POS another count
same word form lemma Yet another POS another count
到如下所示的结果:
the word form total count all possible POS and their individual counts
所以例如我可以:
ring total count = 100 noun = 40, verb = 60
我的数据保存在 CSV 文件中。我想做这样的事情:
for row in all_rows:
if row[0] is the same as row[0] in the next row, add the values from row[3] together to get the total count
buuut 我似乎不知道该怎么做。帮助?
【问题讨论】:
-
你不是说
if column[0] is the same as column[0] in next row...吗? -
嗯。我的想法是逐行进行,因为我的数据中有多个单词,并且我希望保持看起来相同但具有不同 POS 标签的单词形式的总数(敲钟,戴戒指)。因此,如果第 1 行的第 0 个元素(即单词形式)与第 2 行的第 0 个元素相同,则将来自这些行的第 3 个元素的值相加得到单词的总数形式。
-
.. 是的,从技术上讲是专栏。
-
你是对的,实际上 row[0] 是一列,所以我不知道我为什么问这个问题,但最初我很困惑。谢谢
标签: python python-3.x nlp linguistics