-
Notifications
You must be signed in to change notification settings - Fork 27
Rambo bot working #30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
f185357
3188a1a
f1b65a8
b4e9c46
2355680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Scanner; | ||
|
|
||
|
|
@@ -30,7 +31,15 @@ public class LowercaseSentenceTokenizer implements Tokenizer { | |
| */ | ||
| public List<String> tokenize(Scanner scanner) { | ||
| // TODO: Implement this function to convert the scanner's input to a list of words and periods | ||
| return null; | ||
| ArrayList<String> tokenizedList = new ArrayList<>(); | ||
|
|
||
|
|
||
| while (scanner.hasNext()) { | ||
| String item = scanner.next(); | ||
| tokenizedList.add(item); | ||
| } | ||
|
Comment on lines
+37
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works well for spaces, but doesn't quite handle the periods |
||
|
|
||
| return tokenizedList; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,15 @@ void testTokenizeWithNoCapitalizationOrPeriod() { | |
| /* | ||
| * Write your test here! | ||
| */ | ||
|
|
||
| @Test | ||
| void testNoSpaceToken() { | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("hello hi hi hi hello hello"); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
|
|
||
| assertEquals(List.of("hello", "hi", "hi", "hi", "hello", "hello"), tokens); | ||
| } | ||
|
Comment on lines
+22
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice test! |
||
|
|
||
|
|
||
| // Wave 3 | ||
| @Test | ||
|
|
@@ -28,7 +36,7 @@ void testTokenizeWithCapitalization() { | |
| 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); | ||
| assertEquals(List.of("This", "is", "a", "SENTENCE", "with", "sTrAnGe", "capitalization"), tokens); | ||
| } | ||
|
|
||
| // Wave 3 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,11 +47,20 @@ public UnigramWordPredictor(Tokenizer tokenizer) { | |
| * The order of the map and the order of each list is not important. | ||
| * | ||
| * @param scanner the Scanner to read the training text from | ||
| */ | ||
| public void train(Scanner scanner) { | ||
| * @return | ||
| */ | ||
| public List<String> train(Scanner scanner) { | ||
| List<String> trainingWords = tokenizer.tokenize(scanner); | ||
|
|
||
|
|
||
| // TODO: Convert the trainingWords into neighborMap here | ||
| while (scanner.hasNext()) { | ||
| String train = scanner.next(); | ||
| trainingWords.add(train); | ||
| } | ||
|
|
||
| return trainingWords; | ||
|
Comment on lines
+52
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This doesn't quite implement the logic we're hoping for - we were looking to fill the neighborMap here. |
||
|
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to use interface types where appropriate (List)