AI Zone Admin Forum Add your forum

NEWS: Chatbots.org survey on 3000 US and UK consumers shows it is time for chatbot integration in customer service!read more..

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.

 

 
  [ # 12 ]
Dave Morton - Jan 14, 2018:

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

My issue with chatbots has always been repetitive preprogrammed responses. There are ways to mitigate this. Negation (or sentiment analysis in general) is a good example of where most chatbots fail to reflect the sentiment of a string or series of strings (user input) because they tend to rely on literal pattern matching.

Using POS combined with sentiment analysis to construct a more emotional response is possible using a PHP or Python interpreter linked to a db like mySQL (to store the static, or even dynamic, data used for POS and sentiment analysis). The interpreter handles the input string parsing (cleaning to make it machine readable) and output string presentation (making the output string human readable).  AIML uses a simple scoring system for choosing the “best” response. Due to the recursive nature of AIML (the input can be serially modified and cycled through the scoring system using, for instance, <srai> until a solution is found).  Custom tags can be used to trigger additional processing like calling a summarizing web search data scrape to reply to contemporary queries (like what is the current weather or current events), or to choose between a positive or negative response. 

This does not really address detecting negation in the input string, but since a POS framework is accessible (with some additional effort installing and understanding how POS tagging works) by interpreters like Program O that use a db like mySQL using POS detecting negation can be achieved with some degree of satifaction.

 

 
  [ # 13 ]

Here’s Alaric Schenk’s general approach to negation in AIML, and he’s as good as they get in that scripting language.

 

 
  login or register to react