Langage d'intention NlpCraft IDL

Cet article est la suite de l'article « Conception d'intentions avec Apache NlpCraft » et contient une description dĂ©taillĂ©e des fonctionnalitĂ©s du langage de dĂ©finition d'intention NlpCraft IDL, créé pour une utilisation dans des projets NLP basĂ©s sur le systĂšme Apache NlpCraft . La prise en charge de NlpCraft IDL a Ă©tĂ© ajoutĂ©e au systĂšme depuis la version 0.7.5 .   





La nouvelle version du langage de dĂ©finition des intentions dĂ©claratives, appelĂ©e NlpCraft IDL (NlpCraft Intents Definition Language), a grandement simplifiĂ© le processus de travail avec les intentions dans les moteurs de dialogue et de recherche construits sur la base du projet Apache NlpCraft et a en mĂȘme temps Ă©tendu les capacitĂ©s. du systĂšme.  





NlpCraft IDL est un langage déclaratif qui vous permet de créer des définitions d' intention à utiliser dans les modÚles Apache NlpCraft.





Commençons par des exemples dĂ©montrant les capacitĂ©s gĂ©nĂ©rales du langage, fournissons les explications nĂ©cessaires, puis dĂ©crivons les constructions du langage un peu plus formellement. 





, , NLP , .





, NlpCraft IDL

intent=xa
    flow="^(?:login)(^:logout)*$"
    meta={'enabled': true}
    term(a)={!(tok_id()) != "z"}[1,3]
    term(b)={
        meta_intent('enabled') == true &&
        month() == 1
    } 
    term(c)~{
        @tokId = tok_id()
        @usrTypes = meta_model('user_types')

        (tokId == 'order' || tokId == 'order_cancel') &&   
         has_all(@usrTypes, list(1, 2, 3) &&
         abs(meta_tok('order:size')) > 10
        )
   } 
      
      



:





  • - “xa”. 





  • terms. Term - , , .





    • (a) - “z”,  ( term =) . 





    • (b) - -  ”enabled” . , - month().





    • (c) - ( term ~) “order” “order_cancel”. , . , . 





  • Flow. , , “login”, “logout”. , . .     





  • Meta. , , .





intent=xb
    flow=/#flowModelMethod/
    ordered=true
    term(a)=/org.mypackage.MyClass#termMethod/?
    fragment(frag)
      
      



:  





  • - “xb”. 





  • term (”a”, , “?“, ), -  org.mypackage.MyClass#termMethod. 





  • Fragment “frag” terms ,  , terms. “frag” import.





  • Flow , flowModelMethod.





- .  









, NlpCraft IDL . .





  • , NlpCraft IDL   . .





  • . .  





  • , . URL import. , IDE (, , Intellij Idea , ). , . : 1, 2.  





NlpCraft IDL

flow, fragment, import, intent, meta, ordered, term, true, false, null.





  • intent, flow, fragment, meta, ordered, term - . 





  • fragment terms, . 





  • import - fragment, intent import.





  • true, false, null - , .





NlpCraft IDL

, :





  • import





  • fragment





  • intent





. , IDE . import fragment .  





“import” URL .





: import('http://mysite.com/nlp/idls/external.idl)







“fragment” terms. Terms . 





fragment:





fragment=buzz term~{tok_id() == 'x:alarm'}







fragment c ‘a’ ‘b’:





fragment=p1
    term={
        meta_frag('a') &&
        has_any(get(meta_frag('b'), ''), list(1, 2))
    }
      
      



fragment . ‘a’ ‘b’ . 





intent=i1
    fragment(p1, {'a': true, 'b': {'': [1, 2, 3]}})
      
      



. - , . "timeIntent". 





@NCIntentRef("timeIntent")
fun onTimeMatch(
    ctx: NCIntentMatch, 
    @NCIntentTerm("t1") tok: NCToken
): NCResult { ... }
      
      



terms

. Term - . term , term. - . 





term:





  • term. .





  • . . , , “t1”.





  • term. . term: 





    • “~“ - .





    • “=“ - .  





    : term(nums)~{tok_id() == 'nlpcraft:num'}







    term terms , . 





  • term. . term: . 





    :





    • term(nums)={tok_id() == 'nlpcraft:num'}







    • term(nums)~{true}







    • term~/org.mypackage.MyClass#termMethod/?







    term. 





  • . . : 





    • [M, N] - N M .





    • * - , [0, ∞]





    • + - , [1, ∞]





    • ? - 0 1 , [0, 1]





    :





    • term(nums)={tok_id() == 'nlpcraft:num'}[1,2]



      - “nlpcraft:num”.





    • term(nums)={tok_id() == 'nlpcraft:num'}*



      - “nlpcraft:num”.





NlpCraft IDL. 





:





  • - , . : tok_id(), tok_groups(), tok_parent().





  • NLP - , , , -. : tok_lemma(), tok_is_wordnet(), tok_swear().





  • , - ..  : tok_value(), tok_is_permutated(), tok_is_direct().





  • - , user agent. : req_tstamp(), req_addr(), req_agent().





  • - , , ..  : meta_model('my:prop'), meta_tok('nlpcraft:num:unit'), meta_user('my:prop').





  • , NER . , “geo:city“ ,  . 





  • - , . : user_admin(), comp_name(), user_signup_tstamp().





  • - , .. : meta_sys('java.home'), now(), day_of_week().





  • , , .. : lowercase("TeXt"), abs(-1.5), distinct(list(1, 2, 2, 3, 1)).





-





term - , . 





, , :





term(t2)={
    @a = meta_model('a')
    @list = list(1, 2, 3, 4)

    (@a == 42 || @a == 44) && has_all(@list, list(3, 2))
}
      
      



@. . 





, NlpCraft IDL term . java, scala, kotlin, groovy java based term. NlpCraft IDL , .    





: term(a)=/MyClass#myMethod/







, , .





Fragment

Fragment terms, .





Flow

, . 





regex, .  





: flow="^(?:login)(^:logout)*$"



 





, , “login”, “logout”. 





, , Java-based , term. 









@NCIntent("intent=x 
    flow=/com.company.dialog.Flow#customFlow/ 
    term~{tok_id() == 'some_id'}"
)
def onX(): NCResult = { .. }
      
      



, customFlow(), , , boolean. 





Meta

. JSON.





Ordered flag

. false. - terms .  





, , NlpCraft IDL, java based . ? , , - . 





NlpCraft IDL.





  • . DSL . . 





  • NlpCraft IDL , IDL , , .





  • . . , DSL .  





  • java based . Apache NlpCraft . NlpCraft IDL .





J'espĂšre que vous avez pu avoir une premiĂšre idĂ©e des capacitĂ©s du langage d'intention NlpCraft IDL et des types de problĂšmes qui peuvent ĂȘtre rĂ©solus avec son aide. Ici , vous trouverez une description dĂ©taillĂ©e de la langue et de ses capacitĂ©s. Des exemples supplĂ©mentaires de modĂšles créés en java, kotlin, groovy et scala, utilisant NlpCraft IDL pour dĂ©finir les intentions, sont disponibles dans le github du projet.








All Articles