-
Notifications
You must be signed in to change notification settings - Fork 27
ramblebot #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
ramblebot #20
Conversation
auberonedu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job!
| if(word.endsWith(".")){ | ||
| tokens.add(word.substring(0, word.length() -1)); | ||
| tokens.add("."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice use of endsWith!
| //split line by space | ||
| String[]words = line.split("\\s+"); //https://stackoverflow.com/questions/25729181/how-to-split-by-newline-and-space | ||
| //Splitting Words and Periods |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for citing your source!
| void testTokenizeSentenceWitSpace(){ | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("this is a sentence with many space"); | ||
| List<String> tokens = tokenizer.tokenize(scanner); | ||
|
|
||
| assertEquals(List.of("this", "is", "a","sentence","with", "many","space"), tokens); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great test!
| neighborMap = new HashMap<>(); | ||
|
|
||
| //loop through wods | ||
| for(int i=0; i<trainingWords.size()-1; i++){ | ||
| String word = trainingWords.get(i); // Get the current word | ||
| String nextWord = trainingWords.get(i + 1); | ||
|
|
||
| // If the word is not in the map, add it with an empty list | ||
| if (!neighborMap.containsKey(word)) { | ||
| neighborMap.put(word, new ArrayList<>()); | ||
| } | ||
|
|
||
| // Add the next word to the list of following words | ||
| neighborMap.get(word).add(nextWord); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice logic!
No description provided.