Weekend Hacks: n-grams (pt.2)
Processing text files and outputting CSV summaries
I previously put together a quick tutorial on n-grams and hacked together a quick script to find n-grams in a piece of text. At the end of that tutorial I gave some suggestions on how that simple script could be expanded. With this follow up tutorial I will show how to parse a directory of text files for specific n-grams and generate summaries of the results in CSV format.
Modifying the Input Step
— Placeholder text: Describe how to get file listings and read in text files —
Modifying the Processing Step
— Placeholder text: Describe how to modify the processing step with additional functions that search for specific n-grams —
Modifying the Output Step
— Placeholder text: Describe how to modify the output step. Explain the structure of CSV files, explain how to write files to disk with python —