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..

topic include vs inherit
 
 

Hi all,

I’ve been studying the rpg.rs file, to try and understand the difference between include and inherit.  What’s really the difference between the two?  Could you provide an example where using include instead of inherit would produce a different output?

Thanks!

 

 
  [ # 1 ]

For the sake of discussion, trying to find some casual words without all the fancy Object Oriented words… I think a fundamenatl difference may be that “inherit” is preprocessed and “include” is just processed.  But, don’t hold me to this!  Especially if the topic is about Perl, there is some eye opening stuff to read about this topic.  I’m just casually chatting here.

 

 
  [ # 2 ]

No, these are Rivescript commands. Nothing to do with OOP.

The difference is priority.

If I remember correctly, included topics have a higher priority than inherited.  They both function in a similar ay, but the difference would be where there is more than one possible matched input and priority comes into play.

 

 
  [ # 3 ]

From the RiveScript Working Draft:

Topics are able to include and inherit triggers that belong to a different topic. When a topic includes another topic, it means that the triggers in another topic are made available in the topic that did the inclusion (hereby called the “source topic”, which includes triggers from the “included topic”).

When a topic inherits another topic, it means that the entire collection of triggers of the source topic and any included topics, will have a higher matching priority than the inherited topics.

Basically, if you use “include”, the entire pool of replies in both the source topic and the included one are all treated equally as though they were all in the same topic. When you “inherit” a topic, then the source topic (and its included ones, i.e. its equals), all have a higher priority than the inherited ones.

So if you had a trigger of simply “*” in the source topic, then it would be impossible to match triggers in any inherited topics, because even though * is usually the lowest-priority trigger (which ends up dead last when the replies are sorted), it’s a higher priority because of the inherits option. If you used includes instead, it would be sorted dead last as normal.

 

 
  login or register to react