Returns all documents related to the specified term in the
        form of a Counter object.
960494
def get_documents(self, term):
        
        if term not in self._terms:
            raise IndexError(TERM_DOES_NOT_EXIST)
        else:
            return self._terms[term]
285860
def get_docs(self, vocab):
        """"""
        for string in self.strings:
            vocab[string]
        orth_col = self.attrs.index(ORTH)
        for tokens, spaces in zip(self.tokens, self.spaces):
            words = [vocab.strings[orth] for orth in tokens[:, orth_col]]
            doc = Doc(vocab, words=words, spaces=spaces)
            doc = doc.from_array(self.attrs, tokens)
            yield doc
915170
def count_by(records: Sequence[Dict], field_name: str) -> defaultdict:
    

    counter = defaultdict(int)

    for record in records:
        name = record[field_name]
        counter[name] += 1

    return counter
88454
def _get_ngram_counter(ids, n):
  
  # Remove zero IDs used to pad the sequence.
  ids = [token_id for token_id in ids if token_id != 0]
  ngram_list = [tuple(ids[i:i + n]) for i in range(len(ids) + 1 - n)]
  ngrams = set(ngram_list)
  counts = collections.Counter()
  for ngram in ngrams:
    counts[ngram] = 1
  return counts
618589
def count(cls, filter=None, **kwargs):
        """"""
        from mongoframes.queries import Condition, Group, to_refs

        if isinstance(filter, (Condition, Group)):
            filter = filter.to_dict()

        return cls.get_collection().count(to_refs(filter), **kwargs)
303159
def vocab_freq(docs, limit=1e6, verbose=1, tokenizer=generate_tokens):
    
    total = Counter()
    try:
        limit = min(limit, docs.count())
        docs = docs.iterator()
    except:
        pass
    for i, doc in enumerate(docs):
        try:
            doc = doc.values()
        except AttributeError:
            if not isinstance(doc, basestring):
                doc = ' '.join([stringify(v) for v in doc])
            else:
                doc = stringify(doc)
        if i >= limit:
            break
        c = Counter(tokenizer(doc, strip=True, nonwords=False))
        if verbose and (verbose < 1e-3 or not i % int(limit * verbose)):
            print('{}: {} ... {}'.format(i, c.keys()[:3], c.keys()[-3:] if len(c.keys()) > 6 else ''))
        total += c
    return total
1365748
def counter(items):
    
    results = {}
    for item in items:
        results[item] = results.get(item, 0) + 1
    return results
982222
def get_feats(self, doc):
		'''
		
		'''
		ngram_counter = Counter()
		for sent in doc.sents:
			ngrams = self.phrases[str(sent)]
			for subphrases in self.phrases[1:]:
				ngrams = subphrases[str(sent)]
			for ngram in ngrams:
				ngram_counter[ngram] += 1
		return ngram_counter
899787
def rank(words: List[str], exclude_stopwords: bool = False) -> Counter:
    
    if not words:
        return None

    if exclude_stopwords:
        words = [word for word in words if word not in _STOPWORDS]

    return Counter(words)
325762
public static <TERM> Map<TERM, Double> idf(Iterable<Iterable<TERM>> documentVocabularies,
                                               boolean smooth, boolean addOne)
    {
        Map<TERM, Integer> df = new HashMap<TERM, Integer>();
        int d = smooth ? 1 : 0;
        int a = addOne ? 1 : 0;
        int n = d;
        for (Iterable<TERM> documentVocabulary : documentVocabularies)
        {
            n += 1;
            for (TERM term : documentVocabulary)
            {
                Integer t = df.get(term);
                if (t == null) t = d;
                df.put(term, t + 1);
            }
        }
        Map<TERM, Double> idf = new HashMap<TERM, Double>();
        for (Map.Entry<TERM, Integer> e : df.entrySet())
        {
            TERM term = e.getKey();
            double f = e.getValue();
            idf.put(term, Math.log(n / f) + a);
        }
        return idf;
    }
193099
def count_records(self, record_counter, file):
        """"""
        counter = record_counter
        events_counter = 0
        for record in file.get_records():
            recid = record[2]
            counter[recid] = counter.get(recid, 0) + 1
            events_counter += 1

        self.stat['user_record_events'] = events_counter
        return counter
51529
def pages(self, limit=0):
        """"""
        if limit > 0:
            self.iterator.limit = limit
        return self.iterator
12838
def get_lexicons(self, num_terms=10):
        '''
        
        '''
        return {k: v.index[:num_terms]
                for k, v in self.lexicons.items()}
534088
def term_count_buckets(self):

        

        buckets = {}
        for term, count in self.term_counts().items():
            if count in buckets: buckets[count].append(term)
            else: buckets[count] = [term]

        return buckets
1079844
def probabilistic_inverse_document_frequency(term)
      count = @model.document_count(term).to_f
      log((documents.size - count) / count)
    end
988145
def count_terms(geneset, assoc, obo_dag):
    
    term_cnt = Counter()
    for gene in (g for g in geneset if g in assoc):
        for goid in assoc[gene]:
            if goid in obo_dag:
                term_cnt[obo_dag[goid].id] += 1

    return term_cnt
1048611
def words(fpth):
    
    from collections import Counter
    words__ = Counter()
    with open(fpth) as fp:
        for line in fp:
            words__.update(line.strip().split(' '))
    return words__