Skip to content

Ramblebot Complete#27

Open
bellxalli wants to merge 18 commits intogrc-cohort-21:mainfrom
bellxalli:main
Open

Ramblebot Complete#27
bellxalli wants to merge 18 commits intogrc-cohort-21:mainfrom
bellxalli:main

Conversation

@bellxalli
Copy link

No description provided.

…ptions. Need to fix adding the vlaues to the map
…lues for a key, did math for to find range and generate random number. Used generated number to find preidcted word.
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!

@@ -0,0 +1 @@
standing in the pillow what does it matter anyways she didn't like me anyways she was only let her face in the last of her crawl into my arms but what does it matter anyways i haven't seen the last of her crawl into my arms but she buried her oh, anjela can't stand the pillow what does it matter anyways i wasn't trying to stay warm oh, anjela can't stand the cold and arrangements there was only let her anyways she said, i'm not summer anymore i only thought because she climbed into my arms but she didn't like No newline at end of file

Choose a reason for hiding this comment

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

Beautiful, moving

Comment on lines +45 to +66
if(!word.contains("."))
{
tokenList.add(word);
}

//if period is at the end of the sentence or inside word
else
{
//period at end of sentence
int sLength = word.length()-1;
if(word.charAt(sLength) == '.')
{
String newWord = word.substring(0, sLength);
tokenList.add(newWord);
tokenList.add(".");
}

//period within word
else
{
tokenList.add(word);
}

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 +23 to +30
@Test
void testTokenizeSentenceWithSpaces()
{
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 +68 to +83
for(String key : trainingWords)
{
List<String> valueWords = new ArrayList<>();
List<String> trainingWordsTwo = new ArrayList<>(trainingWords); //copy of trainingwords list so that it can be edited without harming actual data
while(trainingWordsTwo.contains(key)) //loop that finds all of the following words for a key, adds to list, and the removes the instances of the keys until there are no more
{
int followingWordIndex = trainingWordsTwo.indexOf(key) + 1;
if(!(followingWordIndex > trainingWordsTwo.size()-1))
{
String followingWord = trainingWordsTwo.get(followingWordIndex);
valueWords.add(followingWord);
}
trainingWordsTwo.remove(trainingWordsTwo.indexOf(key));
}
//add values to key
neighborMap.put(key, valueWords);

Choose a reason for hiding this comment

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

Interesting approach! Smart to make a copy to avoid mutating the original.

Comment on lines +148 to +156
Random rand = new Random();
int min = 0;
int max = followingWords.size()-1;
int range = max - min + 1;
int randIndex = rand.nextInt(range)+min;

//predicting the new word
String predictedWord = followingWords.get(randIndex);
return predictedWord;

Choose a reason for hiding this comment

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

Great 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