Ramblebot Completion - 6 waves#13
Open
xavierb117 wants to merge 12 commits intogrc-cohort-21:mainfrom
Open
Conversation
auberonedu
reviewed
Feb 18, 2025
| @@ -0,0 +1 @@ | |||
| true! -- how stealthily, stealthily --until, at the sound well . for his room . i not told you will think so that distracted me . ha! --would a tub had been deputed to feel --although he slept . i kept pushing it . the low stifled sound as a sound . he had caught all the chair upon the floor," or "it is the bed . they chatted pleasantly, and now you mistake for madness is the bed and smiled gaily, to open the legs . they not within my perfect suavity, as the old man's sleep . but No newline at end of file | |||
Comment on lines
+39
to
+43
| if (token.charAt(token.length() - 1) == '.') { | ||
| String period = token.charAt(token.length() - 1) + ""; | ||
| tokenizedList.add(token.substring(0, token.length() - 1)); | ||
| tokenizedList.add(period); | ||
| } |
There was a problem hiding this comment.
This works well! You can also use endsWith for the check
Comment on lines
+19
to
+26
| @Test | ||
| void testTokenizeWithManySpaces() { | ||
| 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
+56
to
+65
| for (int i = 0; i < trainingWords.size() - 1; i++) { | ||
| if (!neighborMap.containsKey(trainingWords.get(i))) { | ||
| List<String> newList = new ArrayList<>(); | ||
| newList.add(trainingWords.get(i+1)); | ||
| neighborMap.put(trainingWords.get(i), newList); | ||
| } | ||
| else { | ||
| List<String> value = neighborMap.get(trainingWords.get(i)); | ||
| value.add(trainingWords.get(i+1)); | ||
| neighborMap.put(trainingWords.get(i), value); |
There was a problem hiding this comment.
Great logic! Can you consider how you might refactor your if/else so there's a bit less repeated code?
Comment on lines
+117
to
+121
| String word = ""; | ||
| List<String> choices = neighborMap.get(context.get(context.size() - 1)); | ||
| Random random = new Random(); | ||
| int randomNum = random.nextInt(choices.size()); | ||
| word = choices.get(randomNum); |
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.