Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/google-sheets/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Nltk.most_common(),它的返回顺序是什么?_Nltk_N Gram_Frequency Analysis_Human Language - Fatal编程技术网

Nltk.most_common(),它的返回顺序是什么?

Nltk.most_common(),它的返回顺序是什么?,nltk,n-gram,frequency-analysis,human-language,Nltk,N Gram,Frequency Analysis,Human Language,我在某些句子中发现了bigrams的频率: import nltk from nltk import ngrams mydata = “xxxxx" mylist = mydata.split() mybigrams =list(ngrams(mylist, 2)) fd = nltk.FreqDist(mybigrams) print(fd.most_common()) 打印出最常见频率的双随机图时,一个出现7次,而所有95个其他双随机图只出现1次。然而,当把这些双字图和我的句子进行比较时

我在某些句子中发现了bigrams的频率:

import nltk 
from nltk import ngrams
mydata = “xxxxx"
mylist = mydata.split()
mybigrams =list(ngrams(mylist, 2))
fd = nltk.FreqDist(mybigrams)
print(fd.most_common())
打印出最常见频率的双随机图时,一个出现7次,而所有95个其他双随机图只出现1次。然而,当把这些双字图和我的句子进行比较时,我看不出频率为1的双字图打印出来的方式有什么逻辑顺序。有人知道这条路是否有逻辑吗?most_common()是打印bigram还是随机生成的


提前感谢

基于以下文件的简短回答:

计数相等的元素可以任意排序:

在NLTK的当前版本中,
NLTK.FreqDist
基于
NLTK.compat.Counter
。在Python2.7和3.x上,将从标准库导入
collections.Counter
。在Python2.6上,NLTK提供了自己的实现

有关详细信息,请查看源代码:


总之,如果不检查所有可能的版本配置,您就不能期望订购频率相同的单词。

简短回答,基于以下文档:

计数相等的元素可以任意排序:

在NLTK的当前版本中,
NLTK.FreqDist
基于
NLTK.compat.Counter
。在Python2.7和3.x上,将从标准库导入
collections.Counter
。在Python2.6上,NLTK提供了自己的实现

有关详细信息,请查看源代码:

总之,如果不检查所有可能的版本配置,就不能期望订购频率相同的单词