Open
Conversation
…end of each string
…borMap test = Passed
…ways set to context size (1). Changed to neighborhood key -> list.size
…ray to list, moved from each line to each token. Because of the change i was able to take away the split and replace all. While loop scans the whole file not just the first line.
auberonedu
reviewed
Feb 18, 2025
Comment on lines
+1
to
+3
| slow down forever and float above the comedown catches me down for good go for broke, | ||
| as country folk never crack my crescendo vanta blackout with my crescendo vanta blackout | ||
| with my baby dont care youll never crack my soul sister through the electro madness buckle bunny |
Comment on lines
+34
to
+49
| List<String> contentList = new ArrayList<>(); | ||
| List<String> result = new ArrayList<>(); | ||
|
|
||
| while (scanner.hasNextLine()) { | ||
| result.add(scanner.next().toLowerCase()); | ||
| } | ||
|
|
||
| for (String str : result) { | ||
| if(str.charAt(str.length()-1) != '.'){ | ||
| contentList.add(str); | ||
| }else{ | ||
| String temp = str.replace('.', ' '); | ||
| contentList.add(temp.replace(" ", "")); | ||
| contentList.add("."); | ||
| } | ||
| } |
Comment on lines
+19
to
+25
| @Test | ||
| void testTokenWithManySpaces(){ | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("hello hi hi hi hello hello"); | ||
| List<String> token = tokenizer.tokenize(scanner); | ||
| assertEquals(List.of("hello", "hi", "hi", "hi", "hello", "hello"), token); | ||
| } |
Comment on lines
+58
to
+64
| for(int i = 1; i < trainingWords.size(); i++){ | ||
| neighborMap.get(trainingWords.get(i-1)).add(trainingWords.get(i)); | ||
|
|
||
| if(!neighborMap.containsKey(trainingWords.get(i))){ | ||
| neighborMap.put(trainingWords.get(i), new ArrayList<String>()); | ||
| } | ||
| } |
There was a problem hiding this comment.
Smart initializing the list in the previous pass
Comment on lines
+116
to
+118
| String lastWord = context.get(context.size()-1); | ||
| int randomStringIndex = rand.nextInt(neighborMap.get(lastWord).size()); | ||
| return neighborMap.get(lastWord).get(randomStringIndex); |
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.