mypkg_edne.mypkg_edne

Module Contents

Functions

load_text(input_file)

"Load text from a text file and return as a string.

clean_text(text)

Lowercase and remove punctuation from a string.

count_words(input_file: str)

param input_file

Path to text file.

mypkg_edne.mypkg_edne.load_text(input_file)[source]

“Load text from a text file and return as a string.

Parameters

input_file (str) – Path to text file.

Returns

Text file contents.

Return type

str

Examples

>>> load_text("text.txt")
mypkg_edne.mypkg_edne.clean_text(text)[source]

Lowercase and remove punctuation from a string.

Parameters

text (str) – Text to clean.

Returns

Cleaned text.

Return type

str

Examples

>>> clean_text("Early optimization is the root of all evil!")
'early optimization is the root of all evil'
mypkg_edne.mypkg_edne.count_words(input_file: str)[source]
Parameters

input_file (str) – Path to text file.

Returns

dict-like object where keys are words and values are counts.

Return type

collections.Counter

Examples

>>> count_words("text.txt")