example_package.counts ====================== .. py:module:: example_package.counts Functions --------- .. autoapisummary:: example_package.counts.load_text example_package.counts.clean_text example_package.counts.count_words Module Contents --------------- .. py:function:: load_text(file_path) Load text from a file. .. py:function:: clean_text(text) Clean the text by removing punctuation and converting to lowercase. .. py:function:: count_words(input_file) Count the frequency of each word in the input file. :param input_file: Path to the text file to analyze. :type input_file: str :returns: A Counter object containing word frequencies where: - keys are the unique words found in the text - values are the number of occurrences of each word :rtype: Counter .. rubric:: Example >>> word_counts = count_words("sample.txt") >>> word_counts["hello"] 3 >>> word_counts.most_common(1) [('hello', 3)]