ChatScript 5 Advanced User Manual -- 3 advanced patterns

5.5 advanced patterns

     Keyword Phrases :  Just put them in quotes. E.g. 

cocept: ~remove ( "take away" remove )
?: ( do you take away cheese )
      Implied concept Sets : This allows the system to find the soonest match of any of them. otherwise [] and {} take each element in turn and try to find a match, which may be later in the sentence than a later element in the set would match.

     Dictionary Keyword sets : In ChatScript, WordNet ontologies are invoked by naming the word, a ~, and the index of the meaning you want.

concept: ~buildings [ shelter~1 living_accomodations~1 building~3 ]
     Similarly you can invoke parts of speech classes on words. By default you get all of them. If you write : 

concept: ~beings [ snake mother ]
     then a sentence like "I like mothering my baby" would trigger this concept, as would "He snaked his way through the grass". But the engine has a dictionary and a part-of-speech tagger, so it often knows what part of speech a word in the sentence is.

     You can use that to help prevent false matches to concepts by adding ~n ~v ~a or ~b (adverb) after a word.

concept: ~beings [ snake~n mother~n ]
      System Functions : ^query --- to see if some fact data could be found. Many functions make no sense to call, because they are only useful on output and their behavior on the pattern side is unpredictable.
      Macros : Just as you can use sets to "share" data across rules, you can also write macros to share code.

      Pattern macros : a top-level declaration that declares a name, arguments that can be passed, and a set of script to be executed "as though the script code were in place of the original call".

      Macro names can be ordinary names or have a ^ in front of them. The arguments must always begin with ^ .

      The definition ends with the start of a new top-level declaration or end of file. E.g.

patternmacro: ^ISHAIRCOLOR(^who)
    ![not never]
    [
        ( << be ^who [blonde brunette redhead blond ] >> )
        ( << what ^who hair color >> )
    ]
?: ( ^ISHAIRCOLOR(I) ) How would I know your hair color ?
        Dual macros :  it means can be used in both pattern and output contexts.
        Literal Next \

       Question and exclamation - ? !  :  In rejoinders rule, you need to use the ? keyword. It doesn't change the match position.

t: Do you like germs?
   a: ( ? ) Why are you asking ...
   a: ( !? ) I appreciate your statement.
        More comparison test - & ? :  You can use the logical and bit-relation to test numbers. Any non-zero value passes.

s: ( _~number _0&1 ) Your number is odd
        Comparison with C++ #define in dictionarySystem.h : You can name a constant from that file as the right hand side of a comparison test by prefixing its name with #. E.g.

s: ( _~number _0=#NOUN )
        Current Topic ~ :  If the topic is currently on the pending list, then the system will match the ~ . E.g .

u: ( chocolate ~ ) I love chocolate ice cream
     A useful idiom is [~topicname ~]. This allows you to match if either the user gave keywords of the topic OR you are already in the topic. So :

u: ( << chocolate [~ice_cream ~] >> )
    would match if you only said chocolate while inside the topic, or if you said chocolate ice cream while outside the topic.

        Prefix Wildcard Spelling and Postfix Wildcard Spelling : like Sagittarius 

u: ( Sag* ) # This matches "Sagittarius" in a variety of misspellings.
        Indirect pattern elements
        Setting Match Position - @_3+ @_3- @_3

       Backward Wildcards

       Gory details about strings

       Generalizing a pattern word

       The deep view of patterns

       Interesting thing about match variables

       Precautionary note about [ ] and pattern matching retries


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值