In the above task there are 3 functions: 1. Displays text and performs word counting. 2. Must display each word and the number of its repetitions in the form of a dictionary. 2. Must output each word and the number of its repetitions in the form of named tuples, in the sequence in which the words are in the text.
import argparse import sys def main(): parser = argparse.ArgumentParser() parser.add_argument("infile", help="Text file to be analyzed.") args = parser.parse_args() with open(args.infile, encoding="utf-8") as f: text = f.read() words = text.split() unique_words(words) def unique_words(words): the_dict = {} for line in words: unique_words(the_dict) return(the_dict) def count_unique_sorted(words): words = [] return(words) if __name__ == "__main__": sys.exit(main()) Directly text (.txt):
Design, develop, maintain and test cloud applications in Python, and document API for cloud services. design, develop, and test cloud applications in Python, and document API for services. Design, , and cloud in Python, and document for services.