Open
Conversation
auberonedu
reviewed
Feb 18, 2025
Comment on lines
+1
to
+4
| the world so fall beneath the same oh you cause i follow the coldness from your energy to life they don't know where.. | ||
| you're falling through the distance in front of the way and i'll be let it falls away save me alive i will travel the walls | ||
| you radiating energy has set me shine on the word i'd make me to hear me your light and i won't come down to you supernova: | ||
| we'll fuse when the silence now i seek afraid of night, you breathe in seas of your bluff now they only one in the more |
Comment on lines
+41
to
+45
| if(token.contains("." ) && token.substring(token.length()-1).equals(".")){ | ||
| // add the substring of the token that does not contain the period | ||
| tokened.add(token.substring(0, token.length()-1)); | ||
| // add a period | ||
| tokened.add("."); |
There was a problem hiding this comment.
Nice! As an alternative, you can use endsWith
| @Override | ||
| public List<String> tokenize(Scanner text) { | ||
| //returned array | ||
| ArrayList<String> tokened = new ArrayList<>(); |
There was a problem hiding this comment.
Remember to use interface types (List) where appropriate
Comment on lines
+24
to
+30
| @Test | ||
| void testTokenWithLotsOfSpaces(){ | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("this is a sentence with lots of spaces"); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
| assertEquals(List.of("this", "is", "a", "sentence", "with", "lots", "of", "spaces"), tokens); | ||
| } |
| List<String> trainingWords = tokenizer.tokenize(text); | ||
|
|
||
| // TODO: Convert the trainingWords into neighborMap here | ||
| this.neighborMap = new HashMap<String, List<String>>(); |
There was a problem hiding this comment.
You can use <> here and Java will infer the generics
Comment on lines
+56
to
+66
| for(int i = 0; i< trainingWords.size() - 1; i++){ | ||
| String key = trainingWords.get(i); | ||
| if(!this.neighborMap.containsKey(key)){ | ||
| List<String> mapped = new ArrayList<>(); | ||
| for(int j = 0; j < trainingWords.size() - 1; j++){ | ||
| if(trainingWords.get(j).equals(key) && j != trainingWords.size() - 1){ | ||
| mapped.add(trainingWords.get(j+1)); | ||
| } | ||
| } | ||
| this.neighborMap.put(key, mapped); | ||
| } |
Comment on lines
+119
to
+123
| // This lad is chunky | ||
| // First, we get the size of the list belonging to a key. | ||
| // with this, generate a number using the size of the list | ||
| // then we pick a random word in the list using the randomly generated number | ||
| return (this.neighborMap.get(word).get(num.nextInt(this.getNeighborMap().get(word).size()))); |
There was a problem hiding this comment.
This logic works, but putting it all on one line makes it pretty hard to read. Consider splitting this up into multiple lines with intermediate variables.
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.