Skip to content

Ramblebot assignment done!#19

Open
alexborovets11 wants to merge 7 commits intogrc-cohort-21:mainfrom
alexborovets11:main
Open

Ramblebot assignment done!#19
alexborovets11 wants to merge 7 commits intogrc-cohort-21:mainfrom
alexborovets11:main

Conversation

@alexborovets11
Copy link

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.

Great job!

Comment on lines +111 to +112
*I cannot figure out a way to pass the "Dr.Smith's" test:(( It's always treating the period as a separate token.
*I tried using a for loop with else if's also but it's still treating it as a separate token. I don't know how to fix it.

Choose a reason for hiding this comment

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

It's a tricky one! Solving with a regex is definitely not easy. If not doing it with a regex, using scanner.next endsWith can be nice to differentiate between words that have a period inside vs at the end.

Comment on lines +22 to +29
@Test
void testTokenizeWithMultipleSpaces() {
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);
}

Choose a reason for hiding this comment

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

Nice test!

Comment on lines +58 to +64
for (int i = 0; i < trainingWords.size() - 1; i++) {
String currentWord = trainingWords.get(i);
String nextWord = trainingWords.get(i + 1);

neighborMap.putIfAbsent(currentWord, new ArrayList<>());
neighborMap.get(currentWord).add(nextWord);
}

Choose a reason for hiding this comment

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

Great logic!

Comment on lines +114 to +124
String lastWord = context.get(context.size() - 1);

List<String> nextWords = neighborMap.get(lastWord);

if (nextWords == null || nextWords.isEmpty()) {
return null;
}

Random random = new Random();
int randomIndex = random.nextInt(nextWords.size());
return nextWords.get(randomIndex);

Choose a reason for hiding this comment

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

Nice!

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