Annotation Type NCIntentSampleRef

  • @Retention(RUNTIME)
    public @interface NCIntentSampleRef
    Annotation to define samples of the user input that should match an intent. This annotation allows to load these samples from the external sources like local file or URL and 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 NCIntentSample annotation that allows to define samples in place.

    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:

     NCResult onMatch(
          NCIntentMatch ctx,
          @NCIntentTerm("nums") List<NCToken> numToks
     ) {

    Read full documentation in Intent Matching section and review examples.

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

      Required Elements 
      Modifier and Type Required Element Description
      String value
      Local file path, classpath resource path or URL supported by URL class.
    • Element Detail

      • value

        String value
        Local file path, classpath resource path or URL supported by URL class. The content of the source should be a new-line separated list of string. Empty strings and strings starting with '#" (hash) symbol will be ignored. This annotation should be attached the intent callback method. Note that using this annotation is equivalent to using NCIntentSample annotation and listing all of its samples in place instead of an external source.
        Local file path, classpath resource path or URL supported by URL class.