example_package =============== .. py:module:: example_package Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/example_package/_version/index /autoapi/example_package/counts/index /autoapi/example_package/plotting/index /autoapi/example_package/version/index Attributes ---------- .. autoapisummary:: example_package.__version__ Functions --------- .. autoapisummary:: example_package.load_text example_package.clean_text example_package.count_words example_package.plot_words Package Contents ---------------- .. py:data:: __version__ .. 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)] .. py:function:: plot_words(word_counts: collections.Counter, top_n=10) Plot the top N words from the word counts.