Open
Conversation
…method to fix bugs identified by last test
auberonedu
reviewed
Feb 18, 2025
|
|
||
| Enter the filename: dylanTraining.txt | ||
| Enter the number of words to generate: 250 | ||
| once upon a siamese cat ain't got it feel? to it feel, ah you don't seem so loud now you ain't no secrets to fall' you better pawn it ain't got nothing, you say 'beware doll, you're gonna have to be on your own, with no direction home like a home like a chrome horse with no secrets to get your own, with no direction home like a complete unknown, like a chrome horse with no secrets to be on the jugglers and say you dressed so proud about everybody that it feel, how does it feel, ah how does it feel? to get juiced in your own, with your diamond ring, you know you better take your kicks for you say 'beware doll, you're invisible now, you've got nothing to get juiced in rags and the clowns when you say do you you realize he's not selling any alibis as you how does it feel, how does it ain't no direction home like a deal? how does it babe you want to him he really wasn't where it's at napoleon in rags and the frowns on your diamond ring, you everything he really wasn't where it's at napoleon in your kicks for you say do you used to conceal how does it feel? to be without a rolling stone ahh you've gone to fall' you everything he used to him he could steal how to him he could steal how does it babe you stare into the pretty people No newline at end of file |
Comment on lines
+117
to
+124
| public boolean checkIfPunctuation(char character) | ||
| { | ||
| if(character == '.' || character == '!' || character == '?' || character == ',' || character == ';' || character == ':' || character == '\"') | ||
| { | ||
| return true; | ||
| } | ||
|
|
||
| return false; |
There was a problem hiding this comment.
Very cool! Can you think how you could write this as a single line with no if/else?
Comment on lines
+51
to
+62
| if(token.startsWith("\"")) | ||
| { | ||
| tokenList.add("\""); | ||
| token = token.substring(1,token.length()); | ||
| } | ||
|
|
||
| if(token.endsWith("...")) | ||
| { | ||
| token = token.substring(0,token.length()-3); | ||
| tokenList.add(token); | ||
| tokenList.add("..."); | ||
| } |
There was a problem hiding this comment.
Cool you're adding all this functionality!
Comment on lines
+60
to
+76
| @Test | ||
| void testTokenizeEndsWithElipsisi() { | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("Hello world... This is Dr.Smith's example..."); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
|
|
||
| assertEquals(List.of("hello", "world", "...", "this", "is", "dr.smith's", "example", "..."), tokens); | ||
| } | ||
|
|
||
| @Test | ||
| void testTokenizeSentenceInQuotes() { | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("\"Hello world. This is Dr.Smith's example.\""); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
|
|
||
| assertEquals(List.of("\"", "hello","world", ".", "this", "is", "dr.smith's", "example", ".","\""), tokens); | ||
| } |
Comment on lines
+60
to
+78
| for (int i = 0; i < trainingWords.size() - 1; i++) | ||
| { | ||
| String word = trainingWords.get(i); | ||
| String nextWord = trainingWords.get(i + 1); | ||
|
|
||
| if (neighborMap.containsKey(word)) | ||
| { | ||
| List<String>temp = neighborMap.get(word); | ||
| temp.add(nextWord); | ||
| neighborMap.put(word, temp); | ||
| } | ||
|
|
||
| else | ||
| { | ||
| List<String>temp = new ArrayList<>(); | ||
| temp.add(nextWord); | ||
| neighborMap.put(word, temp); | ||
| } | ||
| } |
Comment on lines
+139
to
+149
| String lastWordInContext = context.get(context.size()-1); | ||
| Random random = new Random(); | ||
| String nextWord = ""; | ||
|
|
||
| if (neighborMap.containsKey(lastWordInContext)) | ||
| { | ||
| List<String> temp = neighborMap.get(lastWordInContext); | ||
| int index = random.nextInt(temp.size()); | ||
| nextWord = temp.get(index); | ||
| return nextWord; | ||
| } |
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.