Skip to content

Conversation

@beza102
Copy link

@beza102 beza102 commented Jan 30, 2025

No description provided.

Copy link

@auberonedu auberonedu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

Comment on lines +45 to +47
if(word.endsWith(".")){
tokens.add(word.substring(0, word.length() -1));
tokens.add(".");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of endsWith!

Comment on lines +39 to +41
//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

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!

Comment on lines +23 to +29
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);
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great test!

Comment on lines +57 to +70
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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice logic!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants