Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions GeminiKeats.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
In emerald groves, where sunlight dappled through the leaves like liquid gold, there dwelt a nymph of surpassing beauty. Her laughter, like the tinkling of crystal streams, echoed through the glades, and the very flowers bowed their heads in admiration as she passed. Her name was Elara, and she was beloved by all the creatures of the forest. The shy fawns would gather at her feet, unafraid, and the birds would weave their sweetest melodies in her honor. Even the mischievous sprites, who delighted in playing tricks on unsuspecting travelers, would never dream of harming a hair on her head.

One day, as Elara wandered through the woods, she came across a clearing bathed in an ethereal light. In the center stood a magnificent tree, its branches laden with blossoms of the purest white. Drawn by an irresistible force, Elara approached the tree and gently touched its bark. A shiver ran through her, and she felt a strange energy coursing through her veins. As she gazed up at the tree's crown, she saw a figure materialize amidst the blossoms. It was a young man, tall and handsome, with eyes that sparkled like the stars. He smiled down at Elara, and she felt her heart quicken with a feeling she had never known before.

The young man introduced himself as Orion, a celestial being who had descended to Earth in search of the most beautiful creature in the land. He had heard tales of Elara's beauty and grace, and he had come to see for himself if the rumors were true. Elara was captivated by Orion's charm and his otherworldly aura. They spent hours talking and laughing, and Elara felt as if she had known him for a lifetime. As the sun began to set, Orion confessed his love for Elara, and she, without hesitation, confessed her love for him. They vowed to meet every day in the clearing, and their love grew stronger with each passing moment.
161 changes: 161 additions & 0 deletions InaguralAddress.txt

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,6 @@ Consider doing any of the following (some are very hard!):
## Submitting
Submit your project by making a PR and copying the link to the canvas assignment.

TURN SOMETHING IN BY THE DUE DATE EVEN IF YOU'RE NOT FINISHED.
TURN SOMETHING IN BY THE DUE DATE EVEN IF YOU'RE NOT FINISHED.

testing clone!
10 changes: 10 additions & 0 deletions ramblebotOutput.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
InaguralAddress

thank you . (applause.) wow . so, as we will flourish and be respected again all over the world . america first . we will flourish and be respected again all over the world . (applause.) wow . soil, including our country will flourish and be respected again all over the world . iâ??m pleased to be respected again all over the world . together, we will flourish and be respected again all over the world . and be respected again all over the world . (applause.) wow . thatâ??s interesting . (applause.) wow . the world . (applause.) wow

--seams like it gets stuck repeating whole phrases(I know the original text is redundant and insubstantial, but the bot was even worse.) I did search on my txt documents for words in the repeating phrases, and it was choosing low priority words way too often. I think something is still off.

Geminis generation based on keats training

in emerald groves, where sunlight dappled through the leaves like liquid gold, there dwelt a nymph of surpassing beauty . they spent hours talking and the leaves like liquid gold, there dwelt a nymph of
surpassing beauty . he smiled down at her laughter, like liquid gold, there dwelt a nymph of surpassing beauty . one day, as she passed . the leaves like liquid gold, there dwelt a nymph of surpassing beauty . in emerald groves, where sunlight dappled through the leaves like liquid gold, there dwelt a nymph of surpassing beauty . they spent hours talking and the leaves like liquid gold, there dwelt a nymph of surpassing beauty . in emerald groves, where sunlight dappled through the leaves like liquid gold, there dwelt a nymph of surpassing beauty . they spent hours talking and the leaves like liquid gold, there dwelt a nymph of surpassing beauty .
22 changes: 21 additions & 1 deletion src/LowercaseSentenceTokenizer.java
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;

Expand Down Expand Up @@ -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;
ArrayList<String> tokens = 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 where appropriate (List)

while (scanner.hasNext()) {
String token = scanner.next().toLowerCase();
//I was struggling to remember what symbol means any character. I started to realize ".contains()" wasn't the right choice.
//I started searching the matches method on w3Schools and came across the lastIndexOf() Method
//https://www.w3schools.com/java/ref_string_lastindexof.asp

if(token.lastIndexOf(".") == token.length()-1){
Comment on lines +38 to +41
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, this works! You could also consider using endsWith

String shortStr = "";
char[] cArr = token.toCharArray();
for(int i=0; i<token.length()-1; i++){
shortStr += cArr[i];
}
tokens.add(shortStr);
tokens.add(".");

}else{tokens.add(token);}

}
return tokens;
}
}

