-
Notifications
You must be signed in to change notification settings - Fork 142
/
TestTransliteration.java
97 lines (71 loc) · 2.24 KB
/
TestTransliteration.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/**
* This software is released under the University of Illinois/Research and Academic Use License. See
* the LICENSE file in the root folder for details. Copyright (c) 2016
*
* Developed by: The Cognitive Computation Group University of Illinois at Urbana-Champaign
* http://cogcomp.org/
*/
package edu.illinois.cs.cogcomp.transliteration;
import org.junit.Test;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import static org.junit.Assert.assertEquals;
/**
* Created by mayhew2 on 11/5/15.
*/
public class TestTransliteration {
/**
* This is just a test to make sure that we can load and run everything.
*/
@Test
public void testModelLoad()
{
List<Example> examples = new ArrayList<>();
examples.add(new Example("this", "this"));
SPModel model = new SPModel(examples);
boolean rom = false;
model.Train(1,rom, examples);
System.out.println(model.Probability("this", "this"));
}
/**
* Test to ensure that Example equality is working correctly.
*/
@Test
public void testExampleEquality(){
HashSet<Example> ee = new HashSet<>();
Example e = new Example("John", "Smith");
Example e2 = new Example("John", "Smith");
ee.add(e);
ee.add(e2);
assert(ee.size() == 1);
Example e3 = new Example("Smith", "John");
ee.add(e3);
assert(ee.size() == 2);
}
/**
* Test to ensure that MultiExample equality is working correctly.
*/
@Test
public void testMultiExampleEquality(){
HashSet<MultiExample> ee = new HashSet<>();
List<String> l = new ArrayList<>();
l.add("wut");
l.add("why");
MultiExample me = new MultiExample("John", l);
List<String> l2 = new ArrayList<>();
l2.add("wut");
l2.add("why");
MultiExample me2 = new MultiExample("John", l2);
ee.add(me);
ee.add(me2);
assert(ee.size() == 1);
List<String> l3 = new ArrayList<>();
// these are in the opposite order.
l3.add("why");
l3.add("wut");
MultiExample me3 = new MultiExample("John", l3);
ee.add(me3);
assert(ee.size() == 2);
}
}