Open
Conversation
…ded instructions for train in UnigramWordPredictor.java
…ur anywhere else in the text
auberonedu
reviewed
Feb 18, 2025
Comment on lines
6
to
10
| Ramblebot is a unigram word predictor written in Java that can be trained on any given set of text. | ||
| Using the Markov chain model, the bot can autoregressively predict words to | ||
| produce generated content in the style of the training text. | ||
|
|
||
| ### Academic Honesty | ||
| Link to demo: https://youtu.be/sY_KwScRxa0 |
There was a problem hiding this comment.
Super cool! Nice job cleaning this up so it can be presented to others. Very cool adding the video too!
Comment on lines
+1
to
+2
| on the lightning strikes lead you asked me and kiss me bleed? were kids and i know this life is breakin' i miss the only one way to know, now | ||
| i get this far i know in my mind 'cause i'm leaving i'm letting go now we bury the world is breakin' i just in my mind or tell me i close my mind |
|
|
||
| while (scanner.hasNext()) { | ||
| String token = scanner.next(); | ||
| char tokenLastChar = token.charAt(token.length() - 1); |
There was a problem hiding this comment.
This works well! As an alternative you can use endsWith
Comment on lines
+19
to
+26
| @Test | ||
| void testTokenizeWithManySpaces() { | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("this is a lowercase sentence with many spaces"); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
|
|
||
| assertEquals(List.of("this", "is", "a", "lowercase", "sentence", "with", "many", "spaces"), tokens); | ||
| } |
Comment on lines
+57
to
+61
| if (!neighborMap.containsKey(trainingWords.get(trainingWords.size() - 1))) { | ||
| List<String> newList = new ArrayList<>(); | ||
| newList.add(trainingWords.get(0)); | ||
| neighborMap.put(trainingWords.get(trainingWords.size() - 1), newList); | ||
| } |
There was a problem hiding this comment.
Very very smart! I've been meaning to change the assignment a bit so this is handled elsewhere, but great job handling it here!
Comment on lines
+77
to
+81
| String currentWord = context.get(context.size() - 1); | ||
| List<String> possibleNextWords = new ArrayList<>(neighborMap.get(currentWord)); | ||
| Random random = new Random(); | ||
|
|
||
| return possibleNextWords.get(random.nextInt(possibleNextWords.size())); |
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.
Daniel Grabowski