From 2721b4e31c23a652a39dfb925d519eba0655578a Mon Sep 17 00:00:00 2001 From: Viacheslav Date: Thu, 29 May 2025 10:44:01 +0300 Subject: [PATCH 1/2] Update count_words.py --- count_words.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/count_words.py b/count_words.py index acfa02f..5058adc 100644 --- a/count_words.py +++ b/count_words.py @@ -1,4 +1,21 @@ -paragraph = paragraph.lower() -paragraph = paragraph.translate(str.maketrans("", "", string.punctuation)) +import string + +def count_words(paragraph) -> int: + paragraph = paragraph.lower() + paragraph = paragraph.translate(str.maketrans("", "", string.punctuation)) + wordList = paragraph.split() + counter = Counter(wordList) + return counter + +def manin(): + paragraph = """Nadia’s Garden Restaurant is the creation of husband and wife team Nadia and Timothy Arbore. + Their American-infused, Italian-based, organically created, cuisine was inspired by Nadia’s papa, an immigrant from Italy, + who shared his love of cooking with Nadia as a young girl. His focus on using fresh ingredients and family style dining were + the inspiration for Nadia’s Garden Restaurant. Located in the heart of Main Streets Historic District, they are proud to be a + part of a rich community. In 2011, the duo remodeled the restaurant and updated their menu to include newer and more diverse entrées + that could be made from local organic suppliers. Preservation of the building’s original layout has allowed them to create smaller, + more intimate, dining spaces. Nadia and Timothy are committed to sharing their family history of cuisine, along with their new inspirations, + with their customers. Their passion for community, entertainment, and hospitality are found in every aspect of Nadia’s Garden Restaurant.""" + + print(count_words(paragraph)) -wordList = paragraph.split() From fde0e871ab57001bb5909a493d9d2101b426505f Mon Sep 17 00:00:00 2001 From: Viacheslav Date: Thu, 29 May 2025 07:57:32 +0000 Subject: [PATCH 2/2] corrected counter --- count_words.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/count_words.py b/count_words.py index 5058adc..af93828 100644 --- a/count_words.py +++ b/count_words.py @@ -1,4 +1,5 @@ import string +from collections import Counter def count_words(paragraph) -> int: paragraph = paragraph.lower() @@ -7,7 +8,7 @@ def count_words(paragraph) -> int: counter = Counter(wordList) return counter -def manin(): +def main(): paragraph = """Nadia’s Garden Restaurant is the creation of husband and wife team Nadia and Timothy Arbore. Their American-infused, Italian-based, organically created, cuisine was inspired by Nadia’s papa, an immigrant from Italy, who shared his love of cooking with Nadia as a young girl. His focus on using fresh ingredients and family style dining were @@ -16,6 +17,9 @@ def manin(): that could be made from local organic suppliers. Preservation of the building’s original layout has allowed them to create smaller, more intimate, dining spaces. Nadia and Timothy are committed to sharing their family history of cuisine, along with their new inspirations, with their customers. Their passion for community, entertainment, and hospitality are found in every aspect of Nadia’s Garden Restaurant.""" - + print ("test test") print(count_words(paragraph)) +if __name__ == "__main__": + main() + print ("test print")