public static Bigram[] of(Corpus corpus, int k, int minFrequency) {
        Bigram[] bigrams = new Bigram[k];
        HeapSelect<Bigram> heap = new HeapSelect<>(bigrams);

        Iterator<smile.nlp.Bigram> iterator = corpus.bigrams();
        while (iterator.hasNext()) {
            smile.nlp.Bigram bigram = iterator.next();
            int c12 = corpus.count(bigram);

            if (c12 > minFrequency) {
                int c1 = corpus.count(bigram.w1);
                int c2 = corpus.count(bigram.w2);

                double score = likelihoodRatio(c1, c2, c12, corpus.size());
                heap.add(new Bigram(bigram.w1, bigram.w2, c12, -score));
            }
        }

        heap.sort();

        Bigram[] collocations = new Bigram[k];
        int n = 0;
        for (int i = 0; i < k; i++) {
            Bigram bigram = bigrams[k-i-1];
            if (bigram != null) {
                collocations[n++] = new Bigram(bigram.w1, bigram.w2, bigram.count, -bigram.score);
            }
        }

        if (n < k) {
            collocations = Arrays.copyOf(collocations, n);
        }

        return collocations;
    }
@Test
    public void testFind_Corpus_int() {
        System.out.println("k = 10");

        int k = 10;
        Bigram[] result = Bigram.of(corpus, k, 5);

        assertEquals(10, result.length);
        for (Bigram bigram : result) {
            System.out.println(bigram);
        }

        assertEquals(46, result[0].count);
        assertEquals(545.16, result[0].score, 1E-2);
        assertEquals(19, result[9].count);
        assertEquals(186.69, result[9].score, 1E-2);
    }