SlideShare una empresa de Scribd logo
1 de 1
Descargar para leer sin conexión
9.8 LAB: Word Count Weite a program that first reads in the raime of an inout file and then reada
the file sing the cov readed0 method The fik contains mit ple lines : each a comma segarated list
of words. The program must outeut the words and theit frequehbies tive number of tenes eoch
wers appeats in the fila) witheut any duplicates and daregarcing case (output the words in lower
case) Why do this? in case you are wondenng wry it woudd be important to calcubete bow many
times a word oceurted a a documxent. this is a ocnoept known as ferm trequency and is a concept
oftien used in information ietreval in fact, one of the ear lent papers related to Big Daia discusaes
how Google did word count but at a much latger scide - they were doing t across alt of the
documents they had crawicd in bulding thes search inder. Example: If theinput is cintoniesy and
the contents of Cintor eav consusted of the folowing 4 knes If, there, is, one, needage, that,
echees, forth, fren, thia, conference let, it, be, tkat, humss, rhahti, are, ,youne's, at rights, and,
wocen'a, righti aro, hueian, rtabtin, ence, and, for, akl, Wet, wes, not, fotget, that, ansed the outhut
is if -1 chere - 1 ts- 1 one-1 tesaage - 1 that -3 achoes - 1 forte -1tran--1thin1obaferuace-11it=21t1
be=2himan4fightn5are=dmonea2and=3iopce=1fer-1a.11-1iu=1inot=1furget:=1afope=1those=1the
3ituht=2to-2apeai=1freely=1hisard1 Notes: - The curient versian of Python stares dictionary
entries in the order in which dects were mserted - The itenat) method retums all of the keyvalue
pair entries from a dectonary and can be comerted to a lat. For esample if a dictionary was named
myydict, a ast (inorder) of af of the entries can be gensrated by caling 1 ist ( my_diec.itena () ).
Each item in the list would be a tuple wth the key and value for an entiy: - Similarly
sst(nyydetkeys0) will generate a liat of the keys (in ordes)- The cument version of Python stores
dictionary entries in the order in which items were ingerted - The items () method relurns all of the
keyvalue pair entriea from a dictionary and can be corverted to a fat. For example, if a dictionary
was named my_dict, a lst (in ordet) of all of the entries can be generated by calling 1i=1 fy diet.
items() ). Each item in the list would be a taple with the key and value for an entry. - Similathy. list
my, idict keys0) will generate a jst of the keys (in order). - Output words in oeder of their first
occurfence in the fili - The file Clintoncsv is available to download

Más contenido relacionado

Similar a 98 LAB Word Count Weite a program that first reads in the .pdf

Introduction to Linux Slides.pptx
Introduction to Linux Slides.pptxIntroduction to Linux Slides.pptx
Introduction to Linux Slides.pptx
hazhamina
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
fredharris32
 
Hello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdfHello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdf
actioncbe1
 

Similar a 98 LAB Word Count Weite a program that first reads in the .pdf (20)

Mastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operationsMastering Python lesson 5a_lists_list_operations
Mastering Python lesson 5a_lists_list_operations
 
These questions will be a bit advanced level 2
These questions will be a bit advanced level 2These questions will be a bit advanced level 2
These questions will be a bit advanced level 2
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
biopython, doctest and makefiles
biopython, doctest and makefilesbiopython, doctest and makefiles
biopython, doctest and makefiles
 
Introduction to Linux Slides.pptx
Introduction to Linux Slides.pptxIntroduction to Linux Slides.pptx
Introduction to Linux Slides.pptx
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Phython presentation
Phython presentationPhython presentation
Phython presentation
 
A-Study_TopicModeling
A-Study_TopicModelingA-Study_TopicModeling
A-Study_TopicModeling
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
Paper id 42201608
Paper id 42201608Paper id 42201608
Paper id 42201608
 
Advance python
Advance pythonAdvance python
Advance python
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board ExamsC++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
C++ Notes by Hisham Ahmed Rizvi for Class 12th Board Exams
 
Python ppt_118.pptx
Python ppt_118.pptxPython ppt_118.pptx
Python ppt_118.pptx
 
An Efficient Search Engine for Searching Desired File
An Efficient Search Engine for Searching Desired FileAn Efficient Search Engine for Searching Desired File
An Efficient Search Engine for Searching Desired File
 
Python introduction
Python introductionPython introduction
Python introduction
 
Fp growth algorithm
Fp growth algorithmFp growth algorithm
Fp growth algorithm
 
