List the top ``Nwords`` words for each topic.
188722
def list_topics(self, Nwords=10):
        
        return [(k, self.list_topic(k, Nwords)) for k in xrange(len(self.phi))]
397265
def rank(syllabifications):
    ''''''

    # def key(s):
    #     word = s[0]
    #     w = wsp(word)
    #     p = pk_prom(word)
    #     n = nuc(word)
    #     t = w + p + n
    #     print('%s\twsp: %s\tpk: %s\tnuc: %s\ttotal: %s' % (word, w, p, n, t))

    #     return w + p + n

    # syllabifications.sort(key=key)

    syllabifications.sort(key=lambda s: wsp(s[0]) + pk_prom(s[0]) + nuc(s[0]))

    return syllabifications
161836
def print_topics(words_per_topic = 10)
      raise 'No vocabulary loaded.' unless @vocab

      beta.each_with_index do |topic, topic_num|
        # Sort the topic array and return the sorted indices of the best scores
        indices = topic.zip((0...@vocab.size).to_a).sort { |x| x[0] }.map { |_i, j| j }.reverse[0...words_per_topic]

        puts "Topic #{topic_num}"
        puts "\t#{indices.map { |i| @vocab[i] }.join("\n\t")}"
        puts ''
      end

      nil
    end
42448
def top_sections(self):
        

        top_line = self.text.split('\n')[0]
        sections = len(top_line.split('+')) - 2

        return sections
867410
def top(self, sort_by):
        """"""
        sort = sorted(self.results, key=sort_by)
        return sort
376152
def sentences(self, index = None):
        """"""
        if index is None:
            return self.select(Sentence,None,True,[Quote])
        else:
            if index < 0:
                index = sum(t.count(Sentence,None,True,[Quote]) for t in self.data) + index
            for t in self.data:
                for i,e in enumerate(t.select(Sentence,None,True,[Quote])) :
                    if i == index:
                        return e
            raise IndexError
113097
def lookup(self, topic):
        """"""
        nsq.assert_valid_topic_name(topic)
        return self._request('GET', '/lookup', fields={'topic': topic})
479340
def get_unknown_topics(self, lang):
        """"""
        return [topic['title']
                for topic in self.user_data.language_data[lang]['skills']
                if not topic['learned']]
392445
def get_news(self):
        
        if self.topic is None or self.topic is 'Top Stories':
            resp = requests.get(top_news_url, params=self.params_dict)
        else:
            topic_code = topicMap[process.extractOne(self.topic, self.topics)[0]]
            resp = requests.get(topic_url.format(topic_code), params=self.params_dict)
        return self.parse_feed(resp.content)
955677
private void populateTopics(String[] topics) {
        for (String t : topics) {
            // Clean up leading and trailing white space as appropriate
            t = t.trim();

            // Ignore topics that start or end with a '/'
            if (t.startsWith("/") || t.endsWith("/") || t.contains("//") || t.isEmpty()) {
                continue;
            }

            // Validate subscribe permission per section 113.10.2
            checkTopicSubscribePermission(t);

            if (t.equals("*")) {
                wildcardTopics.add("");
            } else if (t.endsWith("/*")) {
                wildcardTopics.add(t.substring(0, t.length() - 1));
            } else {
                discreteTopics.add(t);
            }
        }
    }
1266693
def text_channels(self):
        """"""
        ret = [c for c in self.guild.channels
            if c.category_id == self.id
            and isinstance(c, TextChannel)]
        ret.sort(key=lambda c: (c.position, c.id))
        return ret
1014776
def tops(opts):
    '''
    
    '''
    if 'master_tops' not in opts:
        return {}
    whitelist = list(opts['master_tops'].keys())
    ret = LazyLoader(
        _module_dirs(opts, 'tops', 'top'),
        opts,
        tag='top',
        whitelist=whitelist,
    )
    return FilterDictWrapper(ret, '.top')
971641
def get_en_words() -> Set[str]:
    

    pull_en_words()

    with open(config.EN_WORDS_PATH) as words_f:
        raw_words = words_f.readlines()
    en_words = set([word.strip().lower() for word in raw_words])
    NA_WORDS_IN_EN_DICT = set(["kore", "nani", "karri", "imi", "o", "yaw", "i",
                           "bi", "aye", "imi", "ane", "kubba", "kab", "a-",
                           "ad", "a", "mak", "selim", "ngai", "en", "yo",
                           "wud", "mani", "yak", "manu", "ka-", "mong",
                           "manga", "ka-", "mane", "kala", "name", "kayo",
                           "kare", "laik", "bale", "ni", "rey", "bu",
                           "re", "iman", "bom", "wam",
                           "alu", "nan", "kure", "kuri", "wam", "ka", "ng",
                           "yi", "na", "m", "arri", "e", "kele", "arri", "nga",
                           "kakan", "ai", "ning", "mala", "ti", "wolk",
                           "bo", "andi", "ken", "ba", "aa", "kun", "bini",
                           "wo", "bim", "man", "bord", "al", "mah", "won",
                           "ku", "ay", "belen", "wen", "yah", "muni",
                           "bah", "di", "mm", "anu", "nane", "ma", "kum",
                           "birri", "ray", "h", "kane", "mumu", "bi", "ah",
                           "i-", "n", "mi", "bedman", "rud", "le", "babu",
                           "da", "kakkak", "yun", "ande", "naw", "kam", "bolk",
                           "woy", "u", "bi-",
                           ])
    EN_WORDS_NOT_IN_EN_DICT = set(["screenprinting"])
    en_words = en_words.difference(NA_WORDS_IN_EN_DICT)
    en_words = en_words | EN_WORDS_NOT_IN_EN_DICT
    return en_words
125923
def _cldf2wordlist(dataset, row='parameter_id', col='language_id'):
    """"""
    return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col)
183453
def _words_by_salience_score(vocab, topic_word_distrib, doc_topic_distrib, doc_lengths, n=None, least_to_most=False):
    """"""
    saliency = get_word_saliency(topic_word_distrib, doc_topic_distrib, doc_lengths)
    return _words_by_score(vocab, saliency, least_to_most=least_to_most, n=n)
567673
def get_top(self, stat, n):
        """'"""
        return sorted(self.stats, key=lambda x: getattr(x, stat), reverse=True)[:n]
1021449
def _disambiguate_pos(self, terms, pos):
        
        # Map the terms to candidate concepts
        # Consider only the top 3 most common senses
        candidate_map = {term: wn.synsets(term, pos=pos)[:3] for term in terms}

        # Filter to unique concepts
        concepts = set(c for cons in candidate_map.values() for c in cons)

        # Back to list for consistent ordering
        concepts = list(concepts)
        sim_mat = self._similarity_matrix(concepts)

        # Final map of terms to their disambiguated concepts
        map = {}

        # This is terrible
        # For each term, select the candidate concept
        # which has the maximum aggregate similarity score against
        # all other candidate concepts of all other terms sharing the same PoS
        for term, cons in candidate_map.items():
            # Some words may not be in WordNet
            # and thus have no candidate concepts, so skip
            if not cons:
                continue
            scores = []
            for con in cons:
                i = concepts.index(con)
                scores_ = []
                for term_, cons_ in candidate_map.items():
                    # Some words may not be in WordNet
                    # and thus have no candidate concepts, so skip
                    if term == term_ or not cons_:
                        continue
                    cons_idx = [concepts.index(c) for c in cons_]
                    top_sim = max(sim_mat[i,cons_idx])
                    scores_.append(top_sim)
                scores.append(sum(scores_))
            best_idx = np.argmax(scores)
            map[term] = cons[best_idx]

        return map