Exemplo n.º 1
0
  @Test
  public void testWrite() throws Exception {

    ch.epfl.bbp.triechar.TrieCnt t = new ch.epfl.bbp.triechar.TrieCnt();
    t.addWord("he");
    t.addWord("he");
    t.addWord("hello");
    t.addWord("hi");
    t.addWord("hi");
    t.addWord("hi");
    t.addWord("awenwioen");

    String file = "target/trieTest_" + currentTimeMillis() + ".txt";
    t.toFrequencyFile(file);
    assertEquals("awenwioen\t1\nhe\t2\nhello\t1\nhi\t3\n", asText(new File(file)));
  }
Exemplo n.º 2
0
  @Test
  public void testCaseSensitive() {

    ch.epfl.bbp.triechar.TrieCnt t = new ch.epfl.bbp.triechar.TrieCnt(true);
    t.addWord("He");
    t.addWord("hi");

    assertEquals(0, t.getWord("he"));
    assertEquals(1, t.getWord("He"));

    assertEquals(1, t.getWord("hi"));
    assertEquals(0, t.getWord("Hi"));
  }