forked from auberonedu/ramblebot
-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathLowercaseSentenceTokenizerTest.java
More file actions
63 lines (50 loc) · 2.2 KB
/
LowercaseSentenceTokenizerTest.java
File metadata and controls
63 lines (50 loc) · 2.2 KB
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
import org.junit.jupiter.api.Test;
import java.util.List;
import java.util.Scanner;
import static org.junit.jupiter.api.Assertions.*;
class LowercaseSentenceTokenizerTest {
// Wave 1
@Test
void testTokenizeWithNoCapitalizationOrPeriod() {
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("this is a lowercase sentence without a period");
List<String> tokens = tokenizer.tokenize(scanner);
assertEquals(List.of("this", "is", "a", "lowercase", "sentence", "without", "a", "period"), tokens);
}
// Wave 2
@Test
void testTokenizeSpaces()
{
// Arrange
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("hello hi hi hi hello hello");
// Act
List<String> tokens = tokenizer.tokenize(scanner);
// Assert
assertEquals(List.of("hello", "hi", "hi", "hi", "hello", "hello"), tokens);
}
// Wave 3
@Test
void testTokenizeWithCapitalization() {
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("This is a SENTENCE with sTrAnGe capitalization");
List<String> tokens = tokenizer.tokenize(scanner);
assertEquals(List.of("this", "is", "a", "sentence", "with", "strange", "capitalization"), tokens);
}
// Wave 3
@Test
void testTokenizeSentenceWithPeriod() {
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("Hello world. This is an example.");
List<String> tokens = tokenizer.tokenize(scanner);
assertEquals(List.of("hello", "world", ".", "this", "is", "an", "example", "."), tokens);
}
// Wave 3
@Test
void testTokenizeWithInternalPeriod() {
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("Hello world. This is Dr.Smith's example.");
List<String> tokens = tokenizer.tokenize(scanner);
assertEquals(List.of("hello", "world", ".", "this", "is", "dr.smith's", "example", "."), tokens);
}
}