本文整理匯總了Python中nltk.compat.iteritems方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.iteritems方法的具體用法?Python compat.iteritems怎麽用?Python compat.iteritems使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nltk.compat
的用法示例。
在下文中一共展示了compat.iteritems方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: Do_alpha
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import iteritems [as 別名]
def Do_alpha(self):
"""The observed disagreement for the alpha coefficient.
The alpha coefficient, unlike the other metrics, uses this rather than
observed agreement.
"""
total = 0.0
for i, itemdata in self._grouped_data('item'):
label_freqs = FreqDist(x['labels'] for x in itemdata)
for j, nj in iteritems(label_freqs):
for l, nl in iteritems(label_freqs):
total += float(nj * nl) * self.distance(l, j)
ret = (1.0 / (len(self.I) * len(self.C) * (len(self.C) - 1))) * total
log.debug("Observed disagreement: %f", ret)
return ret
示例2: Do_alpha
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import iteritems [as 別名]
def Do_alpha(self):
"""The observed disagreement for the alpha coefficient.
The alpha coefficient, unlike the other metrics, uses this rather than
observed agreement.
"""
total = 0.0
for i, itemdata in self._grouped_data('item'):
label_freqs = FreqDist(x['labels'] for x in itemdata)
for j, nj in iteritems(label_freqs):
for l, nl in iteritems(label_freqs):
total += float(nj * nl) * self.distance(l, j)
ret = (1.0 / float((len(self.I) * len(self.C) * (len(self.C) - 1)))) * total
log.debug("Observed disagreement: %f", ret)
return ret
示例3: pi
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import iteritems [as 別名]
def pi(self):
"""Scott 1955; here, multi-pi.
Equivalent to K from Siegel and Castellan (1988).
"""
total = 0.0
label_freqs = FreqDist(x['labels'] for x in self.data)
for k, f in iteritems(label_freqs):
total += f ** 2
Ae = total / ((len(self.I) * len(self.C)) ** 2)
return (self.avg_Ao() - Ae) / (1 - Ae)
示例4: _apply_filter
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import iteritems [as 別名]
def _apply_filter(self, fn=lambda ngram, freq: False):
"""Generic filter removes ngrams from the frequency distribution
if the function returns True when passed an ngram tuple.
"""
tmp_ngram = FreqDist()
for ngram, freq in iteritems(self.ngram_fd):
if not fn(ngram, freq):
tmp_ngram[ngram] = freq
self.ngram_fd = tmp_ngram
示例5: pi
# 需要導入模塊: from nltk import compat [as 別名]
# 或者: from nltk.compat import iteritems [as 別名]
def pi(self):
"""Scott 1955; here, multi-pi.
Equivalent to K from Siegel and Castellan (1988).
"""
total = 0.0
label_freqs = FreqDist(x['labels'] for x in self.data)
for k, f in iteritems(label_freqs):
total += f ** 2
Ae = total / float((len(self.I) * len(self.C)) ** 2)
return (self.avg_Ao() - Ae) / (1 - Ae)