-5

Can I do something like this in python? I have 3 sentences:

I like cats.
I like cats
I like cats

And it is possible when I give I like, the script returns cats?

Can somebody give me advice/tool or some example?

CDspace
  • 2,639
  • 18
  • 30
  • 36
Witcher
  • 63
  • 1
  • 1
  • 5

1 Answers1

-2

There are an unlimited number of ways to do that. You could make a script that just does this:

print("cats")

But, I don't think that's what you want. You're looking for a Language Model. Again, there are many ways of doing this, from the fairly simple Bayesian model to a more advanced neural network language model. If you want to build your own, I would recommend checking out TensorFlow's tutorial on language models. Otherwise, you could use something that's a bit more off the shelf, such as NLTK's language model (see example here).

Community
  • 1
  • 1
dantiston
  • 5,161
  • 2
  • 26
  • 30