EssayPy AI is a Python application that generates paragraphs based on user-defined topics. By using the Datamuse API, it fetches related words and constructs meaningful(sometimes) sentences, allowing for creative text generation on various subjects.
- Fetches words related to a given topic using the Datamuse API.
- Cleans user input by removing common stop words.
- Analyzes and determines relevant topics from the input.
- Generates structured sentences with specified grammatical rules.
- Outputs a set number of paragraphs containing sentences related to identified topics.
To run this application, ensure you have the following:
- Python 3.x
requests
library (install viapip install requests
)
- Clone the repository or download the script file.
- Install the required dependencies:
pip install requests
-
Run the script:
python main.py
-
When prompted, enter a topic:
Enter a topic: Your chosen topic here
-
The application will:
- Clean the input by removing stop words.
- Identify related topics using the Datamuse API.
- Generate and display paragraphs based on the identified topics.
-
get_words_by_topic(topic_word, part_of_speech=None)
: Fetches words related to a topic, optionally filtered by part of speech (noun, verb, adjective, or adverb). -
clean_topic_input(topic_sentence)
: Cleans the input sentence by removing common stop words and splitting it into meaningful words. -
determine_topics(words)
: Analyzes filtered words to identify related topics using the Datamuse API. -
create_sentence(topic)
: Constructs a structured sentence from related words (2 nouns, 1 verb, up to 2 adjectives, and 1 adverb). -
generate_paragraphs(topics, num_paragraphs=5)
: Generates a specified number of paragraphs by creating sentences based on selected topics. -
main()
: The entry point of the application, handling user interaction and invoking other functions.
The application uses Python's built-in logging module to provide detailed logs at various levels (DEBUG, INFO, WARNING, ERROR). Logs are outputted in the console and include timestamps.
When the user inputs a topic, the application may generate paragraphs like the following:
Generated paragraphs:
Paragraph 1:
The beautiful entity acts quickly. The lovely object does its task carefully.
Paragraph 2:
The strange thing moves gracefully. The amazing creature acts swiftly.
This project is licensed under the MIT License - see the LICENSE file for details.
- Thanks to the Datamuse API for providing the word-fetching capabilities.
- Special thanks to the Python community for their ongoing support and contributions.