Conversation
…a second test to test extra spaces
…ptions. Need to fix adding the vlaues to the map
…lues for a key, did math for to find range and generate random number. Used generated number to find preidcted word.
…created two outputs based on those lyrics
auberonedu
reviewed
Feb 18, 2025
| @@ -0,0 +1 @@ | |||
| standing in the pillow what does it matter anyways she didn't like me anyways she was only let her face in the last of her crawl into my arms but what does it matter anyways i haven't seen the last of her crawl into my arms but she buried her oh, anjela can't stand the pillow what does it matter anyways i wasn't trying to stay warm oh, anjela can't stand the cold and arrangements there was only let her anyways she said, i'm not summer anymore i only thought because she climbed into my arms but she didn't like No newline at end of file | |||
Comment on lines
+45
to
+66
| if(!word.contains(".")) | ||
| { | ||
| tokenList.add(word); | ||
| } | ||
|
|
||
| //if period is at the end of the sentence or inside word | ||
| else | ||
| { | ||
| //period at end of sentence | ||
| int sLength = word.length()-1; | ||
| if(word.charAt(sLength) == '.') | ||
| { | ||
| String newWord = word.substring(0, sLength); | ||
| tokenList.add(newWord); | ||
| tokenList.add("."); | ||
| } | ||
|
|
||
| //period within word | ||
| else | ||
| { | ||
| tokenList.add(word); | ||
| } |
Comment on lines
+23
to
+30
| @Test | ||
| void testTokenizeSentenceWithSpaces() | ||
| { | ||
| 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
+68
to
+83
| for(String key : trainingWords) | ||
| { | ||
| List<String> valueWords = new ArrayList<>(); | ||
| List<String> trainingWordsTwo = new ArrayList<>(trainingWords); //copy of trainingwords list so that it can be edited without harming actual data | ||
| while(trainingWordsTwo.contains(key)) //loop that finds all of the following words for a key, adds to list, and the removes the instances of the keys until there are no more | ||
| { | ||
| int followingWordIndex = trainingWordsTwo.indexOf(key) + 1; | ||
| if(!(followingWordIndex > trainingWordsTwo.size()-1)) | ||
| { | ||
| String followingWord = trainingWordsTwo.get(followingWordIndex); | ||
| valueWords.add(followingWord); | ||
| } | ||
| trainingWordsTwo.remove(trainingWordsTwo.indexOf(key)); | ||
| } | ||
| //add values to key | ||
| neighborMap.put(key, valueWords); |
There was a problem hiding this comment.
Interesting approach! Smart to make a copy to avoid mutating the original.
Comment on lines
+148
to
+156
| Random rand = new Random(); | ||
| int min = 0; | ||
| int max = followingWords.size()-1; | ||
| int range = max - min + 1; | ||
| int randIndex = rand.nextInt(range)+min; | ||
|
|
||
| //predicting the new word | ||
| String predictedWord = followingWords.get(randIndex); | ||
| return predictedWord; |
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.