Add exercises 19

Signed-off-by: Manuel Vergara <manuel@vergaracarmona.es>
This commit is contained in:
Manuel Vergara 2023-10-01 00:39:09 +02:00
parent 7f6426e0ee
commit b86c542424
12 changed files with 162123 additions and 1 deletions

View File

@ -0,0 +1,351 @@
"""
01_files.py
"""
import os
import json
import nltk
import re
from data.stop_words import stop_words
# Ejercicio: Nivel 1
# 1. Escribe una función que cuente el número
# de líneas y palabras en un texto.
# Todos los archivos se encuentran en la carpeta [data](./data)):
def contar_lineas_palabras(archivo):
with open(archivo, 'r') as f:
lineas = f.readlines()
f.seek(0)
palabras = f.read().split()
# Contar palabras
resultado = f'tiene {len(lineas)} lineas y {len(palabras)} palabras\n'
return resultado
# a) Lee el archivo obama_speech.txt
# y cuenta el número de líneas y palabras
print(
f"El discurso de Obama {contar_lineas_palabras('data/obama_speech.txt')}")
# b) Lee el archivo michelle_obama_speech.txt
# y cuenta el número de líneas y palabras
print(
f"El discurso de Michelle {contar_lineas_palabras('data/michelle_obama_speech.txt')}")
# c) Lee el archivo donald_speech.txt
# y cuenta el número de líneas y palabras
print(
f"El discurso de Donald {contar_lineas_palabras('data/donald_speech.txt')}")
# d) Lee el archivo melina_trump_speech.txt
# y cuenta el número de líneas y palabras
print(
f"El discurso de Melina {contar_lineas_palabras('data/melina_trump_speech.txt')}")
# 2. Lee el archivo de datos countries_data.json
# en el directorio data,
# crea una función que encuentre
# los diez idiomas más hablados.
def diez_idiomas_mas_hablados():
archivo = 'data/countries_data.json'
with open(archivo, 'r') as f:
data = json.load(f)
idiomas = []
for pais in data:
idiomas.extend(pais['languages'])
# Contamos la frecuencia de cada idioma
idiomas_freq = {}
for idioma in idiomas:
if idioma in idiomas_freq:
idiomas_freq[idioma] += 1
else:
idiomas_freq[idioma] = 1
# Ordenamos los idiomas por frecuencia
# y tomamos los 10 más comunes
diez_idiomas = sorted(
idiomas_freq.items(),
key=lambda x: x[1],
reverse=True
)[:10]
# Creamos una lista de tuplas
# que contengan el nombre del idioma
# y el número de países en los que se habla
resultado = []
for idioma, frecuencia in diez_idiomas:
resultado.append((idioma, frecuencia))
return resultado
for idioma, frecuencia in diez_idiomas_mas_hablados():
print(f"{idioma} se habla en {frecuencia} paises")
print()
# 3. Lee el archivo de datos countries_data.json
# en el directorio data,
# crea una función que genere
# una lista de los diez países más poblados.
def diez_paises_mas_poblados():
archivo = 'data/countries_data.json'
with open(archivo, 'r') as f:
data = json.load(f)
paises = []
for pais in data:
paises.append((pais['name'], pais['population']))
# Ordenamos los paises por población
# y tomamos los 10 más poblados
diez_paises = sorted(
paises,
key=lambda x: x[1],
reverse=True
)[:10]
resultado = []
for pais, poblacion in diez_paises:
poblacion_millones = poblacion / 1000000
resultado.append((pais, poblacion_millones))
return resultado
for pais, poblacion in diez_paises_mas_poblados():
print(f"{pais} tiene {poblacion:.2f} millones de habitantes")
print()
# Ejercicios: Nivel 2
# 1. Extrae todas las direcciones
# de correo electrónico entrantes
# como una lista del archivo
# email_exchange_big.txt.
def extraer_correos():
archivo = 'data/email_exchanges_big.txt'
with open(archivo, 'r') as f:
lineas = f.readlines()
correos = {}
for linea in lineas:
if linea.startswith('From '):
correo = linea.split()[1]
if correo in correos:
correos[correo] += 1
else:
correos[correo] = 1
return correos
for correo, frecuencia in extraer_correos().items():
print(f"{correo} envió {frecuencia} correos")
print()
# 2. Encuentra las palabras más comunes
# en el idioma inglés.
# Llama a tu función encontrar_palabras_mas_comunes,
# tomará dos parámetros:
# una cadena o un archivo
# y un número entero positivo
# que indicará la cantidad de palabras.
# Tu función devolverá una lista de tuplas
# en orden descendente.
def encontrar_palabras_mas_comunes(archivo, n):
with open(archivo, 'r') as f:
palabras = f.read().split()
# Etiquetamos cada palabra con su POS
palabras_pos = nltk.pos_tag(palabras)
# Filtramos las palabras que sean sustantivos o verbos
palabras_filtradas = []
for palabra, pos in palabras_pos:
if pos.startswith('N') or pos.startswith('V'):
palabras_filtradas.append(palabra)
# Contamos las palabras filtradas
palabras_freq = {}
for palabra in palabras_filtradas:
if palabra in palabras_freq:
palabras_freq[palabra] += 1
else:
palabras_freq[palabra] = 1
# Ordenamos las palabras por frecuencia
# y tomamos las n más comunes
n_palabras = sorted(
palabras_freq.items(),
key=lambda x: x[1],
reverse=True
)[:n]
# Creamos una lista de tuplas
# que contengan el nombre de la palabra
# y el número de veces que aparece
resultado = []
for palabra, frecuencia in n_palabras:
resultado.append((palabra, frecuencia))
return resultado
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/romeo_and_juliet.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# 3. Utiliza la función encontrar_palabras_mas_comunes para encontrar:
# a) Las diez palabras más frecuentes utilizadas en el discurso de Obama
print('Las diez palabras más frecuentes utilizadas en el discurso de Obama')
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/obama_speech.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# b) Las diez palabras más frecuentes utilizadas en el discurso de Michelle
print('Las diez palabras más frecuentes utilizadas en el discurso de Michelle')
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/michelle_obama_speech.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# d) Las diez palabras más frecuentes utilizadas en el discurso de Melina
print('Las diez palabras más frecuentes utilizadas en el discurso de Melina')
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/melina_trump_speech.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# c) Las diez palabras más frecuentes utilizadas en el discurso de Trump
print('Las diez palabras más frecuentes utilizadas en el discurso de Trump')
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/donald_speech.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# 4. Escribe una aplicación Python
# que verifique la similitud entre dos textos.
# Toma un archivo o una cadena como parámetro
# y evaluará la similitud entre los dos textos.
# Es posible que necesites un par de funciones:
# una para limpiar el texto (limpiar_texto),
# una para eliminar las palabras de soporte
# (eliminar_palabras_soporte)
# y finalmente para verificar la similitud
# (verificar_similitud_texto).
# La lista de palabras de paro
# se encuentra en el directorio data.
def limpiar_texto(texto):
# Convertir todo a minúsculas
texto = texto.lower()
# Eliminar caracteres no alfabéticos
texto = re.sub(r'[^a-záéíóúñ]', ' ', texto)
# Eliminar espacios en blanco adicionales
texto = re.sub(r'\s+', ' ', texto)
return texto.strip()
def eliminar_palabras_soporte(texto, palabras_soporte):
palabras = texto.split()
palabras_filtradas = [
palabra for palabra in palabras if palabra not in palabras_soporte]
return ' '.join(palabras_filtradas)
def verificar_similitud_texto(texto1, texto2, palabras_soporte):
texto1 = limpiar_texto(texto1)
texto2 = limpiar_texto(texto2)
texto1 = eliminar_palabras_soporte(texto1, palabras_soporte)
texto2 = eliminar_palabras_soporte(texto2, palabras_soporte)
palabras1 = set(texto1.split())
palabras2 = set(texto2.split())
similitud = len(palabras1 & palabras2) / len(palabras1 | palabras2)
return similitud
# Leer los archivos de texto
with open('./data/michelle_obama_speech.txt', 'r') as f:
texto1 = f.read()
with open('./data/melina_trump_speech.txt', 'r') as f:
texto2 = f.read()
# Calcular la similitud entre los textos
similitud = verificar_similitud_texto(texto1, texto2, stop_words)
# Mostrar el resultado como un porcentaje
porcentaje_similitud = similitud * 100
print(f"La similitud entre los textos es de un {porcentaje_similitud:.2f}%\n")
# 5. Encuentra las 10 palabras más repetidas en romeo_and_juliet.txt.
for palabra, frecuencia in encontrar_palabras_mas_comunes('data/romeo_and_juliet.txt', 10):
print(f"\"{palabra}\" aparece {frecuencia} veces")
print()
# 6. Lee el archivo CSV de hacker news y averigua:
def contar_lineas(palabra):
archivo = 'data/hacker_news.csv'
with open(archivo, 'r') as f:
lineas = f.readlines()
contador = 0
for linea in lineas:
if palabra in linea:
contador += 1
return contador
# a) Cuántas líneas contienen python o Python
contador_python = contar_lineas('python') + contar_lineas('Python')
print(
f"El archivo contiene {contador_python} líneas que contienen 'python' o 'Python'.")
# b) Cuántas líneas contienen JavaScript, javascript o Javascript
contador_javascript = contar_lineas(
'JavaScript') + contar_lineas('javascript') + contar_lineas('Javascript')
print(
f"El archivo contiene {contador_javascript} líneas que contienen 'JavaScript', 'javascript' o 'Javascript'.")
# c) Cuántas líneas contienen Java y no JavaScript
contador_java = contar_lineas('Java')
contador_javascript = contar_lineas(
'JavaScript') + contar_lineas('Javascript')
contador_java_sin_javascript = contador_java - contador_javascript
print(
f"El archivo contiene {contador_java_sin_javascript} líneas que contienen 'Java' pero no 'JavaScript', 'javascript' o 'Javascript'.")

