Open
Conversation
…r.java. The periods and capitalization have not been resolved yet.
…ith issue. I spent a lot of time on it but I am moving on now.
…t test for the UnigramWordPredictor.java
…named ramblebotOutput.txt. I also made any necessary adjustments if needed.
Merge finwake from upstream
auberonedu
reviewed
Feb 18, 2025
Comment on lines
+111
to
+112
| *I cannot figure out a way to pass the "Dr.Smith's" test:(( It's always treating the period as a separate token. | ||
| *I tried using a for loop with else if's also but it's still treating it as a separate token. I don't know how to fix it. |
There was a problem hiding this comment.
It's a tricky one! Solving with a regex is definitely not easy. If not doing it with a regex, using scanner.next endsWith can be nice to differentiate between words that have a period inside vs at the end.
Comment on lines
+22
to
+29
| @Test | ||
| void testTokenizeWithMultipleSpaces() { | ||
| 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
+58
to
+64
| for (int i = 0; i < trainingWords.size() - 1; i++) { | ||
| String currentWord = trainingWords.get(i); | ||
| String nextWord = trainingWords.get(i + 1); | ||
|
|
||
| neighborMap.putIfAbsent(currentWord, new ArrayList<>()); | ||
| neighborMap.get(currentWord).add(nextWord); | ||
| } |
Comment on lines
+114
to
+124
| String lastWord = context.get(context.size() - 1); | ||
|
|
||
| List<String> nextWords = neighborMap.get(lastWord); | ||
|
|
||
| if (nextWords == null || nextWords.isEmpty()) { | ||
| return null; | ||
| } | ||
|
|
||
| Random random = new Random(); | ||
| int randomIndex = random.nextInt(nextWords.size()); | ||
| return nextWords.get(randomIndex); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.