JNinja
Junior Member
- Aug 13, 2022
- 191
- 212
I noticed that this forum seems to love Paraphrasing tools (obvious reasons why) but a lot of the paraphrasing tools have low character limits on free plans and can be quite expensive.
This is a 100% free paraphrasing tool with no limits. It is built in Python and you would run it on your local machine or server if you know how to set that up. It is basic but should get the job done.
Here's the code:
This is a 100% free paraphrasing tool with no limits. It is built in Python and you would run it on your local machine or server if you know how to set that up. It is basic but should get the job done.
Here's the code:
Code:
import nltk
from nltk.corpus import wordnet
def paraphrase(text):
# Tokenize the text
tokens = nltk.word_tokenize(text)
# Part-of-speech tag the tokens
pos_tags = nltk.pos_tag(tokens)
# Create an empty list to store the paraphrased words
paraphrased_words = []
# Loop through each token and its part-of-speech tag
for token, pos in pos_tags:
# If the token is a noun or a verb, find its synonyms
if pos.startswith("NN") or pos.startswith("VB"):
# Get the synonyms of the word
synonyms = wordnet.synsets(token)
# If there are synonyms, choose one at random
if synonyms:
paraphrased_word = synonyms[0].lemmas()[0].name()
# If the paraphrased word is not the same as the original word, use it
if paraphrased_word != token:
paraphrased_words.append(paraphrased_word)
continue
# If no synonyms were found or the word is not a noun or verb, use the original word
paraphrased_words.append(token)
# Join the paraphrased words to form the paraphrased sentence
paraphrased_text = " ".join(paraphrased_words)
return paraphrased_text
# Test the paraphrasing tool
text = "The quick brown fox jumps over the lazy dog."
paraphrased_text = paraphrase(text)
print(paraphrased_text)