View File

@ -6,7 +6,7 @@ Documento original en inglés: [file handling](https://github.com/Asabeneh/30-Da
### Ejercicios: Nivel 1 ### Ejercicios: Nivel 1
1. Escribe una función que cuente el número de líneas y palabras en un texto. Todos los archivos se encuentran en la carpeta data: 1. Escribe una función que cuente el número de líneas y palabras en un texto. Todos los archivos se encuentran en la carpeta [data](./data):
a) Lee el archivo obama_speech.txt y cuenta el número de líneas y palabras a) Lee el archivo obama_speech.txt y cuenta el número de líneas y palabras
b) Lee el archivo michelle_obama_speech.txt y cuenta el número de líneas y palabras b) Lee el archivo michelle_obama_speech.txt y cuenta el número de líneas y palabras
c) Lee el archivo donald_speech.txt y cuenta el número de líneas y palabras c) Lee el archivo donald_speech.txt y cuenta el número de líneas y palabras
@ -110,4 +110,6 @@ a) Cuántas líneas contienen python o Python
b) Cuántas líneas contienen JavaScript, javascript o Javascript b) Cuántas líneas contienen JavaScript, javascript o Javascript
c) Cuántas líneas contienen Java y no JavaScript c) Cuántas líneas contienen Java y no JavaScript
[Solución](01_files.py)
[<< Day 18](../18_Expresiones_regulares/README.md) | [Day 20 >>](../20_Gestor_de_paquetes_de_Python/README.md) [<< Day 18](../18_Expresiones_regulares/README.md) | [Day 20 >>](../20_Gestor_de_paquetes_de_Python/README.md)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,48 @@
Chief Justice Roberts, President Carter, President Clinton,President Bush, fellow Americans and people of the world thank you.
We the citizens of America have now joined a great national effort to rebuild our county and restore its promise for all our people.
Together we will determine the course of America for many, many years to come.
Together we will face challenges. We will confront hardships. But we will get the job done.
Every four years we gather on these steps to carry out the orderly and peaceful transfer of power.
And we are grateful to President Obama and First Lady Michelle Obama for their gracious aid throughout this transition. They have been magnificent, thank you.
Todays ceremony, however, has very special meaning because today we are not merely transferring power from one administration to another but transferring it from Washington DC and giving it back to you the people.
For too long a small group in our nations capital has reaped the rewards of government while the people have borne the cost.
Washington flourished but the people did not share in its wealth. Politicians prospered but the jobs left and the factories closed.The establishment protected itself but not the citizens of our country.
Their victories have not been your victories. Their triumphs have not been your triumphs. While they have celebrated there has been little to celebrate for struggling families all across our land.
That all changes starting right here and right now because this moment is your moment. It belongs to you. It belongs to everyone gathered here today and everyone watching all across America today.
This is your day.This is your celebration.And this the United States of America is your country.What truly matters is not what party controls our government but that this government is controlled by the people.
Today, January 20 2017, will be remembered as the day the people became the rulers of this nation again.The forgotten men and women of our country will be forgotten no longer. Everyone is listening to you now.
You came by the tens of millions to become part of a historic movement the likes of which the world has never seen before.
At the centre of this movement is a crucial conviction that a nation exists to serve its citizens.Americans want great schools for their children, safe neighbourhoods for their families and good jobs for themselves.
These are just and reasonable demands.Mothers and children trapped in poverty in our inner cities, rusted out factories scattered like tombstones across the landscape of our nation.
An education system flushed with cash, but which leaves our young and beautiful students deprived of all knowledge. And the crime and the gangs and the drugs which deprive people of so much unrealised potential.
We are one nation, and their pain is our pain, their dreams are our dreams, we share one nation, one home and one glorious destiny.
Today I take an oath of allegiance to all Americans. For many decades, weve enriched foreign industry at the expense of American industry, subsidised the armies of other countries, while allowing the sad depletion of our own military.
We've defended other nations borders while refusing to defend our own.And spent trillions and trillions of dollars overseas while Americas infrastructure has fallen into disrepair and decay.
We have made other countries rich while the wealth, strength and confidence of our country has dissipated over the horizon.
One by one, shutters have closed on our factories without even a thought about the millions and millions of those who have been left behind.
But that is the past and now we are looking only to the future.
We assembled here today are issuing a new decree to be heard in every city, in every foreign capital, in every hall of power from this day on a new vision will govern our land from this day onwards it is only going to be America first America first!
Every decision on trade, on taxes, on immigration, on foreign affairs will be made to benefit American workers and American families.
Protection will lead to great prosperity and strength. I will fight for you with every bone in my body and I will never ever let you down.
America will start winning again. America will start winning like never before.
We will bring back our jobs, we will bring back our borders, we will bring back our wealth, we will bring back our dreams.
We will bring new roads and high roads and bridges and tunnels and railways all across our wonderful nation.
We will get our people off welfare and back to work rebuilding our country with American hands and American labour.
We will follow two simple rules buy American and hire American.
We see good will with the nations of the world but we do so with the understanding that it is the right of all nations to put their nations first.
We will shine for everyone to follow.We will reinforce old alliances and form new ones, and untie the world against radical Islamic terrorism which we will eradicate from the face of the earth.
At the bed rock of our politics will be an allegiance to the United States.And we will discover new allegiance to each other. There is no room for prejudice.
The bible tells us how good and pleasant it is when gods people live together in unity.When America is united, America is totally unstoppable
There is no fear, we are protected and will always be protected by the great men and women of our military and most importantly we will be protected by god.
Finally, we must think big and dream even bigger. As Americans, we know we live as a nation only when it is striving.
We will no longer accept politicians who are always complaining but never doing anything about it.The time for empty talk is over, now arrives the hour of action.
Do not allow anyone to tell you it cannot be done. No challenge can match the heart and fight and spirit of America. We will not fail, our country will thrive and prosper again.
We stand at the birth of a new millennium, ready to unlock the mysteries of space, to free the earth from the miseries of disease, to harvest the energies, industries and technologies of tomorrow.
A new national pride will stir ourselves, lift our sights and heal our divisions. Its time to remember that old wisdom our soldiers will never forget, that whether we are black or brown or white, we all bleed the same red blood of patriots.
We all enjoy the same glorious freedoms and we all salute the same great American flag and whether a child is born in the urban sprawl of Detroit or the windswept plains of Nebraska, they look at the same night sky, and dream the same dreams, and they are infused with the breath by the same almighty creator.
So to all Americans in every city near and far, small and large, from mountain to mountain, from ocean to ocean hear these words you will never be ignored again.
Your voice, your hopes and dreams will define your American destiny.Your courage, goodness and love will forever guide us along the way.
Together we will make America strong again, we will make America wealthy again, we will make America safe again and yes together we will make America great again.
Thank you.
God bless you.
And god bless America.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,33 @@
Thank you very much. Thank you. You have all been very kind to Donald and me, to our young son Barron, and to our whole family. It's a very nice welcome and we're excited to be with you at this historic convention. I am so proud of your choice for president of the United States, my husband, Donald J. Trump.
And I can assure you, he is moved by this great honor. The 2016 Republican primaries were fierce and started with many candidates, 17 to be exact, and I know that Donald agrees with me when I mention how talented all of them are. They deserve respect and gratitude from all of us.
However, when it comes to my husband, I will say that I am definitely biased, and for good reason.
I have been with Donald for 18 years and I have been aware of his love for this country since we first met. He never had a hidden agenda when it comes to his patriotism, because, like me, he loves this country so much. I was born in Slovenia, a small, beautiful and then-communist country in Central Europe. My sister Ines, who is an incredible woman and a friend, and I were raised by my wonderful parents. My elegant and hard-working mother Amalia introduced me to fashion and beauty. My father Viktor instilled in me a passion for business and travel. Their integrity, compassion and intelligence reflects to this day on me and for my love of family and America.
From a young age, my parents impressed on me the values that you work hard for what you want in life; that your word is your bond and you do what you say and keep your promise; that you treat people with respect. They taught and showed me values and morals in their daily life. That is a lesson that I continue to pass along to our son, and we need to pass those lessons on to the many generations to follow. Because we want our children in this nation to know that the only limit to your achievements is the strength of your dreams and your willingness to work for them.
I am fortunate for my heritage, but also for where it brought me today. I traveled the world while working hard in the incredible arena of fashion. After living and working in Milan and Paris, I arrived in New York City 20 years ago, and I saw both the joys and the hardships of daily life. On July 28, 2006, I was very proud to become a citizen of the United States — the greatest privilege on planet Earth. I cannot, or will not, take the freedoms this country offers for granted. But these freedoms have come with a price so many times. The sacrifices made by our veterans are reminders to us of this. I would like to take this moment to recognize an amazing veteran, the great Sen. Bob Dole. And let us thank all of our veterans in the arena today, and those across our great country. We are all truly blessed to be here. That will never change.
I can tell you with certainty that my husband has been concerned about our country for as long as I have known him. With all of my heart, I know that he will make a great and lasting difference. Donald has a deep and unbounding determination and a never-give-up attitude. I have seen him fight for years to get a project done — or even started — and he does not give up! If you want someone to fight for you and your country, I can assure you, he is the "guy."
He will never, ever, give up. And, most importantly, he will never, ever, let you down. Donald is, and always has been, an amazing leader. Now, he will go to work for you. His achievements speak for themselves, and his performance throughout the primary campaign proved that he knows how to win. He also knows how to remain focused on improving our country — on keeping it safe and secure. He is tough when he has to be but he is also kind and fair and caring. This kindness is not always noted, but it is there for all to see. That is one reason I fell in love with him to begin with.
Donald is intensely loyal. To family, friends, employees, country. He has the utmost respect for his parents, Mary and Fred, to his sisters Maryanne and Elizabeth, to his brother Robert and to the memory of his late brother Fred. His children have been cared for and mentored to the extent that even his adversaries admit they are an amazing testament to who he is as a man and a father. There is a great deal of love in the Trump family. That is our bond, and that is our strength.
Yes, Donald thinks big, which is especially important when considering the presidency of the United States. No room for small thinking. No room for small results. Donald gets things done.
Our country is underperforming and needs new leadership. Leadership is also what the world needs. Donald wants our country to move forward in the most positive of ways. Everyone wants change. Donald is the only one that can deliver it. We should not be satisfied with stagnation. Donald wants prosperity for all Americans. We need new programs to help the poor and opportunities to challenge the young. There has to be a plan for growth — only then will fairness result.
My husband's experience exemplifies growth and successful passage of opportunity to the next generation. His success indicates inclusion rather than division. My husband offers a new direction, welcoming change, prosperity and greater cooperation among peoples and nations. Donald intends to represent all the people, not just some of the people. That includes Christians and Jews and Muslims, it includes Hispanics and African Americans and Asians, and the poor and the middle-class. Throughout his career, Donald has successfully worked with people of many faiths and with many nations.
Like no one else, I have seen the talent, the energy, the tenacity, the resourceful mind, and the simple goodness of heart that God gave to Donald Trump. Now is the time to use those gifts as never before, for purposes far greater than ever before. And he will do this better than anyone else can — and it won't even be close. Everything depends on it, for our cause and for our country.
People are counting on him — all the millions of you who have touched us so much with your kindness and your confidence. You have turned this unlikely campaign into a movement that is still gaining in strength and number. The primary season, and its toughness, is behind us. Let's all come together in a national campaign like no other.
The race will be hard-fought, all the way to November. There will be good times and hard times and unexpected turns — it would not be a Trump contest without excitement and drama. But through it all, my husband will remain focused on only one thing: this beautiful country, that he loves so much.
If I am honored to serve as first lady, I will use that wonderful privilege to try to help people in our country who need it the most. One of the many causes dear to my heart is helping children and women. You judge a society by how it treats its citizens. We must do our best to ensure that every child can live in comfort and security, with the best possible education. As citizens of this great nation, it is kindness, love, and compassion for each other that will bring us together — and keep us together. These are the values Donald and I will bring to the White House. My husband is ready to lead this great nation. He is ready to fight, every day, to give our children the better future they deserve. Ladies and gentlemen, Donald J. Trump is ready to serve and lead this country as the next president of the United States.
Thank you, God bless you, and God bless America.

