本文整理汇总了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))