'Update the corpus word counts given a loose array of word indices.
Can be called multiple times, but once `finalize` is called the word
counts cannot be updated.
Arguments
loose_array : int array
Array of word indices.
Examples
>>> corpus = Corpus()
>>> corpus.update_word_count(np.arange(10))
>>> corpus.update_word_count(np.arange(8))
>>> corpus.counts_loose[0]
2
>>> corpus.counts_loose[9]
1'

def update_word_count(self, loose_array):

    self._check_unfinalized()
    (uniques, counts) = np.unique(np.ravel(loose_array), return_counts=True)
    msg = 'Loose    arrays    cannot    have    elements    below    the    values    of    special    '
    msg += 'tokens    as    these    indices    are    reserved'
    assert (uniques.min() >= min(self.specials.values())), msg
    for (k, v) in zip(uniques, counts):
        self.counts_loose[k] += v
