本文整理匯總了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()
示例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]
示例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 # 序列結束符
示例4: __init__
# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
def __init__(self, *args, **kwargs):
Counter.__init__(self, *args, **kwargs)
示例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'}
示例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)
示例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
示例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
示例9: __init__
# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
def __init__(self, factors={}):
Counter.__init__(self, factors)
示例10: __init__
# 需要導入模塊: from collections import Counter [as 別名]
# 或者: from collections.Counter import __init__ [as 別名]
def __init__(self, samples=None):
Counter.__init__(self, samples)
示例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))