View File

@ -0,0 +1,83 @@
As you might imagine, for Barack, running for president is nothing compared to that first game of basketball with my brother, Craig.
I can't tell you how much it means to have Craig and my mom here tonight. Like Craig, I can feel my dad looking down on us, just as I've felt his presence in every grace-filled moment of my life.
At 6-foot-6, I've often felt like Craig was looking down on me too ... literally. But the truth is, both when we were kids and today, he wasn't looking down on me. He was watching over me.
And he's been there for me every step of the way since that clear February day 19 months ago, when — with little more than our faith in each other and a hunger for change — we joined my husband, Barack Obama, on the improbable journey that's brought us to this moment.
But each of us also comes here tonight by way of our own improbable journey.
I come here tonight as a sister, blessed with a brother who is my mentor, my protector and my lifelong friend.
I come here as a wife who loves my husband and believes he will be an extraordinary president.
I come here as a mom whose girls are the heart of my heart and the center of my world — they're the first thing I think about when I wake up in the morning, and the last thing I think about when I go to bed at night. Their future — and all our children's future — is my stake in this election.
And I come here as a daughter — raised on the South Side of Chicago by a father who was a blue-collar city worker and a mother who stayed at home with my brother and me. My mother's love has always been a sustaining force for our family, and one of my greatest joys is seeing her integrity, her compassion and her intelligence reflected in my own daughters.
My dad was our rock. Although he was diagnosed with multiple sclerosis in his early 30s, he was our provider, our champion, our hero. As he got sicker, it got harder for him to walk, it took him longer to get dressed in the morning. But if he was in pain, he never let on. He never stopped smiling and laughing — even while struggling to button his shirt, even while using two canes to get himself across the room to give my mom a kiss. He just woke up a little earlier and worked a little harder.
He and my mom poured everything they had into me and Craig. It was the greatest gift a child can receive: never doubting for a single minute that you're loved, and cherished, and have a place in this world. And thanks to their faith and hard work, we both were able to go on to college. So I know firsthand from their lives — and mine — that the American dream endures.
And you know, what struck me when I first met Barack was that even though he had this funny name, even though he'd grown up all the way across the continent in Hawaii, his family was so much like mine. He was raised by grandparents who were working-class folks just like my parents, and by a single mother who struggled to pay the bills just like we did. Like my family, they scrimped and saved so that he could have opportunities they never had themselves. And Barack and I were raised with so many of the same values: that you work hard for what you want in life; that your word is your bond and you do what you say you're going to do; that you treat people with dignity and respect, even if you don't know them, and even if you don't agree with them.
And Barack and I set out to build lives guided by these values, and pass them on to the next generation. Because we want our children — and all children in this nation — to know that the only limit to the height of your achievements is the reach of your dreams and your willingness to work for them.
And as our friendship grew, and I learned more about Barack, he introduced me to the work he'd done when he first moved to Chicago after college. Instead of heading to Wall Street, Barack had gone to work in neighborhoods devastated when steel plants shut down and jobs dried up. And he'd been invited back to speak to people from those neighborhoods about how to rebuild their community.
The people gathered together that day were ordinary folks doing the best they could to build a good life. They were parents living paycheck to paycheck; grandparents trying to get by on a fixed income; men frustrated that they couldn't support their families after their jobs disappeared. Those folks weren't asking for a handout or a shortcut. They were ready to work — they wanted to contribute. They believed — like you and I believe — that America should be a place where you can make it if you try.
Barack stood up that day, and spoke words that have stayed with me ever since. He talked about "The world as it is" and "The world as it should be." And he said that all too often, we accept the distance between the two, and settle for the world as it is — even when it doesn't reflect our values and aspirations. But he reminded us that we know what our world should look like. We know what fairness and justice and opportunity look like. And he urged us to believe in ourselves — to find the strength within ourselves to strive for the world as it should be. And isn't that the great American story?
It's the story of men and women gathered in churches and union halls, in town squares and high school gyms — people who stood up and marched and risked everything they had — refusing to settle, determined to mold our future into the shape of our ideals.
It is because of their will and determination that this week, we celebrate two anniversaries: the 88th anniversary of women winning the right to vote, and the 45th anniversary of that hot summer day when [Dr. Martin Luther King Jr.] lifted our sights and our hearts with his dream for our nation.
I stand here today at the crosscurrents of that history — knowing that my piece of the American dream is a blessing hard won by those who came before me. All of them driven by the same conviction that drove my dad to get up an hour early each day to painstakingly dress himself for work. The same conviction that drives the men and women I've met all across this country:
People who work the day shift, kiss their kids goodnight, and head out for the night shift — without disappointment, without regret — that goodnight kiss a reminder of everything they're working for.
The military families who say grace each night with an empty seat at the table. The servicemen and women who love this country so much, they leave those they love most to defend it.
The young people across America serving our communities — teaching children, cleaning up neighborhoods, caring for the least among us each and every day.
People like Hillary Clinton, who put those 18 million cracks in the glass ceiling, so that our daughters — and sons — can dream a little bigger and aim a little higher.
People like Joe Biden, who's never forgotten where he came from and never stopped fighting for folks who work long hours and face long odds and need someone on their side again.
All of us driven by a simple belief that the world as it is just won't do — that we have an obligation to fight for the world as it should be.
That is the thread that connects our hearts. That is the thread that runs through my journey and Barack's journey and so many other improbable journeys that have brought us here tonight, where the current of history meets this new tide of hope.
That is why I love this country.
And in my own life, in my own small way, I've tried to give back to this country that has given me so much. That's why I left a job at a law firm for a career in public service, working to empower young people to volunteer in their communities. Because I believe that each of us — no matter what our age or background or walk of life — each of us has something to contribute to the life of this nation.
It's a belief Barack shares — a belief at the heart of his life's work.
It's what he did all those years ago, on the streets of Chicago, setting up job training to get people back to work and after-school programs to keep kids safe — working block by block to help people lift up their families.
It's what he did in the Illinois Senate, moving people from welfare to jobs, passing tax cuts for hard-working families, and making sure women get equal pay for equal work.
It's what he's done in the United States Senate, fighting to ensure the men and women who serve this country are welcomed home not just with medals and parades but with good jobs and benefits and health care — including mental health care.
That's why he's running — to end the war in Iraq responsibly, to build an economy that lifts every family, to make health care available for every American, and to make sure every child in this nation gets a world class education all the way from preschool to college. That's what Barack Obama will do as president of the United States of America.
He'll achieve these goals the same way he always has — by bringing us together and reminding us how much we share and how alike we really are. You see, Barack doesn't care where you're from, or what your background is, or what party — if any — you belong to. That's not how he sees the world. He knows that thread that connects us — our belief in America's promise, our commitment to our children's future — is strong enough to hold us together as one nation even when we disagree.
It was strong enough to bring hope to those neighborhoods in Chicago.
It was strong enough to bring hope to the mother he met worried about her child in Iraq; hope to the man who's unemployed, but can't afford gas to find a job; hope to the student working nights to pay for her sister's health care, sleeping just a few hours a day.
And it was strong enough to bring hope to people who came out on a cold Iowa night and became the first voices in this chorus for change that's been echoed by millions of Americans from every corner of this nation.
Millions of Americans who know that Barack understands their dreams; that Barack will fight for people like them; and that Barack will finally bring the change we need.
And in the end, after all that's happened these past 19 months, the Barack Obama I know today is the same man I fell in love with 19 years ago. He's the same man who drove me and our new baby daughter home from the hospital 10 years ago this summer, inching along at a snail's pace, peering anxiously at us in the rearview mirror, feeling the whole weight of her future in his hands, determined to give her everything he'd struggled so hard for himself, determined to give her what he never had: the affirming embrace of a father's love.
And as I tuck that little girl and her little sister into bed at night, I think about how one day, they'll have families of their own. And one day, they — and your sons and daughters — will tell their own children about what we did together in this election. They'll tell them how this time, we listened to our hopes, instead of our fears. How this time, we decided to stop doubting and to start dreaming. How this time, in this great country — where a girl from the South Side of Chicago can go to college and law school, and the son of a single mother from Hawaii can go all the way to the White House we committed ourselves to building the world as it should be.
So tonight, in honor of my father's memory and my daughters' future — out of gratitude to those whose triumphs we mark this week, and those whose everyday sacrifices have brought us to this moment — let us devote ourselves to finishing their work; let us work together to fulfill their hopes; and let us stand together to elect Barack Obama president of the United States of America.
Thank you, God bless you, and God bless America.

