The Dictionary Checker is a simple Python program that takes a string containing two concatenated words without spaces and attempts to identify and separate the words.
- NLTK (Natural Language Toolkit)
- The program first imports the required libraries (
nltk
andwords
corpus fromnltk.corpus
). - It then prompts the user to start the game by asking whether they want to play.
- If the user inputs "no", the program exits, otherwise it continues to the next step.
- The user is prompted to input a string containing two concatenated words with no spaces.
- The program then iterates through the input string, dividing it into two parts at each possible position.
- For each division, the program checks if both parts are valid words using the
words.words()
function from the NLTK library. - If a valid pair of words is found, the program prints the separated words and asks the user if they want to try again.
- If the user inputs "no", the program exits. If no valid pair of words is found, the program informs the user and prompts them to try again.
Welcome to Dictionary Checker! Would you like to play (Yes/no)?: Yes
Please enter a string containing two words, with no spaces: icecream
You entered icecream
The two words are ice and cream
Would you like to try again (Yes/no)?: no
Goodbye