当前位置: 首页>>代码示例>>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;未经允许,请勿转载。