Untitled

 avatar
unknown
java
2 years ago
832 B
7
Indexable
@Test
    public void testIDFAndRankRetrieval() {

        Search search = new Search(testPages);
        search.pages = testPages;

        int totalNumberOfDocuments = 18; // This is the total number of documents in the corpus
        int OR = 1; // This is the OR value

        // get all List<Pages> from the HashMap
        List<Pages> pagesSet1 = new ArrayList<>(testPages.get("Word1"));
        pagesSet1.addAll(testPages.get("Word3"));

        search.IDF(pagesSet1, "word1", 1);

        // Assert
        for (Pages page : pagesSet1) {
            double D = pagesSet1.size();
            double N = totalNumberOfDocuments;
            double expectedIDF = Math.abs(Math.log(N / D));
            double rank = page.getRankdIDF(OR);
            assertEquals(expectedIDF, rank, 0.01);
        }
    }
Editor is loading...
Leave a Comment