Exemplo n.º 1
0
 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()
Exemplo n.º 2
0
 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]
Exemplo n.º 3
0
 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]
Exemplo n.º 4
0
    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  # 序列结束符
Exemplo n.º 5
0
    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             # 序列结束符
Exemplo n.º 6
0
    def __init__(self, samples=None):
        """
        Construct a new frequency distribution.  If ``samples`` is
        given, then the frequency distribution will be initialized
        with the count of each object in ``samples``; otherwise, it
        will be initialized to be empty.

        In particular, ``FreqDist()`` returns an empty frequency
        distribution; and ``FreqDist(samples)`` first creates an empty
        frequency distribution, and then calls ``update`` with the
        list ``samples``.

        :param samples: The samples to initialize the frequency
            distribution with.
        :type samples: Sequence
        """
        Counter.__init__(self, samples)

        # Cached number of samples in this FreqDist
        self._N = None
Exemplo n.º 7
0
 def __init__(self, unknown_cutoff, *counter_args):
     Counter.__init__(self, *counter_args)
     self.cutoff = unknown_cutoff
 def __init__(self, *args, **kw):
     Counter.__init__(self, *args, **kw)
     self.__changed = set()
Exemplo n.º 9
0
 def __init__(self, *args, **kwargs):
     defaultdict.__init__(self, int)
     Counter.__init__(self, *args, **kwargs)
     for k, v in list(self.items()):
         if not v:
             del self[k]
 def __init__(self, *args, **kwargs):
     AttrDict.__init__(self, *args, **kwargs)
     Counter.__init__(self)
     self.__exclude_keys__ |= {'most_common'}
Exemplo n.º 11
0
 def __init__(self, *args, **kwargs):
     """ A dictionary with sorted float values (by default, 0.0).
     """
     Counter.__init__(self, dict(*args, **kwargs))
 def __init__(self, word_list = []):
     self.word_list = word_list
     Counter.__init__(self, word_list)
Exemplo n.º 13
0
 def __init__(self, unknown_cutoff, *counter_args):
     if isinstance(unknown_cutoff, dict):
         Counter.__init__(self, unknown_cutoff, *counter_args)
     else:
         Counter.__init__(self, *counter_args)
         self.cutoff = unknown_cutoff
Exemplo n.º 14
0
 def __init__(self, iterable):
     self.__finishedinit = False
     Counter.__init__(self, iterable)
     self.__finishedinit = True
Exemplo n.º 15
0
 def __init__(self, *args, **kwargs):
     Counter.__init__(self, *args, **kwargs)
Exemplo n.º 16
0
 def __init__(self, dic):
     self._len = -1
     Counter.__init__(self, dic)
Exemplo n.º 17
0
 def __init__(self, factors={}):
     Counter.__init__(self, factors)
Exemplo n.º 18
0
 def __init__(self, *args, **kwargs):
     """ A dictionary with sorted float values (by default, 0.0).
     """
     Counter.__init__(self, dict(*args, **kwargs))
Exemplo n.º 19
0
 def __init__(self, word):
     Counter.__init__(self, word)
     self.word = word
Exemplo n.º 20
0
 def __init__(self, samples=None):
     Counter.__init__(self, samples)
Exemplo n.º 21
0
 def __init__(self, *args, **kwargs):
     Counter.__init__(self, *args, **kwargs)
 def __init__(self, sampleData=None): #Has sampleData being the
     Counter.__init__(self, sampleData) # Uses Counter class's instantiation
 def __init__(self, word_list=[]):
     self.word_list = word_list
     Counter.__init__(self, word_list)