Did Shakespeare truly have a way with words?
Explore the docs »
Report Bug
·
Request Feature
Sometimes it is important to determine unique words in text. We might also simply be curious how truly genius Shakespeare was! Use this code to display the unique words in Romeo's famous speech confessing his love to Juliet. Finding unique words in a text file can be useful to note if a word was misspelled, that a general replace all commas and apostrophies or remove whitespaces would not do. This happens a lot due to manual entries in data, more likely in text files. An extra bonus, the words will be shown in alphabetical order. This would make it nicer for a human to read, and even for a computer to quickly search through. You're more than welcome to test your own input files to convince others that they may need to expand their vocabulary... ☺
To get a local copy up and running, download the alphabetical_unique_words.py
file and the text input files, romeo.txt
and proof.txt
, into the same folder. Then run the code in an IDE software, such as IDLE, or in Command Prompt. The romeo.txt
file contains Romeo's speech, while the proof.txt
file was used to prove to my professor that my program works by using my own name. Easily try your own text file with this program by saving it into the same folder.
Using the romeo.txt
file in IDLE:
Using the proof.txt
file in IDLE:
Using the romeo.txt
file in Command Prompt:
>>python3 alphabetical_unique_words.py
>>Enter the file name: romeo.txt
>>['Arise', 'But', 'It', 'Juliet', 'Who', 'already', 'and', 'breaks', 'east', 'envious', 'fair', 'grief', 'is', 'kill', 'light', 'moon', 'pale', 'sick', 'soft', 'sun', 'the', 'through', 'what', 'window', 'with', 'yonder']
Karishma Mathur - karishma324@gmail.com
Project Link: https://github.com/Mathurkarishma/romeo-unique-words
- Dr. Prasanna Menta at University of Maryland, Global Campus - Fall 2019