-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordGramTester.java
47 lines (45 loc) · 1.48 KB
/
WordGramTester.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class WordGramTester
{
public void testWordGram()
{
String source = "this is a test this is a test this is a test of words";
String[] words = source.split("\\s+");
int size = 4;
for(int index = 0; index <= words.length - size; index += 1)
{
WordGram wg = new WordGram(words,index,size);
System.out.println(index+"\t"+wg.length()+"\t"+wg);
}
}
public void testWordGramEquals()
{
String source = "this is a test this is a test this is a test of words";
String[] words = source.split("\\s+");
ArrayList<WordGram> list = new ArrayList<WordGram>();
int size = 4;
for(int index = 0; index <= words.length - size; index += 1)
{
WordGram wg = new WordGram(words,index,size);
list.add(wg);
}
WordGram first = list.get(0);
System.out.println("checking "+first);
for(int k=0; k < list.size(); k++)
{
if (first.equals(list.get(k)))
{
System.out.println("matched at "+k+" "+list.get(k));
}
}
}
public void testShiftAdd()
{
String source = "this is a test this is a test this is a test of words";
String[] words = source.split("\\s+");
int size = 4;
WordGram wg = new WordGram(words,0,size);
WordGram newWg = wg.shiftAdd("yes");
System.out.println(newWg);
}
}