I am working on a program that needs to create a sentence that is grammatically correct from a given set of words. Here I will be passing an input of a list of strings to the program and my output should be a meaningful sentence made with those words, and a few other words that are necessary. Eg.
Input: {'You' , 'House' , 'Beautiful'}
Output: 'Your house is beautiful' (or) 'you house is beautiful'
Input: {'Father' , 'Love' , 'Child'}
Output: 'The father loves the child'
How do I implement this with NLTK and(or) Machine Learning?
Any suggestions as to how I should go about this? I'm ready to even the most wildest ideas. Thanks! :)
In this case you can apply an n-gram model. The idea is that a sentence
I like NLP very much.
gets the following 3-grams:
<s> I like
I like NLP
like NLP very
NLP very much
very much </s>
Then you think of it as a probability model P(word3 | word1 word2)
.
So your work would be:
Please note:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With