0 comments

GET A PROFESSIONAL PAPER DONE BY AN EXPERT

Write a program that changes your output from HW04 to create a JSON file (Links to an external site.) instead. In previous versions you’ve counted and written out results files, but this time you should write out a single json file that is constructed of all these results.Step 1: Create and prepopulate your dictionary. Look at the schema provided at the end and determine what needs to be established before you start performing the searches. You will need two phases: populating the static information, and populating the dictionary of terms such that it will be ready for counting and lines to be added to the line list. You will likely need to change what you have here as you work through step 2, but you need to have something to start with.Step 2: Perform the searches and populate the dictionary of data. You should (depending on how you solved it) be able to use your previous looping structure from HW04 but change it to do two things: increment that term’s counter and append each line to the appropriate term list for each positive match. You may find it beneficial to make a small proof of concept in your python console and experiment with how the lookups, counts, and appends are working. Print your dictionary to see your results. Try to search for very uncommon words within your file to make the results a bit smaller.Step 3: Use the json module to write out your dictionary as a json file. Call it term-results.json. Use the indent = 4 command so the final version is more readable.Step 4: Read this new file in, load it via the json parser, and show/explain three data lookups within it. You may do this in a new script or at the end of your main script.Coding done!Discussion question:In your narrative, propose a new version of this schema that would account for multiple files. You are welcome to attach pictures of drawings, etc. You don’t need to implement this, just diagram and describe it.Use the following JSON schema:{‘file_name’: your file name,‘Num_terms’: the number of terms used (this should be computed not hard coded,‘term’: {‘count’: number of times it appeared,‘Lines’: [list of all the lines]}}Here’s an example:{“file_name”: “Three-years-in-europe.txt”,“num_terms”: 2,“cat”: {“count”: 3,“lines”: [“worthless paper. These were known as the “Wild Cat Banks.”” Silver coinn””

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}