Given the words, the task is to extract different words from a set of characters using the defined dictionary.
Python in its language defines an inbuilt module
enchant which handles certain operations related to words. In the approach mentioned, following methods are used.
check() :It checks if a string is a word or not and returns true if a string is a word, else returns false.
permutations(str_arr, str_len) :It provides the combination of a string as per the mentioned string length.
There is a chance that
enchant() module might not be present, so it can be installed using pip3 install enchant.
Below is the Python code implementation of the above approach.
star is an English words tars is an English words arts is an English words rats is an English words perm_word [‘star’, ‘tars’, ‘arts’, ‘rats’] sat is an English word tar is an English word art is an English word rat is an English word perm_word [‘star’, ‘tars’, ‘arts’, ‘rats’, ‘sat’, ‘tar’, ‘art’, ‘rat’] st is an English word ts is an English word tr is an English word as is an English word at is an English word rs is an English word rt is an English word perm_word [‘star’, ‘tars’, ‘arts’, ‘rats’, ‘sat’, ‘tar’, ‘art’, ‘rat’, ‘st’, ‘ts’, ‘tr’, ‘as’, ‘at’, ‘rs’, ‘rt’]
- Scraping And Finding Ordered Words In A Dictionary using Python
- Possible Words using given characters in Python
- Python | Toggle characters in words having same case
- Python Dictionary to find mirror characters in a string
- Python | Prefix extraction before specific character
- Python | Foreground Extraction in an Image using Grabcut Algorithm
- Python - Rear element extraction from list of tuples records
- Python | Convert flattened dictionary into nested dictionary
- Python | Convert nested dictionary into flattened dictionary
- Python | Pretty Print a dictionary with dictionary value
- Regular Dictionary vs Ordered Dictionary in Python
- Python | Convert string dictionary to dictionary
- NLP | Location Tags Extraction
- NLP | Proper Noun Extraction
- Sklearn | Feature Extraction with TF-IDF
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.