-
Notifications
You must be signed in to change notification settings - Fork 27
Finished rambleBot #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
eb64217
25a6f83
27ec183
fded138
947d852
8b20429
07e432b
a50b483
72b01d0
d5246a1
a332389
556a82e
ad2a1f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Slow down | ||
| Give yourself the run around | ||
| And just hold your horses | ||
| Outlaw external forces | ||
|
|
||
| And float above the boys in the gray suits | ||
| I know you like the rush | ||
| But the comedowns yet to come | ||
|
|
||
| Trudge through the electro madness | ||
| Buckle bunny Im behind you | ||
| Those machines for killing fascists | ||
| They dont make them like they used to | ||
| And when the comedown catches me | ||
| Before I catch myself | ||
|
|
||
| Ride them in my baby | ||
| Dont you try to save me | ||
|
|
||
| And float above the boys in the gray suits | ||
| I know you like the rush | ||
| But the comedowns yet to come | ||
|
|
||
| Trudge through the electro madness | ||
| Buckle bunny Im behind you | ||
| Those machines for killing sadness | ||
| They dont make them like they used to | ||
| And when the comedown catches me | ||
| Before I catch myself | ||
|
|
||
| Ride them in my baby | ||
| Dont you try to save me | ||
|
|
||
| Youll never crack my crescendo | ||
| Vanta blackout with my soul sister | ||
| Through the false love out the window | ||
| Tie me down forever and a day I dont care | ||
|
|
||
| Youll never crack my crescendo | ||
| Vanta blackout with my soul sister | ||
| Through the false love out the window | ||
| Tie me down forever and a day I dont care | ||
|
|
||
| Honeymoon radiation | ||
| Im gonna burn it down for good | ||
| Go for broke, as country folk | ||
| Never thinking about if we should | ||
|
|
||
| Honeymoon radiation | ||
| Im gonna burn it down for good | ||
| Go for broke, as country folk | ||
| Never thinking about if we should | ||
|
|
||
| Youll never crack my crescendo | ||
| Vanta blackout with my soul sister | ||
| Through the false love out the window | ||
| Tie me down forever and a day I dont care |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| slow down forever and float above the comedown catches me down for good go for broke, | ||
| as country folk never crack my crescendo vanta blackout with my crescendo vanta blackout | ||
| with my baby dont care youll never crack my soul sister through the electro madness buckle bunny | ||
| im behind you like they dont you like the window tie me before i catch myself ride them | ||
| like the false love out the false love out the boys in the false love out the rush but the | ||
| gray suits i catch myself ride them like the false love out the window tie me and when the | ||
| rush but the window tie me and float above the boys in the false love out the rush but the | ||
| comedowns yet to and when the comedown catches me down forever and float above the false love | ||
| out the gray suits i dont care honeymoon radiation | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Scanner; | ||
|
|
||
|
|
@@ -30,7 +31,26 @@ public class LowercaseSentenceTokenizer implements Tokenizer { | |
| */ | ||
| public List<String> tokenize(Scanner scanner) { | ||
| // TODO: Implement this function to convert the scanner's input to a list of words and periods | ||
| return null; | ||
| List<String> contentList = new ArrayList<>(); | ||
| List<String> result = new ArrayList<>(); | ||
|
|
||
| while (scanner.hasNextLine()) { | ||
| result.add(scanner.next().toLowerCase()); | ||
| } | ||
|
|
||
| for (String str : result) { | ||
| if(str.charAt(str.length()-1) != '.'){ | ||
| contentList.add(str); | ||
| }else{ | ||
| String temp = str.replace('.', ' '); | ||
| contentList.add(temp.replace(" ", "")); | ||
| contentList.add("."); | ||
| } | ||
| } | ||
|
Comment on lines
+34
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great logic! |
||
|
|
||
|
|
||
|
|
||
| return contentList; | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,13 @@ void testTokenizeWithNoCapitalizationOrPeriod() { | |
| } | ||
|
|
||
| // Wave 2 | ||
| /* | ||
| * Write your test here! | ||
| */ | ||
| @Test | ||
| void testTokenWithManySpaces(){ | ||
| LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); | ||
| Scanner scanner = new Scanner("hello hi hi hi hello hello"); | ||
| List<String> token = tokenizer.tokenize(scanner); | ||
| assertEquals(List.of("hello", "hi", "hi", "hi", "hello", "hello"), token); | ||
| } | ||
|
Comment on lines
+19
to
+25
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice test |
||
|
|
||
|
|
||
| // Wave 3 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Random; | ||
| import java.util.Scanner; | ||
|
|
||
| /** | ||
|
|
@@ -49,9 +50,18 @@ public UnigramWordPredictor(Tokenizer tokenizer) { | |
| * @param scanner the Scanner to read the training text from | ||
| */ | ||
| public void train(Scanner scanner) { | ||
| // TODO: Convert the trainingWords into neighborMap here | ||
| neighborMap = new HashMap<>(); | ||
| List<String> trainingWords = tokenizer.tokenize(scanner); | ||
| neighborMap.put(trainingWords.get(0),new ArrayList<>()); | ||
|
|
||
| // TODO: Convert the trainingWords into neighborMap here | ||
| for(int i = 1; i < trainingWords.size(); i++){ | ||
| neighborMap.get(trainingWords.get(i-1)).add(trainingWords.get(i)); | ||
|
|
||
| if(!neighborMap.containsKey(trainingWords.get(i))){ | ||
| neighborMap.put(trainingWords.get(i), new ArrayList<String>()); | ||
| } | ||
| } | ||
|
Comment on lines
+58
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Smart initializing the list in the previous pass |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -101,7 +111,11 @@ public void train(Scanner scanner) { | |
| public String predictNextWord(List<String> context) { | ||
| // TODO: Return a predicted word given the words preceding it | ||
| // Hint: only the last word in context should be looked at | ||
| return null; | ||
| //Random class information gathered at https://www.geeksforgeeks.org/generating-random-numbers-in-java/ | ||
| Random rand = new Random(); | ||
| String lastWord = context.get(context.size()-1); | ||
| int randomStringIndex = rand.nextInt(neighborMap.get(lastWord).size()); | ||
| return neighborMap.get(lastWord).get(randomStringIndex); | ||
|
Comment on lines
+116
to
+118
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice variable names |
||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really makes you think