Skip to content

Functional Ramblebot#15

Open
Butenkite wants to merge 15 commits intogrc-cohort-21:mainfrom
Butenkite:main
Open

Functional Ramblebot#15
Butenkite wants to merge 15 commits intogrc-cohort-21:mainfrom
Butenkite:main

Conversation

@Butenkite
Copy link
Copy Markdown

No description provided.

Copy link
Copy Markdown

@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 thread rambleOutput.txt
Comment on lines +1 to +4
the world so fall beneath the same oh you cause i follow the coldness from your energy to life they don't know where..
you're falling through the distance in front of the way and i'll be let it falls away save me alive i will travel the walls
you radiating energy has set me shine on the word i'd make me to hear me your light and i won't come down to you supernova:
we'll fuse when the silence now i seek afraid of night, you breathe in seas of your bluff now they only one in the more
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

😮

Comment on lines +41 to +45
if(token.contains("." ) && token.substring(token.length()-1).equals(".")){
// add the substring of the token that does not contain the period
tokened.add(token.substring(0, token.length()-1));
// add a period
tokened.add(".");
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice! As an alternative, you can use endsWith

@Override
public List<String> tokenize(Scanner text) {
//returned array
ArrayList<String> tokened = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Remember to use interface types (List) where appropriate

Comment on lines +24 to +30
@Test
void testTokenWithLotsOfSpaces(){
LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer();
Scanner scanner = new Scanner("this is a sentence with lots of spaces");
List<String> tokens = tokenizer.tokenize(scanner);
assertEquals(List.of("this", "is", "a", "sentence", "with", "lots", "of", "spaces"), tokens);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice test!

List<String> trainingWords = tokenizer.tokenize(text);

// TODO: Convert the trainingWords into neighborMap here
this.neighborMap = new HashMap<String, List<String>>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You can use <> here and Java will infer the generics

Comment on lines +56 to +66
for(int i = 0; i< trainingWords.size() - 1; i++){
String key = trainingWords.get(i);
if(!this.neighborMap.containsKey(key)){
List<String> mapped = new ArrayList<>();
for(int j = 0; j < trainingWords.size() - 1; j++){
if(trainingWords.get(j).equals(key) && j != trainingWords.size() - 1){
mapped.add(trainingWords.get(j+1));
}
}
this.neighborMap.put(key, mapped);
}
Copy link
Copy Markdown

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 +119 to +123
// This lad is chunky
// First, we get the size of the list belonging to a key.
// with this, generate a number using the size of the list
// then we pick a random word in the list using the randomly generated number
return (this.neighborMap.get(word).get(num.nextInt(this.getNeighborMap().get(word).size())));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This logic works, but putting it all on one line makes it pretty hard to read. Consider splitting this up into multiple lines with intermediate variables.

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