Parameters
        ----------
        num_terms, int

        Returns
        -------
        dict
12838
def get_lexicons(self, num_terms=10):
        '''
        
        '''
        return {k: v.index[:num_terms]
                for k, v in self.lexicons.items()}
679158
def num_columns(self):
        """"""
        if self.term.is_a_tty:
            return self.term.width // self.hint_width
        return 1
375720
def parseSearchTerm(term):
    
    terms = []
    keywords = {}
    for word in term.split():
        if word.count(':') == 1:
            k, v = word.split(u':')
            if k and v:
                keywords[k] = v
            elif k or v:
                terms.append(k or v)
        else:
            terms.append(word)
    term = u' '.join(terms)
    if keywords:
        return term, keywords
    return term, None
55805
def get_terms(self):
        '''  '''
        if not self.terms.empty:
            return self.terms
        if self.from_backup:
            self.terms = open_pickle(TERMS_BACKUP_PATH)
            return self.terms
        engine = create_engine(self.db_url)
        data = """
            SELECT t.id as tid, t.ilx, t.label, t.definition, t.type, t.comment, t.version
            FROM terms t
            GROUP BY t.ilx
        """
        self.terms = pd.read_sql(data, engine)
        create_pickle(self.terms, TERMS_BACKUP_PATH)
        return self.terms
403155
def get_numwords():
    """"""
    numwords = {'and': (1, 0), 'a': (1, 1), 'an': (1, 1)}

    for idx, word in enumerate(UNITS):
        numwords[word] = (1, idx)
    for idx, word in enumerate(TENS):
        numwords[word] = (1, idx * 10)
    for idx, word in enumerate(SCALES):
        numwords[word] = (10 ** (idx * 3 or 2), 0)

    all_numbers = ur'|'.join(ur'\b%s\b' % i for i in numwords.keys() if i)

    return all_numbers, numwords
1347829
def _or_join(self, terms):
        
        from six import text_type

        if isinstance(terms, (tuple, list)):
            if len(terms) > 1:
                return ' | '.join(text_type(t) for t in terms)
            else:
                return terms[0]
        else:
            return terms
1220318
def get_term_frequency(self, term, document, normalized=False):
        
        if document not in self._documents:
            raise IndexError(DOCUMENT_DOES_NOT_EXIST)

        if term not in self._terms:
            raise IndexError(TERM_DOES_NOT_EXIST)

        result = self._terms[term].get(document, 0)
        if normalized:
            result /= self.get_document_length(document)

        return float(result)
1123884
def most_frequent_terms(self, count=0):
        
        # sort terms by number of occurrences in descending order
        terms = sorted(self._terms.items(), key=lambda i: -i[1])

        terms = tuple(i[0] for i in terms)
        if count == 0:
            return terms
        elif count > 0:
            return terms[:count]
        else:
            raise ValueError(
                "Only non-negative values are allowed for count of terms.")
1131202
def _compute_term_1(self, C, mag):
        
        return (
            C['a1'] + C['a2'] * mag + C['a3'] *
            np.power(mag, 2) + C['a4'] * np.power(mag, 3)
            + C['a5'] * np.power(mag, 4) + C['a6'] *
            np.power(mag, 5) + C['a7'] * np.power(mag, 6)
        )
550108
def imm_dict(imm):
    '''
    
    '''
    immd = dict(**imm_params(imm))
    for (k,v) in six.iteritems(imm_values(imm)):
        immd[k] = v
    return immd
960494
def get_documents(self, term):
        
        if term not in self._terms:
            raise IndexError(TERM_DOES_NOT_EXIST)
        else:
            return self._terms[term]
497920
def call(*terms, **kwargs):
    
    for kwarg in kwargs:
        if kwarg not in ["module"]:
            raise KeyError

    module = kwargs.get("module", None)

    t = terms[0]
    for tx in terms[1:]:
        t = _comma(t, tx)

    return PL_call(t.handle, module)
1153714
def to_ngrams(self, terms):
        ''' 
        '''
        if len(terms) <= self.n:
            return terms
        if self.n == 1:
            n_grams = [[term] for term in terms]
        else:
            n_grams = []
            for i in range(0,len(terms)-self.n+1):
                n_grams.append(terms[i:i+self.n])
        return n_grams
893885
def get_feats(self, doc):
		'''
		
		'''
		# ngram_counter = phrasemachine.get_phrases(str(doc), tagger='spacy')['counts']
		ngram_counter = Counter()
		for sent in doc.sents:
			unigrams = self._get_unigram_feats(sent)
			ngram_counter += Counter(unigrams) + _phrase_counts(sent)
		return ngram_counter
886679
def word_counts(self):
    
    counts = defaultdict(int)
    for word in self.words:
        counts[word] += 1
    return counts
499225
def __get_query_for_repos(self, term_count=5):
        
        repo_query_terms = list()
        for term in self.lda_model.get_topic_terms(0, topn=term_count):
            repo_query_terms.append(self.lda_model.id2word[term[0]])
        return " ".join(repo_query_terms)
701304
def remove_terms_used_in_less_than_num_docs(self, threshold):
        '''
        
        '''
        term_counts = self._X.astype(bool).astype(int).sum(axis=0).A[0]
        terms_to_remove = np.where(term_counts < threshold)[0]
        return self.remove_terms_by_indices(terms_to_remove)