當前位置: 首頁>>代碼示例>>Python>>正文


Python compat.iteritems方法代碼示例

本文整理匯總了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 
開發者ID:Thejas-1,項目名稱:Price-Comparator,代碼行數:18,代碼來源:agreement.py

示例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 
開發者ID:jarrellmark,項目名稱:neighborhood_mood_aws,代碼行數:18,代碼來源:agreement.py

示例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) 
開發者ID:Thejas-1,項目名稱:Price-Comparator,代碼行數:13,代碼來源:agreement.py

示例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 
開發者ID:Thejas-1,項目名稱:Price-Comparator,代碼行數:11,代碼來源:collocations.py

示例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) 
開發者ID:jarrellmark,項目名稱:neighborhood_mood_aws,代碼行數:13,代碼來源:agreement.py


注:本文中的nltk.compat.iteritems方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。