View File

@ -0,0 +1,66 @@
My fellow citizens:I stand here today humbled by the task before us, grateful for the trust you have bestowed, mindful of the sacrifices borne by our ancestors. I thank President Bush for his service to our nation, as well as the generosity and cooperation he has shown throughout this transition.
Forty-four Americans have now taken the presidential oath. The words have been spoken during rising tides of prosperity and the still waters of peace. Yet, every so often the oath is taken amidst gathering clouds and raging storms. At these moments, America has carried on not simply because of the skill or vision of those in high office, but because We the People have remained faithful to the ideals of our forbearers, and true to our founding documents.
So it has been. So it must be with this generation of Americans.
That we are in the midst of crisis is now well understood. Our nation is at war, against a far-reaching network of violence and hatred. Our economy is badly weakened, a consequence of greed and irresponsibility on the part of some, but also our collective failure to make hard choices and prepare the nation for a new age. Homes have been lost; jobs shed; businesses shuttered. Our health care is too costly; our schools fail too many; and each day brings further evidence that the ways we use energy strengthen our adversaries and threaten our planet.
These are the indicators of crisis, subject to data and statistics. Less measurable but no less profound is a sapping of confidence across our land - a nagging fear that America's decline is inevitable, and that the next generation must lower its sights.
Today I say to you that the challenges we face are real. They are serious and they are many.
They will not be met easily or in a short span of time. But know this, America - they will be met. On this day, we gather because we have chosen hope over fear, unity of purpose over conflict and discord.
On this day, we come to proclaim an end to the petty grievances and false promises, the recriminations and worn out dogmas, that for far too long have strangled our politics.
We remain a young nation, but in the words of Scripture, the time has come to set aside childish things. The time has come to reaffirm our enduring spirit; to choose our better history; to carry forward that precious gift, that noble idea, passed on from generation to generation: the God-given promise that all are equal, all are free, and all deserve a chance to pursue their full measure of happiness.
In reaffirming the greatness of our nation, we understand that greatness is never a given. It must be earned. Our journey has never been one of short-cuts or settling for less. It has not been the path for the faint-hearted - for those who prefer leisure over work, or seek only the pleasures of riches and fame. Rather, it has been the risk-takers, the doers, the makers of things - some celebrated but more often men and women obscure in their labor, who have carried us up the long, rugged path towards prosperity and freedom.
For us, they packed up their few worldly possessions and traveled across oceans in search of a new life.
For us, they toiled in sweatshops and settled the West; endured the lash of the whip and plowed the hard earth.
For us, they fought and died, in places like Concord and Gettysburg; Normandy and Khe Sahn. Time and again these men and women struggled and sacrificed and worked till their hands were raw so that we might live a better life. They saw America as bigger than the sum of our individual ambitions; greater than all the differences of birth or wealth or faction.
This is the journey we continue today. We remain the most prosperous, powerful nation on Earth. Our workers are no less productive than when this crisis began. Our minds are no less inventive, our goods and services no less needed than they were last week or last month or last year. Our capacity remains undiminished. But our time of standing pat, of protecting narrow interests and putting off unpleasant decisions - that time has surely passed. Starting today, we must pick ourselves up, dust ourselves off, and begin again the work of remaking America.
For everywhere we look, there is work to be done. The state of the economy calls for action, bold and swift, and we will act - not only to create new jobs, but to lay a new foundation for growth. We will build the roads and bridges, the electric grids and digital lines that feed our commerce and bind us together. We will restore science to its rightful place, and wield technology's wonders to raise health care's quality and lower its cost. We will harness the sun and the winds and the soil to fuel our cars and run our factories. And we will transform our schools and colleges and universities to meet the demands of a new age. All this we can do. And all this we will do.
Now, there are some who question the scale of our ambitions - who suggest that our system cannot tolerate too many big plans. Their memories are short. For they have forgotten what this country has already done; what free men and women can achieve when imagination is joined to common purpose, and necessity to courage.
What the cynics fail to understand is that the ground has shifted beneath them - that the stale political arguments that have consumed us for so long no longer apply. The question we ask today is not whether our government is too big or too small, but whether it works - whether it helps families find jobs at a decent wage, care they can afford, a retirement that is dignified. Where the answer is yes, we intend to move forward. Where the answer is no, programs will end. And those of us who manage the public's dollars will be held to account - to spend wisely, reform bad habits, and do our business in the light of day - because only then can we restore the vital trust between a people and their government.
Nor is the question before us whether the market is a force for good or ill. Its power to generate wealth and expand freedom is unmatched, but this crisis has reminded us that without a watchful eye, the market can spin out of control - and that a nation cannot prosper long when it favors only the prosperous. The success of our economy has always depended not just on the size of our Gross Domestic Product, but on the reach of our prosperity; on our ability to extend opportunity to every willing heart - not out of charity, but because it is the surest route to our common good.
As for our common defense, we reject as false the choice between our safety and our ideals. Our Founding Fathers, faced with perils we can scarcely imagine, drafted a charter to assure the rule of law and the rights of man, a charter expanded by the blood of generations. Those ideals still light the world, and we will not give them up for expedience's sake. And so to all other peoples and governments who are watching today, from the grandest capitals to the small village where my father was born: know that America is a friend of each nation and every man, woman, and child who seeks a future of peace and dignity, and that we are ready to lead once more.
Recall that earlier generations faced down fascism and communism not just with missiles and tanks, but with sturdy alliances and enduring convictions. They understood that our power alone cannot protect us, nor does it entitle us to do as we please. Instead, they knew that our power grows through its prudent use; our security emanates from the justness of our cause, the force of our example, the tempering qualities of humility and restraint.
We are the keepers of this legacy. Guided by these principles once more, we can meet those new threats that demand even greater effort - even greater cooperation and understanding between nations. We will begin to responsibly leave Iraq to its people, and forge a hard-earned peace in Afghanistan. With old friends and former foes, we will work tirelessly to lessen the nuclear threat, and roll back the specter of a warming planet. We will not apologize for our way of life, nor will we waver in its defense, and for those who seek to advance their aims by inducing terror and slaughtering innocents, we say to you now that our spirit is stronger and cannot be broken; you cannot outlast us, and we will defeat you.
For we know that our patchwork heritage is a strength, not a weakness. We are a nation of Christians and Muslims, Jews and Hindus - and non-believers. We are shaped by every language and culture, drawn from every end of this Earth; and because we have tasted the bitter swill of civil war and segregation, and emerged from that dark chapter stronger and more united, we cannot help but believe that the old hatreds shall someday pass; that the lines of tribe shall soon dissolve; that as the world grows smaller, our common humanity shall reveal itself; and that America must play its role in ushering in a new era of peace.
To the Muslim world, we seek a new way forward, based on mutual interest and mutual respect.
To those leaders around the globe who seek to sow conflict, or blame their society's ills on the West - know that your people will judge you on what you can build, not what you destroy. To those who cling to power through corruption and deceit and the silencing of dissent, know that you are on the wrong side of history; but that we will extend a hand if you are willing to unclench your fist.
To the people of poor nations, we pledge to work alongside you to make your farms flourish and let clean waters flow; to nourish starved bodies and feed hungry minds. And to those nations like ours that enjoy relative plenty, we say we can no longer afford indifference to suffering outside our borders; nor can we consume the world's resources without regard to effect. For the world has changed, and we must change with it.
As we consider the road that unfolds before us, we remember with humble gratitude those brave Americans who, at this very hour, patrol far-off deserts and distant mountains. They have something to tell us today, just as the fallen heroes who lie in Arlington whisper through the ages.
We honor them not only because they are guardians of our liberty, but because they embody the spirit of service; a willingness to find meaning in something greater than themselves. And yet, at this moment - a moment that will define a generation - it is precisely this spirit that must inhabit us all.
For as much as government can do and must do, it is ultimately the faith and determination of the American people upon which this nation relies. It is the kindness to take in a stranger when the levees break, the selflessness of workers who would rather cut their hours than see a friend lose their job which sees us through our darkest hours. It is the firefighter's courage to storm a stairway filled with smoke, but also a parent's willingness to nurture a child, that finally decides our fate.
Our challenges may be new. The instruments with which we meet them may be new. But those values upon which our success depends - hard work and honesty, courage and fair play, tolerance and curiosity, loyalty and patriotism - these things are old. These things are true. They have been the quiet force of progress throughout our history. What is demanded then is a return to these truths. What is required of us now is a new era of responsibility - a recognition, on the part of every American, that we have duties to ourselves, our nation, and the world, duties that we do not grudgingly accept but rather seize gladly, firm in the knowledge that there is nothing so satisfying to the spirit, so defining of our character, than giving our all to a difficult task.
This is the price and the promise of citizenship.
This is the source of our confidence - the knowledge that God calls on us to shape an uncertain destiny.
This is the meaning of our liberty and our creed - why men and women and children of every race and every faith can join in celebration across this magnificent mall, and why a man whose father less than sixty years ago might not have been served at a local restaurant can now stand before you to take a most sacred oath.
So let us mark this day with remembrance, of who we are and how far we have traveled. In the year of America's birth, in the coldest of months, a small band of patriots huddled by dying campfires on the shores of an icy river. The capital was abandoned. The enemy was advancing. The snow was stained with blood. At a moment when the outcome of our revolution was most in doubt, the father of our nation ordered these words be read to the people:
"Let it be told to the future world...that in the depth of winter, when nothing but hope and virtue could survive...that the city and the country, alarmed at one common danger, came forth to meet [it]."
America. In the face of our common dangers, in this winter of our hardship, let us remember these timeless words. With hope and virtue, let us brave once more the icy currents, and endure what storms may come. Let it be said by our children's children that when we were tested we refused to let this journey end, that we did not turn back nor did we falter; and with eyes fixed on the horizon and God's grace upon us, we carried forth that great gift of freedom and delivered it safely to future generations.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
stop_words = ['i','me','my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're", "you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he', 'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's", 'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which', 'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are', 'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do', 'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because', 'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against', 'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below', 'to', 'from', 'up','down', 'in', 'out', 'on', 'off', 'over', 'under', 'again', 'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how', 'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no', 'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't', 'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll', 'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't", 'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't", 'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn', "mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't", 'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"]