word_text_counter

Subpackages

Submodules

Package Contents

Functions

count_words(filename: str) → dict

Counting words from a text.

get_flatland_path() → str

get sample text file path, with name "flatland.txt".

get_time_machine_path() → str

get sample text file path, with name "time_machine.txt".

get_lostworld_path() → str

get sample text file path, with name "lostworld.txt".

word_text_counter.count_words(filename: str) dict[source]

Counting words from a text.

Words are made lowercase and punctuation is removed before counting.

Parameters

filename (str) – a file path.

Returns

total words and count details for each word.

Return type

dict

Examples

>>> from word_text_counter import count_words
>>> count_words("data/text.txt")
word_text_counter.get_flatland_path() str[source]

get sample text file path, with name “flatland.txt”.

Returns

a flatland.txt path.

Return type

str

word_text_counter.get_time_machine_path() str[source]

get sample text file path, with name “time_machine.txt”.

Returns

a time_machine.txt path.

Return type

str

word_text_counter.get_lostworld_path() str[source]

get sample text file path, with name “lostworld.txt”.

Returns

a lostworld.txt path.

Return type

str