9 changes: 9 additions & 0 deletions src/LowercaseSentenceTokenizerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ void testTokenizeWithNoCapitalizationOrPeriod() {
/*
* Write your test here!
*/
@Test
void testTokenizeWithSpaces(){
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);
}
Comment on lines +22 to +28
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!





// Wave 3
Expand Down
1 change: 1 addition & 0 deletions src/RambleApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -163,5 +163,6 @@ public static void main(String[] args) {

RambleApp app = new RambleApp(tokenizer, predictor, inputScanner);
app.run();

}
}
75 changes: 71 additions & 4 deletions src/UnigramWordPredictor.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Random;

/**
* A class for predicting the next word in a sequence using a unigram model.
Expand Down Expand Up @@ -50,9 +52,64 @@ public UnigramWordPredictor(Tokenizer tokenizer) {
*/
public void train(Scanner scanner) {
List<String> trainingWords = tokenizer.tokenize(scanner);

// TODO: Convert the trainingWords into neighborMap here
}
neighborMap = new HashMap<>();


for(int i=0; i < trainingWords.size()-1; i++){
//create a variable to store map keys and next word.
String mKey = trainingWords.get(i);
String nextWord = trainingWords.get(i+1);
List<String> tempVals = new LinkedList<>();

//update temp with previous values.
if(neighborMap.containsKey(mKey)){
neighborMap.get(mKey).add(nextWord);
}else{
tempVals.add(nextWord);
neighborMap.put(mKey, tempVals);
}
}
Comment on lines +60 to +73
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 logic!

}










// //check if the token has been completed and added.
// if(!neighborMap.containsKey(mKey)){

// tempVals = new LinkedList<>();
// //find the token and add the next word to tempVals
// for(int j=0; j<trainingWords.size(); j++){

// //this little if statement was a nightmare for me. I wasn't failing any tests, but my map wasn't correct. I'm not sure if there is a bug in the test
// //I used 12 println statements with descriptions and variables and finally realized my if statement was running false when it should be true.
// //you can probably guess what I did wrong but I could not figure out why it was false. I finally found someone on stack overflow with a similar issue.
// //I forgot Strings are objects and I needed to use .equals() rather than ==
// if(mKey.equals(trainingWords.get(j)) && j != (trainingWords.size()-1)){
// tempVals.add(trainingWords.get(j+1));

// //System.out.println("updating " + mKey + " with " + trainingWords.get(j+1));
// //System.out.println(mKey + " = " + tempVals + " " + i + " " + j);
// }

// }
// //add in the token, and list of values stored
// neighborMap.put(mKey, tempVals);

// }else{

// }

//System.out.println(getNeighborMap());


/**
* Predicts the next word based on the given context.
Expand Down Expand Up @@ -99,9 +156,19 @@ public void train(Scanner scanner) {
* @return the predicted next word, or null if no prediction can be made
*/
public String predictNextWord(List<String> context) {
List<String> vals = new LinkedList<>();
String lastWord = context.get(context.size()-1);
// random number research: https://www.tutorialspoint.com/java/util/random_nextint_inc_exc.htm
Random picker = new Random();
String choice ="";
// TODO: Return a predicted word given the words preceding it
if(neighborMap.containsKey(lastWord)){
vals = neighborMap.get(lastWord);
choice = vals.get(picker.nextInt(vals.size()));
}

// Hint: only the last word in context should be looked at
return null;
return choice;
Comment on lines 158 to +171
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!

}

/**
Expand All @@ -119,7 +186,7 @@ public Map<String, List<String>> getNeighborMap() {
List<String> newList = new ArrayList<>(entry.getValue());
copy.put(entry.getKey(), newList);
}

System.out.println(copy);
return copy;
}
}
1 change: 1 addition & 0 deletions src/UnigramWordPredictorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void testTrainAndGetNeighborMap() {
);

assertEquals(expectedMap, neighborMap);
System.out.println(neighborMap);
}

// Wave 5
Expand Down
1 change: 1 addition & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
a b c 1 a 1 b 1 c