Fp growth algorithm
Fp growth algorithmFp growth algorithm
Fp growth algorithm
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
 
Hello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdfHello guys please make sure program runs well USING C anyth.pdf
Hello guys please make sure program runs well USING C anyth.pdf
 

Más de sastaindin

A 2010 Pew Research poll asked 1306 Americans From what yo.pdf
A 2010 Pew Research poll asked 1306 Americans From what yo.pdfA 2010 Pew Research poll asked 1306 Americans From what yo.pdf
A 2010 Pew Research poll asked 1306 Americans From what yo.pdf
sastaindin
 
a 1 The first step is to understand the requirements of th.pdf
a 1 The first step is to understand the requirements of th.pdfa 1 The first step is to understand the requirements of th.pdf
a 1 The first step is to understand the requirements of th.pdf
sastaindin
 
9 Using the key choices complete the crossword puzale by a.pdf
9 Using the key choices complete the crossword puzale by a.pdf9 Using the key choices complete the crossword puzale by a.pdf
9 Using the key choices complete the crossword puzale by a.pdf
sastaindin
 
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
sastaindin
 
9 You are studying the molecular behavior of myosin II S1 .pdf
9 You are studying the molecular behavior of myosin II S1 .pdf9 You are studying the molecular behavior of myosin II S1 .pdf
9 You are studying the molecular behavior of myosin II S1 .pdf
sastaindin
 

Más de sastaindin (20)

A 7 year 15000 bond paying a coupon rate of 475 compound.pdf
A 7 year 15000 bond paying a coupon rate of 475 compound.pdfA 7 year 15000 bond paying a coupon rate of 475 compound.pdf
A 7 year 15000 bond paying a coupon rate of 475 compound.pdf
 
A 25 yearold graduate student enters the student health ce.pdf
A 25 yearold graduate student enters the student health ce.pdfA 25 yearold graduate student enters the student health ce.pdf
A 25 yearold graduate student enters the student health ce.pdf
 
a 2 pts Construct the final Fibonacci heap after the fol.pdf
a 2 pts Construct the final Fibonacci heap after the fol.pdfa 2 pts Construct the final Fibonacci heap after the fol.pdf
a 2 pts Construct the final Fibonacci heap after the fol.pdf
 
A 2010 Pew Research poll asked 1306 Americans From what yo.pdf
A 2010 Pew Research poll asked 1306 Americans From what yo.pdfA 2010 Pew Research poll asked 1306 Americans From what yo.pdf
A 2010 Pew Research poll asked 1306 Americans From what yo.pdf
 
a 1 The first step is to understand the requirements of th.pdf
a 1 The first step is to understand the requirements of th.pdfa 1 The first step is to understand the requirements of th.pdf
a 1 The first step is to understand the requirements of th.pdf
 
A 10 year old develops severe pharyngitis at summer camp He.pdf
A 10 year old develops severe pharyngitis at summer camp He.pdfA 10 year old develops severe pharyngitis at summer camp He.pdf
A 10 year old develops severe pharyngitis at summer camp He.pdf
 
A modeling study of the stomatogastric ganglion STG of th.pdf
A  modeling study of the stomatogastric ganglion STG of th.pdfA  modeling study of the stomatogastric ganglion STG of th.pdf
A modeling study of the stomatogastric ganglion STG of th.pdf
 
9 Using the key choices complete the crossword puzale by a.pdf
9 Using the key choices complete the crossword puzale by a.pdf9 Using the key choices complete the crossword puzale by a.pdf
9 Using the key choices complete the crossword puzale by a.pdf
 
9 Sickle Cell Anemia is a condition that shows codominance.pdf
9 Sickle Cell Anemia is a condition that shows codominance.pdf9 Sickle Cell Anemia is a condition that shows codominance.pdf
9 Sickle Cell Anemia is a condition that shows codominance.pdf
 
A Blastula aamas B zigot aamas C Morula aamas D.pdf
A  Blastula aamas   B  zigot aamas   C  Morula aamas   D.pdfA  Blastula aamas   B  zigot aamas   C  Morula aamas   D.pdf
A Blastula aamas B zigot aamas C Morula aamas D.pdf
 
97 Using the table for the t distributions make an assess.pdf
97 Using the table for the t distributions make an assess.pdf97 Using the table for the t distributions make an assess.pdf
97 Using the table for the t distributions make an assess.pdf
 
