# How can I determine if an input sentence is consistent with a certain subject?

How can I determine if an input sentence is consistent with a certain subject?

For example, suppose I am given the following dataset.

| Subject       | User input           | Output |
|---------------|----------------------|--------|
| Dog ownership | I own a dog          | Yes    |
| Dog ownership | My dog is called Joe | Yes    |
| Dog ownership | I don't have a dog   | No     |


In the examples above, the subject "dog ownership" is consistent with the input sentences "I own a dog" and "My dog is called Joe" (because, if your dog is called Joe, then you also own a dog).

If you have lots of training data, ANN's (deep learning) could quite possibly get you there. But I have a hunch you might also get some mileage out of using something like a rule induction approach. Maybe something like CN2. I'd suggest at least reading up on those and see if you can see a way to apply that to your system.

• The thing is that I don't have enough training data for ANN's, but I'm starting to think that I will need it. Since it will require a big amount of effort, I was waiting to be sure that getting this big set of data is the solution. Jul 22, 2017 at 14:54

I think you need first, data mining to export the meaning and relations in this data, then you can build your expert system that will answer you.

• I do have some training data. Do you know any particular algorithm that could work? Jul 20, 2017 at 15:00

Neural networks are the one thing I would not recommend. Your problem fits into the domain of predicate calculus, with some basic pattern recognition of the input sentences (assuming you only accept a certain type of sentences). You can do that without the need for masses of data.

First, transform your statement into a canonical representation, probably using first-order logic and simple pattern matching/string matching. For example,

I own a dog

X own/owns a/an Y

owns(I, dog)


Here you have a pattern "X own(s) a(n) Y", which you recognise in your user input. You then have a predicate owns(X, Y), which you add to your database of statements. This database you can then query. For example, Do I own a cat? could fit a question pattern Do/Does X own(s) a(n) Y?, and you can search for own(I, cat) in your DB; you will not find it, so the answer is "No". If the question is "Do I own a dog?" you will find owns(I, dog) in your database and you can reply "Yes".

This is all rather 'old' technology, but I think you will find that you will get decent results much quicker than with machine learning or statistical methods, especially if you have not much data to begin with.

A further branch to look into would be expert systems. If you're thinking in terms of programming languages, then Prolog would be well suited for this, but any language should do, really.