コード例 #1
0
 /*
  * incrementTerm(String term, EntryStatistics es)
  */
 @Test
 public void test_incrementTerm1() throws Exception {
   MemoryLexicon lexicon = new MemoryLexicon();
   assertNotNull(lexicon);
   for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]);
   assertEquals(10, lexicon.numberOfEntries());
 }
コード例 #2
0
 /*
  * getLexiconEntry(String term)
  */
 @Test
 public void test_getLexiconEntry1() throws Exception {
   MemoryLexicon lexicon = new MemoryLexicon();
   assertNotNull(lexicon);
   for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]);
   for (int i = 0; i < 10; i++) {
     LexiconEntry le = lexicon.getLexiconEntry(terms[i].toString());
     assertEquals(i, le.getTermId());
     assertEquals(i + 1, le.getDocumentFrequency());
     assertEquals(i + 1, le.getFrequency());
   }
 }
コード例 #3
0
 /*
  * getIthLexiconEntry(int index)
  */
 @Test
 public void test_getIthLexiconEntry() throws Exception {
   MemoryLexicon lexicon = new MemoryLexicon();
   assertNotNull(lexicon);
   for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]);
   for (int i = 0; i < 10; i++) {
     Entry<String, LexiconEntry> kv = lexicon.getIthLexiconEntry(i);
     assertEquals("t" + i, kv.getKey());
     assertEquals(i, kv.getValue().getTermId());
     assertEquals(i + 1, kv.getValue().getDocumentFrequency());
     assertEquals(i + 1, kv.getValue().getFrequency());
   }
 }
コード例 #4
0
 /*
  * iterator()
  */
 @Test
 public void test_iterator() throws Exception {
   MemoryLexicon lexicon = new MemoryLexicon();
   assertNotNull(lexicon);
   for (int i = 0; i < 10; i++) lexicon.term(terms[i].toString(), entries[i]);
   Iterator<Entry<String, LexiconEntry>> it = lexicon.iterator();
   assertNotNull(it);
   int i = 0;
   while (it.hasNext()) {
     Entry<String, LexiconEntry> kv1 = it.next();
     Entry<String, LexiconEntry> kv2 = lexicon.getLexiconEntry(i++);
     assertEquals(kv1.getKey(), kv2.getKey());
     assertEquals(kv1.getValue().getTermId(), kv2.getValue().getTermId());
     assertEquals(kv1.getValue().getDocumentFrequency(), kv2.getValue().getDocumentFrequency());
     assertEquals(kv1.getValue().getFrequency(), kv2.getValue().getFrequency());
   }
 }