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


Python Counter.__init__方法代碼示例

本文整理匯總了Python中collections.Counter.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python Counter.__init__方法的具體用法?Python Counter.__init__怎麽用?Python Counter.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在collections.Counter的用法示例。


在下文中一共展示了Counter.__init__方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, _dict=None, **kwargs):
     if _dict is None:
         self.__init__(kwargs)
     else:
         if not all(isinstance(x, Rational) for x in _dict.values()):
             raise TypeError("powers of dimensions must be rational")
         Counter.__init__(self, _dict)
         self.clean()
開發者ID:speezepearson,項目名稱:units,代碼行數:10,代碼來源:dimensions.py

示例2: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, n, *args, **kwargs):
     assert n>=1
     self._size = n
     self._worst = None
     Counter.__init__(self, *args, **kwargs)
     if len(self)>=n:
         self._worst = self.most_common(n)[-1]
         for k,v in self.most_common()[n:]:
             del self[k]
開發者ID:chenguandan,項目名稱:pysupersensetagger,代碼行數:11,代碼來源:beam.py

示例3: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
    def __init__(self, max_len, N_max = 5):
        '''
        @summary: NGramSet Constructor

        @param max_len: 最優序列長度
        @param N_max: CCS2012 對應最大n-gram

        '''
        Counter.__init__(self)
        
        self.N_max = N_max
        self.max_len = max_len
        
        self.alphabet_size = 0    # 記錄項總數
        self.all_record_num = 0   # 記錄數據集中記錄總數
        self.TERM = 0             # 序列結束符
開發者ID:luguoqing,項目名稱:Diff-FSPM,代碼行數:18,代碼來源:NGramSet.py

示例4: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, *args, **kwargs):
     Counter.__init__(self, *args, **kwargs)
開發者ID:rodricios,項目名稱:wikicrawl,代碼行數:4,代碼來源:containers.py

示例5: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, *args, **kwargs):
     AttrDict.__init__(self, *args, **kwargs)
     Counter.__init__(self)
     self.__exclude_keys__ |= {'most_common'}
開發者ID:pratapvardhan,項目名稱:orderedattrdict,代碼行數:6,代碼來源:test_orderedattrdict.py

示例6: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, word_list = []):
     self.word_list = word_list
     Counter.__init__(self, word_list)
開發者ID:xiaohan2012,項目名稱:Chinese-Ingredient-Network-Analysis,代碼行數:5,代碼來源:word_freq.py

示例7: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, iterable):
     self.__finishedinit = False
     Counter.__init__(self, iterable)
     self.__finishedinit = True
開發者ID:hroskes,項目名稱:randomlhestuff,代碼行數:6,代碼來源:frozencounter.py

示例8: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, sampleData=None): #Has sampleData being the
     Counter.__init__(self, sampleData) # Uses Counter class's instantiation
開發者ID:nathanso,項目名稱:Computer_Science_Project,代碼行數:4,代碼來源:Naive+Bayes.py

示例9: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, factors={}):
     Counter.__init__(self, factors)
開發者ID:phincallahan,項目名稱:project-euler,代碼行數:4,代碼來源:factorization.py

示例10: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, samples=None):
     Counter.__init__(self, samples)
開發者ID:nathanso,項目名稱:Computer_Science_Project,代碼行數:4,代碼來源:POS+1.py

示例11: __init__

# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
 def __init__(self, *args, **kwargs):
     """ A dictionary with sorted float values (by default, 0.0).
     """
     Counter.__init__(self, dict(*args, **kwargs))
開發者ID:markus-beuckelmann,項目名稱:pattern,代碼行數:6,代碼來源:metrics.py


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