Print common terms for each pair of word sets.
    :param common_terms: Output of get_common_terms().
960389
def print_common_terms(common_terms):
    
    if not common_terms:
        print('No duplicates')
    else:
        for set_pair in common_terms:
            set1, set2, terms = set_pair
            print('{} and {} have in common:'.format(set1, set2))
            for term in terms:
                print('    {}'.format(term))
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)
419364
def map_tokens_to_terms(self,list_tokens):
        
        if self.terms_for_token is None:
            self.terms_for_token = {}
            for term in self.get_terms():
                termid = term.get_id()
                token_ids = term.get_span().get_span_ids()
                for tokid in token_ids:
                    if tokid not in self.terms_for_token:
                        self.terms_for_token[tokid] = [termid]
                    else:
                        self.terms_for_token[tokid].append(termid)

        ret = set()
        for my_id in list_tokens:
            term_ids = self.terms_for_token.get(my_id,[])
            ret |= set(term_ids)
        return sorted(list(ret))
1289517
def extract_common(self, keys):
		
		keys = set(keys)
		new = self.__class__()
		intersection = self.intersection(keys)
		for key in keys:
			dict.__setitem__(new, key, _shallowcopy(intersection))
			dict.__setitem__(new.offsets, key, self.offsets[key])
		return new
752568
def word_texts(self):
        """"""
        if not self.is_tagged(WORDS):
            self.tokenize_words()
        return [word[TEXT] for word in self[WORDS]]
1207890
def get_pair(self, term1, term2):

        

        key = self.key(term1, term2)
        return self.pairs.get(key, None)
298649
def quick_search(self, terms):
        ''''''
        assert type(terms) is str
        p = [{'quicksearch': terms}]
        return self.search_bugs(p)
786173
public Set<Term> getAllTerms() {
        final Set<Term> ret = new HashSet<Term>();
        for (final StatementGroup sg : statementGroups) {
            for (final Statement stmt : sg.getAllStatements()) {
                ret.addAll(stmt.getAllTerms());
            }
        }
        return ret;
    }
147902
def _common_prefix(names):
    """"""
    if not names:
        return ''
    prefix = names[0]
    for name in names:
        i = 0
        while i < len(prefix) and i < len(name) and prefix[i] == name[i]:
            i += 1
        prefix = prefix[:i]
    return prefix
801311
def all_terms(self):
        """"""

        for s_name, s in self.sections.items():

            # Yield the section header
            if s.name != 'Root':
                yield s

            # Yield all of the rows for terms in the section
            for rterm in s:
                yield rterm
                for d in rterm.descendents:
                    yield d
950359
def words_for_language(language_code):
    
    word_groups = word_groups_for_language(language_code)
    words = []

    for group in word_groups:
        words.extend(word_groups[group].keys())

    return words
756186
def get_common(self, filename):
        '''  '''
        word_list = []
        words = open(filename)
        for word in words.readlines():
            word_list.append(word.strip())
        return word_list
593281
def print_user_sets(wordsets, print_terms):
    
    if not wordsets:
        print('No sets found')
    else:
        print('Found sets: {}'.format(len(wordsets)))
        for wordset in wordsets:
            print('    {}'.format(wordset))
            if print_terms:
                for term in wordset.terms:
                    print('        {}'.format(term))
1144375
def from_terms_dict(terms_dict):
        """"""
        return Expr(tuple(Term(k, v) for k, v in terms_dict.items() if v))
948848
function common(words) {
  return _.map(words, function(o) {
    return o.word.toLowerCase();
  }).sort();
}
85752
def term_rank(self, items, print_output=True):

        

        if items == 'stems':
            v = self.stems
        elif items == 'tokens':
            v = self.tokens
        elif items == 'bigrams':
            v = self.bigrams
        else:
            raise ValueError("Items must be either \'tokens\' , \'bigrams\' or \'stems\'.")

        agg = itertools.chain(*v)
        counts = collections.Counter(agg)

        v_unique = list(map(lambda x: set(x), v))
        agg_d = itertools.chain(*v_unique)
        counts_d = collections.Counter(agg_d)

        unique_tokens = set(itertools.chain(*v))

        def tf_idf_compute(t):
            return (1 + np.log(counts[t]))*np.log(self.N/counts_d[t])

        unsorted_df = [counts[t] for t in unique_tokens]
        unsorted_tf_idf = [tf_idf_compute(t) for t in unique_tokens]

        self.df_ranking = sorted(zip(unique_tokens, unsorted_df),
                                 key=lambda x: x[1], reverse=True)
        self.tfidf_ranking = sorted(zip(unique_tokens, unsorted_tf_idf),
                                    key=lambda x: x[1], reverse=True)

        if print_output:
            with codecs.open('df_ranking.csv', 'w', 'utf-8') as f:
                    for p in self.df_ranking:
                        f.write("%s,%d\n" % (p[0], p[1]))
            with codecs.open('tfidf_ranking.csv', 'w', 'utf-8') as f:
                    for p in self.tfidf_ranking:
                        f.write("%s,%f\n" % (p[0], p[1]))
531369
def keywords(text):
    
    text = split_words(text)
    numWords = len(text)  # of words before removing blacklist words
    freq = Counter(x for x in text if x not in stopWords)

    minSize = min(10, len(freq))  # get first 10
    keywords = {x: y for x, y in freq.most_common(minSize)}  # recreate a dict

    for k in keywords:
        articleScore = keywords[k]*1.0 / numWords
        keywords[k] = articleScore * 1.5 + 1

    return keywords