Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text Spinner using Naive Bayes

I am writing a text spinner which is working fine as it should. But the accuracy of the readable sentences is very low as it is just using a dictionary which i am getting from database. Which return spintax like this

{Your} {home| house| residence| property} {is} {your} {castle| mansion| fortress| palace}

and is passed to a function which selects randomly synonym and output sentence based on the original input of the user. For example for input:

Your home is your castle.

will return

Your property is your mansion.

Now I want to include Artificial intelligence as it will make my output sentences more readable. I want to know how to make a better selection using naive Bayes. I know I probably need to train so that better results.

Here is my current method for selection of word, which is really simple right now.

def spin(spintax):
    while True:
        word, n = re.subn('{([^{}]*)}',lambda m: random.choice(m.group(1).split("|")),spintax)
        if n == 0: break
return word.strip()

Thank you in advance if you guys need me to post more code let me know

like image 492
Abdul Rehman Janjua Avatar asked Mar 12 '26 03:03

Abdul Rehman Janjua


1 Answers

This will probably get closed as there is no concise answer to your question, but you might want to check out nltk wordnet:

https://pythonprogramming.net/wordnet-nltk-tutorial/

like image 89
litepresence Avatar answered Mar 17 '26 04:03

litepresence