Skip to content

Project: ramblebot #28

Open
elena5100 wants to merge 4 commits intogrc-cohort-21:mainfrom
elena5100:main
Open

Project: ramblebot #28
elena5100 wants to merge 4 commits intogrc-cohort-21:mainfrom
elena5100:main

Conversation

@elena5100
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.

Nice job!

String[] words = input.split("\\s+");

for (String word : words) {
if (word.endsWith(".")) {

Choose a reason for hiding this comment

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

Smart!

public List<String> tokenize(Scanner scanner) {
List<String> tokens = new ArrayList<>();

String input = scanner.nextLine().toLowerCase();

Choose a reason for hiding this comment

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

I think this only reads in a single line of input and doesn't handle multi-line input.

Comment on lines +23 to +30
@Test
void testTokenizeWithExtraSpaces() {
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 +45 to +56
for (int i = 0; i < trainingWords.size() - 1; i++) {
String currentWord = trainingWords.get(i);
String nextWord = trainingWords.get(i + 1);

// this code mean ...if currentWord is not already in neighborMap, add it with an empty list as its value.


neighborMap.putIfAbsent(currentWord, new ArrayList<>());

// Store the word that follows
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.

Nice!

Comment on lines +117 to +125
String lastWord = context.get(context.size() - 1); // Get last word

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

if (!nextWords.isEmpty()) {
return nextWords.get(random.nextInt(nextWords.size()));
}
}

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