Annotation Type NCIntentSample

  • @Retention(RUNTIME)
    public @interface NCIntentSample
    Annotation to define samples of the user input that should match an intent. This annotation should be used together with NCIntent or NCIntentRef annotations on the callback methods. Method can have multiple annotations of this type and each annotation can define multiple input examples. See similar NCIntentSampleRef annotation that allows to load samples from external resources like file or URL.

    The corpus of intent samples serve several important roles in NLPCraft:

    • It provide code level documentation on what type of user input given intent is supposed to match on. In many cases having NCIntent and NCIntentSample annotations on the intent callback method allows to see all the main ingredients of the language comprehension in one place.
    • It provides a necessary corpus for automated unit and regression testing used by NCTestAutoModelValidator class from built-in test framework. This class auto-validates that provided samples are matched on by their corresponding intents.
    • This corpus is used by various statistical tools like synonyms tool and category value enrichment. Both of these tools utilize Google's BERT and Facebook fasttext models and require at least minimal corpus of samples for each intent.

    Here's an example of using this annotation (from LightSwitch example):

     @NCIntent("intent=act term(act)={has(tok_groups(), 'act')} term(loc)={trim(tok_id()) == 'ls:loc'}*")
         "Turn the lights off in the entire house.",
         "Switch on the illumination in the master bedroom closet.",
         "Get the lights on.",
         "Please, put the light out in the upstairs bedroom."
     def onMatch(
         @NCIntentTerm("act") actTok: NCToken,
         @NCIntentTerm("loc") locToks: List[NCToken]
     ): NCResult = {

    Read full documentation in Intent Matching section and review examples.

    See Also:
    NCIntentSampleRef, NCIntent, NCIntentRef, NCIntentTerm, NCIntentSkip, NCIntentMatch, NCModel.onMatchedIntent(NCIntentMatch), NCTestAutoModelValidator
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      String[] value
      Gets a list of user input samples that should match corresponding intent.
    • Element Detail

      • value

        String[] value
        Gets a list of user input samples that should match corresponding intent. This annotation should be attached the intent callback method.
        Set of user input examples that should match corresponding intent.