AI Zone Admin Forum Add your forum

Chatbot Conference in the Netherlands on Tue 24, 2018, with international line-up! Check it out

How do AIML and other languages handle ‘negation’?
 
 

In particular, do “patterns” need to be created twice when negation is possible or is there a generic mechanism?

 

 

 
  [ # 1 ]

No, there isn’t any sort of mechanism in place for automatic negation of a pattern of words. You would need to code that for yourself, to cover possibilities of “I like pizza” or “I don’t like pizza” (or other, similar concepts of negation). AIML should be looked at as more of a database structure, or a database and template engine than anything else, really.

 

 
  [ # 2 ]

How about your program ‘O’?

 

 
  [ # 3 ]

Program O was designed to follow the AIML 1.0.1 specification with regard to how it parses inputs, so negation still needs to be handled by creating categories with the appropriate patterns. I don’t think you’re going to find an AIML interpreter/chatbot engine that automatically handles negation, nor do I feel that there should be one. This is because negation is rarely (if ever) a straight forward process. there are too many factors involved for it to be made a strictly automated process.

Either that, or I’m misunderstanding your meaning, and need more details in order to come up with a cogent, relevant response? wink

 

 
  [ # 4 ]

That is what I wanted to know. I would not be so quick to dismiss automatic handling of negation.

 

 
  [ # 5 ]

Using an open source interpreter like Program O I have been able to do some negation detection based on a custom PHP module that does sentiment analysis (pdf) (weights based on positive/negative polarity of the input string). I invoke it when responding to input like, for example, “do you like grapes” or “what do you think about Brexit”. Since program O uses a mySQL db, you can easilly populate custom tables with sentiment or other filters.

 

 
  [ # 6 ]

I didn’t know you worked with Program O in that manner, Carl. I’d be very interested in learning more about your project, if you wouldn’t mind sharing. smile

 

 
  [ # 7 ]
Peter Waksman - Jan 13, 2018:

I would not be so quick to dismiss automatic handling of negation.

While automatic handling of negation is important, I agree in part with Dave that this is not well compatible with keyword-based technologies like AIML. In order to handle negation consistently in my private AI project I can not do without grammar parsing and morphology. To name some particular cases: “unwise”, “without”, “this is not entirely false”, “I do not doubt that this is true”, and “That is not my cat”, where the latter negates “my”, but it still is a cat.

The way I see it, you can’t handle negation consistently if you can’t at least also spot negating prefixes. If AIML or such could consult a database of word stems and so convert “un-wise” to “not wise” in preprocessing, then you could get somewhere, but there would still be ambiguity in prefixes like “in-flammable”.

 

 
  [ # 8 ]
Don Patrick - Jan 14, 2018:

If AIML or such could consult a database of word stems and so convert “un-wise” to “not wise” in preprocessing, then you could get somewhere, but there would still be ambiguity in prefixes like “in-flammable”.

I’ve given that some thought as well, Don, and I’ve come to realize that if you added some sort of pre-processing to detect, say, input structure and semantics, such as some sort of NLP or POS functionality you could build a chatbot engine that would require far less volume or complexity with regard to the categories necessary to make a coherent and believable chatbot, but then you would have to construct your patterns for those categories in a very different way than it’s currently done. Instead of matching words or phrases, you might instead match syntax patterns, where your wildcards would be capturing the nouns and verbs, subjects and objects of the user’s inputs, and building responses based on the context, rather than the literal wording of the user. However, I’m still questioning whether this is a viable evolutionary step to pursue.

 

 
  [ # 9 ]

Quite. ChatScript has a POS tagger that allows matching more general “noun-verb-noun-predeterminer-location” patterns and such, though I do not know it to generally handle negation as described. Working with syntax elements covers a lot more ground than specifying individual words in a pattern, but at the same time you’ll still have to specify those words further down the line, if you want specific responses to “I had a cat” or “I had a heart attack”. ChatScript does this by matching against topics, i.e. word groups like a series of synonyms or all imaginable pets, which are also very versatile.

The main advantage I see is that you could more easily set up broad-range, generic responses, and that you can have the bot prioritise responding to the most important elements of a sentence like subject-verb-object, before it goes off on a tangent about keywords that only have minor roles in the sentence, like location. Frankly I do think it is a more versatile approach, but I can not assure you that it is less work.

 

 
  [ # 10 ]

Oh, I’m quite certain, Don, that it would, indeed, be MORE work to achieve what I’m envisioning, and certainly more than I alone can accomplish, but I can at least start with an outline of sorts, and then cobble together some sort of Proof of Concept. As to when that might be, I have not the foggiest of notions. cheese

 

 
  [ # 11 ]

That is a commendable attitude. Remember there are a lot of resources out there that you could use to save time. Stanford’s POS tagger is freely available in Python’s NLTK toolkit, and there are public databases of verbs, nouns and whatnot.
Personally I work entirely with general elements like subjects and verbs in my system, from input to knowledge database to output, without having to write any responses manually (save for general manners). So one has conversations like this:
“subject verbs object.” -> save to database
“does subject verb object?” -> check in database ->“yes/no, subject does (not) verb object.”
“which objects verbs subject?” -> check in database -> “subject verbs A, subject verbs B, and subject verbs C.”
For less robotic conversation, I find such elements are also well compatible with techniques like Carl’s sentiment analysis.

 

 
  login or register to react