925 Match the following generally accepted accounting princ.pdf
925 Match the following generally accepted accounting princ.pdf925 Match the following generally accepted accounting princ.pdf
925 Match the following generally accepted accounting princ.pdf
 
8En Alemania los trabajadores Seleccione uno a pued.pdf
8En Alemania los trabajadores    Seleccione uno  a pued.pdf8En Alemania los trabajadores    Seleccione uno  a pued.pdf
8En Alemania los trabajadores Seleccione uno a pued.pdf
 
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
9Tara asiste a una escuela secundaria en un rea urbana Q.pdf
 
918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdf918 LAB Sorting user IDs Given a main that reads user ID.pdf
918 LAB Sorting user IDs Given a main that reads user ID.pdf
 
900 ABDli yetikinden oluan bir rneklemde 206s nllerin .pdf
900 ABDli yetikinden oluan bir rneklemde 206s nllerin .pdf900 ABDli yetikinden oluan bir rneklemde 206s nllerin .pdf
900 ABDli yetikinden oluan bir rneklemde 206s nllerin .pdf
 
9 You are studying the molecular behavior of myosin II S1 .pdf
9 You are studying the molecular behavior of myosin II S1 .pdf9 You are studying the molecular behavior of myosin II S1 .pdf
9 You are studying the molecular behavior of myosin II S1 .pdf
 
9 What will be the outgut of the C program Aincluderstdich.pdf
9 What will be the outgut of the C program Aincluderstdich.pdf9 What will be the outgut of the C program Aincluderstdich.pdf
9 What will be the outgut of the C program Aincluderstdich.pdf
 
9 Which Git command should be used to update a local reposi.pdf
9 Which Git command should be used to update a local reposi.pdf9 Which Git command should be used to update a local reposi.pdf
9 Which Git command should be used to update a local reposi.pdf
 
9 Private solutions to correct for externalities Consider t.pdf
9 Private solutions to correct for externalities Consider t.pdf9 Private solutions to correct for externalities Consider t.pdf
9 Private solutions to correct for externalities Consider t.pdf
 

Último

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 

Último (20)

Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 

98 LAB Word Count Weite a program that first reads in the .pdf

  • 1. 9.8 LAB: Word Count Weite a program that first reads in the raime of an inout file and then reada the file sing the cov readed0 method The fik contains mit ple lines : each a comma segarated list of words. The program must outeut the words and theit frequehbies tive number of tenes eoch wers appeats in the fila) witheut any duplicates and daregarcing case (output the words in lower case) Why do this? in case you are wondenng wry it woudd be important to calcubete bow many times a word oceurted a a documxent. this is a ocnoept known as ferm trequency and is a concept oftien used in information ietreval in fact, one of the ear lent papers related to Big Daia discusaes how Google did word count but at a much latger scide - they were doing t across alt of the documents they had crawicd in bulding thes search inder. Example: If theinput is cintoniesy and the contents of Cintor eav consusted of the folowing 4 knes If, there, is, one, needage, that, echees, forth, fren, thia, conference let, it, be, tkat, humss, rhahti, are, ,youne's, at rights, and, wocen'a, righti aro, hueian, rtabtin, ence, and, for, akl, Wet, wes, not, fotget, that, ansed the outhut is if -1 chere - 1 ts- 1 one-1 tesaage - 1 that -3 achoes - 1 forte -1tran--1thin1obaferuace-11it=21t1 be=2himan4fightn5are=dmonea2and=3iopce=1fer-1a.11-1iu=1inot=1furget:=1afope=1those=1the 3ituht=2to-2apeai=1freely=1hisard1 Notes: - The curient versian of Python stares dictionary entries in the order in which dects were mserted - The itenat) method retums all of the keyvalue pair entries from a dectonary and can be comerted to a lat. For esample if a dictionary was named myydict, a ast (inorder) of af of the entries can be gensrated by caling 1 ist ( my_diec.itena () ). Each item in the list would be a tuple wth the key and value for an entiy: - Similarly sst(nyydetkeys0) will generate a liat of the keys (in ordes)- The cument version of Python stores dictionary entries in the order in which items were ingerted - The items () method relurns all of the keyvalue pair entriea from a dictionary and can be corverted to a fat. For example, if a dictionary was named my_dict, a lst (in ordet) of all of the entries can be generated by calling 1i=1 fy diet. items() ). Each item in the list would be a taple with the key and value for an entry. - Similathy. list my, idict keys0) will generate a jst of the keys (in order). - Output words in oeder of their first occurfence in the fili - The file Clintoncsv is available to download