From 5674da24a828b652b71dc6d2a11ccafaf5e1b00b Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Tue, 21 Jan 2025 11:46:44 -0800 Subject: [PATCH 01/16] testing clone --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e57375e..addb31d 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +TURN SOMETHING IN BY THE DUE DATE EVEN IF YOU'RE NOT FINISHED. + +testing clone! \ No newline at end of file From 483ca0281f3e558a24d231a4b829f5adf76ebb78 Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:49:29 -0800 Subject: [PATCH 02/16] wave 1 tokenizer --- src/LowercaseSentenceTokenizer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/LowercaseSentenceTokenizer.java b/src/LowercaseSentenceTokenizer.java index cc8285d..44cd225 100644 --- a/src/LowercaseSentenceTokenizer.java +++ b/src/LowercaseSentenceTokenizer.java @@ -1,3 +1,4 @@ +import java.util.ArrayList; import java.util.List; import java.util.Scanner; @@ -30,7 +31,12 @@ public class LowercaseSentenceTokenizer implements Tokenizer { */ public List tokenize(Scanner scanner) { // TODO: Implement this function to convert the scanner's input to a list of words and periods - return null; + ArrayList tokens = new ArrayList<>(); + while (scanner.hasNext()) { + tokens.add(scanner.next().toLowerCase()); + tokens.add(scanner.next().toLowerCase()); + } + return tokens; } } From bbb739ef0489c99289017c06bf06a03f8f491e69 Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 27 Jan 2025 10:55:09 -0800 Subject: [PATCH 03/16] wave 2 Space test --- src/LowercaseSentenceTokenizer.java | 2 +- src/LowercaseSentenceTokenizerTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/LowercaseSentenceTokenizer.java b/src/LowercaseSentenceTokenizer.java index 44cd225..0b1146d 100644 --- a/src/LowercaseSentenceTokenizer.java +++ b/src/LowercaseSentenceTokenizer.java @@ -34,7 +34,7 @@ public List tokenize(Scanner scanner) { ArrayList tokens = new ArrayList<>(); while (scanner.hasNext()) { tokens.add(scanner.next().toLowerCase()); - tokens.add(scanner.next().toLowerCase()); + // tokens.add(scanner.next().toLowerCase()); } return tokens; } diff --git a/src/LowercaseSentenceTokenizerTest.java b/src/LowercaseSentenceTokenizerTest.java index 85ac3a2..55cff66 100644 --- a/src/LowercaseSentenceTokenizerTest.java +++ b/src/LowercaseSentenceTokenizerTest.java @@ -19,6 +19,14 @@ void testTokenizeWithNoCapitalizationOrPeriod() { /* * Write your test here! */ + @Test + void testTokenizeWithSpaces(){ + LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); + Scanner scanner = new Scanner("hello hi hi hi hello hello"); + List tokens = tokenizer.tokenize(scanner); + } + + // Wave 3 From bb1517c310ad6258729ce4633b216eb3c24a73b2 Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 27 Jan 2025 11:50:57 -0800 Subject: [PATCH 04/16] LowerCaseTokenizer passing all tests --- src/LowercaseSentenceTokenizer.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/LowercaseSentenceTokenizer.java b/src/LowercaseSentenceTokenizer.java index 0b1146d..d23a27c 100644 --- a/src/LowercaseSentenceTokenizer.java +++ b/src/LowercaseSentenceTokenizer.java @@ -33,7 +33,24 @@ public List tokenize(Scanner scanner) { // TODO: Implement this function to convert the scanner's input to a list of words and periods ArrayList tokens = new ArrayList<>(); while (scanner.hasNext()) { - tokens.add(scanner.next().toLowerCase()); + 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){ + String shortStr = ""; + char[] cArr = token.toCharArray(); + + for(int i=0; i Date: Mon, 27 Jan 2025 12:34:04 -0800 Subject: [PATCH 05/16] saving work for train() --- src/LowercaseSentenceTokenizer.java | 2 -- src/UnigramWordPredictor.java | 17 +++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/LowercaseSentenceTokenizer.java b/src/LowercaseSentenceTokenizer.java index d23a27c..06724fc 100644 --- a/src/LowercaseSentenceTokenizer.java +++ b/src/LowercaseSentenceTokenizer.java @@ -50,8 +50,6 @@ public List tokenize(Scanner scanner) { }else{tokens.add(token);} - - // tokens.add(scanner.next().toLowerCase()); } return tokens; } diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index d713250..31f0774 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -1,5 +1,6 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Scanner; @@ -50,8 +51,24 @@ public UnigramWordPredictor(Tokenizer tokenizer) { */ public void train(Scanner scanner) { List trainingWords = tokenizer.tokenize(scanner); + List temp = new LinkedList<>(); // TODO: Convert the trainingWords into neighborMap here + neighborMap = new HashMap<>(); + for(int i=0; i Date: Mon, 27 Jan 2025 13:21:04 -0800 Subject: [PATCH 06/16] Finally got train method passing first test. It took a long time to figure out I was itteration on i in my second loop instead of j. Also fixed the issue with tempVals not clearing after a key was finished. --- src/LowercaseSentenceTokenizer.java | 1 - src/UnigramWordPredictor.java | 25 +++++++++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/LowercaseSentenceTokenizer.java b/src/LowercaseSentenceTokenizer.java index 06724fc..f29d078 100644 --- a/src/LowercaseSentenceTokenizer.java +++ b/src/LowercaseSentenceTokenizer.java @@ -41,7 +41,6 @@ public List tokenize(Scanner scanner) { if(token.lastIndexOf(".") == token.length()-1){ String shortStr = ""; char[] cArr = token.toCharArray(); - for(int i=0; i trainingWords = tokenizer.tokenize(scanner); - List temp = new LinkedList<>(); - + List tempVals; + // TODO: Convert the trainingWords into neighborMap here neighborMap = new HashMap<>(); for(int i=0; i(); + //find the token and add the next word to tempVals + for(int j=0; j Date: Mon, 27 Jan 2025 14:00:34 -0800 Subject: [PATCH 07/16] all Tests passing pridict next words is working. I'm still confused why we are using a List to pass in context rather than a word. --- src/UnigramWordPredictor.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index a6a82fa..ac41717 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -4,6 +4,7 @@ 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. @@ -72,12 +73,7 @@ public void train(Scanner scanner) { //add in the token, and list of values stored neighborMap.put(mKey, tempVals); } - } - - - - } /** @@ -125,9 +121,18 @@ public void train(Scanner scanner) { * @return the predicted next word, or null if no prediction can be made */ public String predictNextWord(List context) { + List vals = new ArrayList<>(); + String lastWord = context.get(context.size()-1); + 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; } /** From 5ff575a795dd415c2ce64fcace999859f03e3298 Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:01:17 -0800 Subject: [PATCH 08/16] forgot to save before commit --- src/UnigramWordPredictor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index ac41717..0ed6e04 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -123,6 +123,7 @@ public void train(Scanner scanner) { public String predictNextWord(List context) { List vals = new ArrayList<>(); 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 From 6ad6d5f523767d191a7303c2b26b7930732026d4 Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Mon, 27 Jan 2025 14:45:34 -0800 Subject: [PATCH 09/16] testing with new data files --- GeminiKeats.txt | 5 ++ InaguralAddress.txt | 161 ++++++++++++++++++++++++++++++++++++++++++++ ramblebotOutput.txt | 0 3 files changed, 166 insertions(+) create mode 100644 GeminiKeats.txt create mode 100644 InaguralAddress.txt create mode 100644 ramblebotOutput.txt diff --git a/GeminiKeats.txt b/GeminiKeats.txt new file mode 100644 index 0000000..336aceb --- /dev/null +++ b/GeminiKeats.txt @@ -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. \ No newline at end of file diff --git a/InaguralAddress.txt b/InaguralAddress.txt new file mode 100644 index 0000000..b6a7a3d --- /dev/null +++ b/InaguralAddress.txt @@ -0,0 +1,161 @@ +Thank you. Thank you very much, everybody. (Applause.) Wow. Thank you very, very much. + +From this day forward, our country will flourish and be respected again all over the world. We will be the envy of every nation, and we will not allow ourselves to be taken advantage of any longer. During every single day of the Trump administration, I will, very simply, put America first. (Applause.) Our sovereignty will be reclaimed. Our safety will be restored. The scales of justice will be rebalanced. The vicious, violent, and unfair weaponization of the Justice Department and our government will end. (Applause.) And our top priority will be to create a nation that is proud, prosperous, and free. (Applause.) America will soon be greater, stronger, and far more exceptional than ever before. (Applause.) I return to the presidency confident and optimistic that we are at the start of a thrilling new era of national success. A tide of change is sweeping the country, sunlight is pouring over the entire world, and America has the chance to seize this opportunity like never before. But first, we must be honest about the challenges we face. While they are plentiful, they will be annihilated by this great momentum that the world is now witnessing in the United States of America. As we gather today, our government confronts a crisis of trust. For many years, a radical and corrupt establishment has extracted power and wealth from our citizens while the pillars of our society lay broken and seemingly in complete disrepair.We now have a government that cannot manage even a simple crisis at home while, at the same time, stumbling into a continuing catalogue of catastrophic events abroad.It fails to protect our magnificent, law-abiding American citizens but provides sanctuary and protection for dangerous criminals, many from prisons and mental institutions, that have illegally entered our country from all over the world. We have a government that has given unlimited funding to the defense of foreign borders but refuses to defend American borders or, more importantly, its own people. + +Our country can no longer deliver basic services in times of emergency, as recently shown by the wonderful people of North Carolina — who have been treated so badly — (applause) — and other states who are still suffering from a hurricane that took place many months ago or, more recently, Los Angeles, where we are watching fires still tragically burn from weeks ago without even a token of defense. They’re raging through the houses and communities, even affecting some of the wealthiest and most powerful individuals in our country — some of whom are sitting here right now. They don’t have a home any longer. That’s interesting. But we can’t let this happen. Everyone is unable to do anything about it. That’s going to change. + +We have a public health system that does not deliver in times of disaster, yet more money is spent on it than any country anywhere in the world. + +And we have an education system that teaches our children to be ashamed of themselves — in many cases, to hate our country despite the love that we try so desperately to provide to them. All of this will change starting today, and it will change very quickly. (Applause.) + +My recent election is a mandate to completely and totally reverse a horrible betrayal and all of these many betrayals that have taken place and to give the people back their faith, their wealth, their democracy, and, indeed, their freedom. From this moment on, America’s decline is over. (Applause.) + +Our liberties and our nation’s glorious destiny will no longer be denied. And we will immediately restore the integrity, competency, and loyalty of America’s government. + +Over the past eight years, I have been tested and challenged more than any president in our 250-year history, and I’ve learned a lot along the way. + +The journey to reclaim our republic has not been an easy one — that, I can tell you. Those who wish to stop our cause have tried to take my freedom and, indeed, to take my life. + +Just a few months ago, in a beautiful Pennsylvania field, an assassin’s bullet ripped through my ear. But I felt then and believe even more so now that my life was saved for a reason. I was saved by God to make America great again. (Applause.) + +Thank you. Thank you. (Applause.) + +Thank you very much. (Applause.) + +That is why each day under our administration of American patriots, we will be working to meet every crisis with dignity and power and strength. We will move with purpose and speed to bring back hope, prosperity, safety, and peace for citizens of every race, religion, color, and creed. + +For American citizens, January 20th, 2025, is Liberation Day. (Applause.) It is my hope that our recent presidential election will be remembered as the greatest and most consequential election in the history of our country. + +As our victory showed, the entire nation is rapidly unifying behind our agenda with dramatic increases in support from virtually every element of our society: young and old, men and women, African Americans, Hispanic Americans, Asian Americans, urban, suburban, rural. And very importantly, we had a powerful win in all seven swing states — (applause) — and the popular vote, we won by millions of people. (Applause.) + +To the Black and Hispanic communities, I want to thank you for the tremendous outpouring of love and trust that you have shown me with your vote. We set records, and I will not forget it. I’ve heard your voices in the campaign, and I look forward to working with you in the years to come. + +Today is Martin Luther King Day. And his honor — this will be a great honor. But in his honor, we will strive together to make his dream a reality. We will make his dream come true. (Applause.) + +Thank you. Thank you. Thank you. (Applause.) + +National unity is now returning to America, and confidence and pride is soaring like never before. In everything we do, my administration will be inspired by a strong pursuit of excellence and unrelenting success. We will not forget our country, we will not forget our Constitution, and we will not forget our God. Can’t do that. (Applause.) + +Today, I will sign a series of historic executive orders. With these actions, we will begin the complete restoration of America and the revolution of common sense. It’s all about common sense. (Applause.) + +First, I will declare a national emergency at our southern border. (Applause.) + +All illegal entry will immediately be halted, and we will begin the process of returning millions and millions of criminal aliens back to the places from which they came. We will reinstate my Remain in Mexico policy. (Applause.) + +I will end the practice of catch and release. (Applause.) + +And I will send troops to the southern border to repel the disastrous invasion of our country. (Applause.) + +Under the orders I sign today, we will also be designating the cartels as foreign terrorist organizations. (Applause.) + +And by invoking the Alien Enemies Act of 1798, I will direct our government to use the full and immense power of federal and state law enforcement to eliminate the presence of all foreign gangs and criminal networks bringing devastating crime to U.S. soil, including our cities and inner cities. (Applause.) + +As commander in chief, I have no higher responsibility than to defend our country from threats and invasions, and that is exactly what I am going to do. We will do it at a level that nobody has ever seen before. + +Next, I will direct all members of my cabinet to marshal the vast powers at their disposal to defeat what was record inflation and rapidly bring down costs and prices. (Applause.) + +The inflation crisis was caused by massive overspending and escalating energy prices, and that is why today I will also declare a national energy emergency. We will drill, baby, drill. (Applause.) + +America will be a manufacturing nation once again, and we have something that no other manufacturing nation will ever have — the largest amount of oil and gas of any country on earth — and we are going to use it. We’ll use it. (Applause.) + +We will bring prices down, fill our strategic reserves up again right to the top, and export American energy all over the world. (Applause.) + +We will be a rich nation again, and it is that liquid gold under our feet that will help to do it. + +With my actions today, we will end the Green New Deal, and we will revoke the electric vehicle mandate, saving our auto industry and keeping my sacred pledge to our great American autoworkers. (Applause.) + +In other words, you’ll be able to buy the car of your choice. + +We will build automobiles in America again at a rate that nobody could have dreamt possible just a few years ago. And thank you to the autoworkers of our nation for your inspiring vote of confidence. We did tremendously with their vote. (Applause.) + +I will immediately begin the overhaul of our trade system to protect American workers and families. Instead of taxing our citizens to enrich other countries, we will tariff and tax foreign countries to enrich our citizens. (Applause.) + +For this purpose, we are establishing the External Revenue Service to collect all tariffs, duties, and revenues. It will be massive amounts of money pouring into our Treasury, coming from foreign sources. + +The American dream will soon be back and thriving like never before. + +To restore competence and effectiveness to our federal government, my administration will establish the brand-new Department of Government Efficiency. (Applause.) + +After years and years of illegal and unconstitutional federal efforts to restrict free expression, I also will sign an executive order to immediately stop all government censorship and bring back free speech to America. (Applause.) + +Never again will the immense power of the state be weaponized to persecute political opponents — something I know something about. (Laughter.) We will not allow that to happen. It will not happen again. + +Under my leadership, we will restore fair, equal, and impartial justice under the constitutional rule of law. (Applause.) + +And we are going to bring law and order back to our cities. (Applause.) + +This week, I will also end the government policy of trying to socially engineer race and gender into every aspect of public and private life. (Applause.) We will forge a society that is colorblind and merit-based. (Applause.) + +As of today, it will henceforth be the official policy of the United States government that there are only two genders: male and female. (Applause.) + +This week, I will reinstate any service members who were unjustly expelled from our military for objecting to the COVID vaccine mandate with full back pay. (Applause.) + +And I will sign an order to stop our warriors from being subjected to radical political theories and social experiments while on duty. It’s going to end immediately. (Applause.) Our armed forces will be freed to focus on their sole mission: defeating America’s enemies. (Applause.) + +Like in 2017, we will again build the strongest military the world has ever seen. We will measure our success not only by the battles we win but also by the wars that we end — and perhaps most importantly, the wars we never get into. (Applause.) + +My proudest legacy will be that of a peacemaker and unifier. That’s what I want to be: a peacemaker and a unifier. + +I’m pleased to say that as of yesterday, one day before I assumed office, the hostages in the Middle East are coming back home to their families. (Applause.) + +Thank you. + +America will reclaim its rightful place as the greatest, most powerful, most respected nation on earth, inspiring the awe and admiration of the entire world. + +A short time from now, we are going to be changing the name of the Gulf of Mexico to the Gulf of America — (applause) — and we will restore the name of a great president, William McKinley, to Mount McKinley, where it should be and where it belongs. (Applause.) + +President McKinley made our country very rich through tariffs and through talent — he was a natural businessman — and gave Teddy Roosevelt the money for many of the great things he did, including the Panama Canal, which has foolishly been given to the country of Panama after the United Spates — the United States — I mean, think of this — spent more money than ever spent on a project before and lost 38,000 lives in the building of the Panama Canal. + +We have been treated very badly from this foolish gift that should have never been made, and Panama’s promise to us has been broken. + +The purpose of our deal and the spirit of our treaty has been totally violated. American ships are being severely overcharged and not treated fairly in any way, shape, or form. And that includes the United States Navy. + +And above all, China is operating the Panama Canal. And we didn’t give it to China. We gave it to Panama, and we’re taking it back. (Applause.) + +Above all, my message to Americans today is that it is time for us to once again act with courage, vigor, and the vitality of history’s greatest civilization. + +So, as we liberate our nation, we will lead it to new heights of victory and success. We will not be deterred. Together, we will end the chronic disease epidemic and keep our children safe, healthy, and disease-free. + +The United States will once again consider itself a growing nation — one that increases our wealth, expands our territory, builds our cities, raises our expectations, and carries our flag into new and beautiful horizons. + +And we will pursue our manifest destiny into the stars, launching American astronauts to plant the Stars and Stripes on the planet Mars. (Applause.) + +Ambition is the lifeblood of a great nation, and, right now, our nation is more ambitious than any other. There’s no nation like our nation. + +Americans are explorers, builders, innovators, entrepreneurs, and pioneers. The spirit of the frontier is written into our hearts. The call of the next great adventure resounds from within our souls. + +Our American ancestors turned a small group of colonies on the edge of a vast continent into a mighty republic of the most extraordinary citizens on Earth. No one comes close. + +Americans pushed thousands of miles through a rugged land of untamed wilderness. They crossed deserts, scaled mountains, braved untold dangers, won the Wild West, ended slavery, rescued millions from tyranny, lifted billions from poverty, harnessed electricity, split the atom, launched mankind into the heavens, and put the universe of human knowledge into the palm of the human hand. If we work together, there is nothing we cannot do and no dream we cannot achieve. + +Many people thought it was impossible for me to stage such a historic political comeback. But as you see today, here I am. The American people have spoken. (Applause.) + +I stand before you now as proof that you should never believe that something is impossible to do. In America, the impossible is what we do best. (Applause.) + +From New York to Los Angeles, from Philadelphia to Phoenix, from Chicago to Miami, from Houston to right here in Washington, D.C., our country was forged and built by the generations of patriots who gave everything they had for our rights and for our freedom. + +They were farmers and soldiers, cowboys and factory workers, steelworkers and coal miners, police officers and pioneers who pushed onward, marched forward, and let no obstacle defeat their spirit or their pride. + +Together, they laid down the railroads, raised up the skyscrapers, built great highways, won two world wars, defeated fascism and communism, and triumphed over every single challenge that they faced. + +After all we have been through together, we stand on the verge of the four greatest years in American history. With your help, we will restore America promise and we will rebuild the nation that we love — and we love it so much. + +We are one people, one family, and one glorious nation under God. So, to every parent who dreams for their child and every child who dreams for their future, I am with you, I will fight for you, and I will win for you. We’re going to win like never before. (Applause.) + +Thank you. Thank you. (Applause.) + +Thank you. Thank you. (Applause.) + +In recent years, our nation has suffered greatly. But we are going to bring it back and make it great again, greater than ever before. + +We will be a nation like no other, full of compassion, courage, and exceptionalism. Our power will stop all wars and bring a new spirit of unity to a world that has been angry, violent, and totally unpredictable. + +America will be respected again and admired again, including by people of religion, faith, and goodwill. We will be prosperous, we will be proud, we will be strong, and we will win like never before. + +We will not be conquered, we will not be intimidated, we will not be broken, and we will not fail. From this day on, the United States of America will be a free, sovereign, and independent nation. + +We will stand bravely, we will live proudly, we will dream boldly, and nothing will stand in our way because we are Americans. The future is ours, and our golden age has just begun. + +Thank you. God bless America. Thank you all. Thank you. (Applause.) Thank you very much. Thank you very much. Thank you. (Applause.) + +Thank you. (Applause.) \ No newline at end of file diff --git a/ramblebotOutput.txt b/ramblebotOutput.txt new file mode 100644 index 0000000..e69de29 From befbb47fc0bb4bdb83ef1d9227098b40db353dbb Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Wed, 29 Jan 2025 09:51:54 -0800 Subject: [PATCH 10/16] testing output --- ramblebotOutput.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ramblebotOutput.txt b/ramblebotOutput.txt index e69de29..6100f54 100644 --- a/ramblebotOutput.txt +++ b/ramblebotOutput.txt @@ -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 . From a9c7fc1a88dd0759270c0244490d3e600636e5ad Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:02:49 -0800 Subject: [PATCH 11/16] testing map --- src/LowercaseSentenceTokenizerTest.java | 1 + src/RambleApp.java | 1 + src/UnigramWordPredictor.java | 11 +++++++---- src/UnigramWordPredictorTest.java | 1 + test.txt | 1 + 5 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 test.txt diff --git a/src/LowercaseSentenceTokenizerTest.java b/src/LowercaseSentenceTokenizerTest.java index 55cff66..6bbf504 100644 --- a/src/LowercaseSentenceTokenizerTest.java +++ b/src/LowercaseSentenceTokenizerTest.java @@ -24,6 +24,7 @@ void testTokenizeWithSpaces(){ LowercaseSentenceTokenizer tokenizer = new LowercaseSentenceTokenizer(); Scanner scanner = new Scanner("hello hi hi hi hello hello"); List tokens = tokenizer.tokenize(scanner); + assertEquals(List.of("hello", "hi", "hi", "hi", "hello", "hello"), tokens); } diff --git a/src/RambleApp.java b/src/RambleApp.java index dea00c1..14c78d2 100644 --- a/src/RambleApp.java +++ b/src/RambleApp.java @@ -163,5 +163,6 @@ public static void main(String[] args) { RambleApp app = new RambleApp(tokenizer, predictor, inputScanner); app.run(); + } } diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index 0ed6e04..c980ac4 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -63,17 +63,20 @@ public void train(Scanner scanner) { //check if the token has been completed and added. if(!neighborMap.containsKey(mKey)){ - tempVals = new ArrayList<>(); + tempVals = new LinkedList<>(); //find the token and add the next word to tempVals for(int j=0; j context) { - List vals = new ArrayList<>(); + List 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(); @@ -151,7 +154,7 @@ public Map> getNeighborMap() { List newList = new ArrayList<>(entry.getValue()); copy.put(entry.getKey(), newList); } - + System.out.println(copy); return copy; } } diff --git a/src/UnigramWordPredictorTest.java b/src/UnigramWordPredictorTest.java index 08618a3..a6678c3 100644 --- a/src/UnigramWordPredictorTest.java +++ b/src/UnigramWordPredictorTest.java @@ -52,6 +52,7 @@ void testTrainAndGetNeighborMap() { ); assertEquals(expectedMap, neighborMap); + System.out.println(neighborMap); } // Wave 5 diff --git a/test.txt b/test.txt new file mode 100644 index 0000000..4963abb --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +a b c 1 a 1 b 1 c \ No newline at end of file From b5191a52b18b66d41444ba1fa11d4b7e603d8bfc Mon Sep 17 00:00:00 2001 From: JACOB_WOODBURY <166659344+JacobWoodbury@users.noreply.github.com> Date: Wed, 29 Jan 2025 10:52:11 -0800 Subject: [PATCH 12/16] Fixed my if statement bug --- src/UnigramWordPredictor.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index c980ac4..0f35b8a 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -53,7 +53,7 @@ public UnigramWordPredictor(Tokenizer tokenizer) { public void train(Scanner scanner) { List trainingWords = tokenizer.tokenize(scanner); List tempVals; - + System.out.println(trainingWords); // TODO: Convert the trainingWords into neighborMap here neighborMap = new HashMap<>(); for(int i=0; i(); //find the token and add the next word to tempVals for(int j=0; j Date: Wed, 29 Jan 2025 11:12:09 -0800 Subject: [PATCH 13/16] cleaning before attempting to make it more efficient --- src/UnigramWordPredictor.java | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index 0f35b8a..5d2eff5 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -53,7 +53,6 @@ public UnigramWordPredictor(Tokenizer tokenizer) { public void train(Scanner scanner) { List trainingWords = tokenizer.tokenize(scanner); List tempVals; - System.out.println(trainingWords); // TODO: Convert the trainingWords into neighborMap here neighborMap = new HashMap<>(); for(int i=0; i(); //find the token and add the next word to tempVals for(int j=0; j Date: Wed, 29 Jan 2025 12:20:52 -0800 Subject: [PATCH 14/16] moving to laptop --- src/UnigramWordPredictor.java | 71 +++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index 5d2eff5..d3e7161 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -52,38 +52,59 @@ public UnigramWordPredictor(Tokenizer tokenizer) { */ public void train(Scanner scanner) { List trainingWords = tokenizer.tokenize(scanner); - List tempVals; + // TODO: Convert the trainingWords into neighborMap here neighborMap = new HashMap<>(); - for(int i=0; i tempVals = new LinkedList<>(); + //update temp with previous values. + + + System.out.println("next word: " + nextWord); + tempVals.add(nextWord); + System.out.println("tempVals: " + tempVals); + + + neighborMap.put(mKey, tempVals); + + + + + + + + + + + + // //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(); - //find the token and add the next word to tempVals - for(int j=0; j Date: Wed, 29 Jan 2025 12:38:54 -0800 Subject: [PATCH 15/16] final resolution --- src/UnigramWordPredictor.java | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index d3e7161..8e8a7e3 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -61,15 +61,14 @@ public void train(Scanner scanner) { String nextWord = trainingWords.get(i+1); List tempVals = new LinkedList<>(); //update temp with previous values. - - - System.out.println("next word: " + nextWord); - tempVals.add(nextWord); - System.out.println("tempVals: " + tempVals); - - - neighborMap.put(mKey, tempVals); - + if(neighborMap.containsKey(mKey)){ + neighborMap.get(mKey).add(nextWord); + }else{ + tempVals.add(nextWord); + neighborMap.put(mKey, tempVals); + } + } + } @@ -105,9 +104,9 @@ public void train(Scanner scanner) { // }else{ // } - } + //System.out.println(getNeighborMap()); - } + /** * Predicts the next word based on the given context. From 9bd5f1c917c93ab37958af6d463ef66c6ad21633 Mon Sep 17 00:00:00 2001 From: Jacob Woodbury <166659344+JacobWoodbury@users.noreply.github.com> Date: Thu, 13 Feb 2025 10:48:21 -0800 Subject: [PATCH 16/16] done --- src/UnigramWordPredictor.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/UnigramWordPredictor.java b/src/UnigramWordPredictor.java index 8e8a7e3..b5f86fb 100644 --- a/src/UnigramWordPredictor.java +++ b/src/UnigramWordPredictor.java @@ -55,11 +55,14 @@ public void train(Scanner 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 tempVals = new LinkedList<>(); + //update temp with previous values. if(neighborMap.containsKey(mKey)){ neighborMap.get(mKey).add(nextWord);