Skip to content

Commit

Permalink
unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
ysc committed Jan 30, 2017
1 parent 9045b07 commit 6392a47
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ public void testGet() {
}
@Test
public void testBigram(){
try(Stream<String> lines = Files.lines(Paths.get("src/main/resources/bigram.txt"))) {
try(Stream<String> lines = Files.lines(Paths.get("src/main/resources/bigram.txt")).limit(1000)) {
Map<String, Integer> map = new HashMap<>();
lines.forEach(line -> {
String[] attrs = line.split("\\s+");
if(attrs!=null && attrs.length==2){
map.put(attrs[0], Integer.parseInt(attrs[1]));
}
});
DoubleArrayGenericTrie doubleArrayGenericTrie = new DoubleArrayGenericTrie(WordConfTools.getInt("bigram.double.array.trie.size", 5300000));
DoubleArrayGenericTrie doubleArrayGenericTrie = new DoubleArrayGenericTrie(WordConfTools.getInt("bigram.double.array.trie.size", 10000));
doubleArrayGenericTrie.putAll(map);
map.keySet().forEach(key->assertEquals(map.get(key).intValue(), doubleArrayGenericTrie.get(key)));
}catch (Exception e){
Expand All @@ -88,15 +88,15 @@ public void testBigram(){
}
@Test
public void testTrigram(){
try(Stream<String> lines = Files.lines(Paths.get("src/main/resources/trigram.txt"))) {
try(Stream<String> lines = Files.lines(Paths.get("src/main/resources/trigram.txt")).limit(1000)) {
Map<String, Integer> map = new HashMap<>();
lines.forEach(line -> {
String[] attrs = line.split("\\s+");
if(attrs!=null && attrs.length==2){
map.put(attrs[0], Integer.parseInt(attrs[1]));
}
});
DoubleArrayGenericTrie doubleArrayGenericTrie = new DoubleArrayGenericTrie(WordConfTools.getInt("trigram.double.array.trie.size", 9800000));
DoubleArrayGenericTrie doubleArrayGenericTrie = new DoubleArrayGenericTrie(WordConfTools.getInt("trigram.double.array.trie.size", 10000));
doubleArrayGenericTrie.putAll(map);
map.keySet().forEach(key->assertEquals(map.get(key).intValue(), doubleArrayGenericTrie.get(key)));
}catch (Exception e){
Expand Down

0 comments on commit 6392a47

Please sign in to comment.