Package org.apache.nlpcraft.model
Interface NCIntentMatch
-
- All Superinterfaces:
NCMetadata
,Serializable
public interface NCIntentMatch extends NCMetadata, Serializable
An intent match context that can be passed into the callback of the matched intent. Note that when usingNCIntent
andNCIntentTerm
annotations the callback method can be defined parameter-less (and this context won't be passed in). If used, intent context must be the 1st formal parameter in intent callback.Read full documentation in Intent Matching section and review examples.
- See Also:
NCIntent
,NCIntentTerm
,NCIntentSkip
,NCIntentSample
,NCIntentSampleRef
,NCIntentRef
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description NCContext
getContext()
Gets context of the user input query.String
getIntentId()
Gets ID of the matched intent.List<List<NCToken>>
getIntentTokens()
Gets a subset of tokens representing matched intent.List<NCToken>
getTermTokens(int idx)
Gets tokens for given term.List<NCToken>
getTermTokens(String termId)
Gets tokens for given term.NCVariant
getVariant()
Gets sentence parsing variant that produced the matching for this intent.-
Methods inherited from interface org.apache.nlpcraft.model.NCMetadata
getMetadata, meta, meta, metaOpt, metax
-
-
-
-
Method Detail
-
getIntentId
String getIntentId()
Gets ID of the matched intent.- Returns:
- ID of the matched intent.
-
getContext
NCContext getContext()
Gets context of the user input query.- Returns:
- Original query context.
-
getIntentTokens
List<List<NCToken>> getIntentTokens()
Gets a subset of tokens representing matched intent. This subset is grouped by the matched terms where anull
sub-list defines an optional term. Order and index of sub-lists corresponds to the order and index of terms in the matching intent. Number of sub-lists will always be the same as the number of terms in the matched intent.Note that unlike
getVariant()
method this method returns only subset of the tokens that were part of the matched intent. Specifically, it will not return tokens for free words, stopwords or unmatched ("dangling") tokens.Consider using
NCIntentTerm
annotation instead for simpler access to intent tokens.- Returns:
- List of list of tokens representing matched intent.
- See Also:
getVariant()
,NCIntentTerm
-
getTermTokens
List<NCToken> getTermTokens(int idx)
Gets tokens for given term. This is a companion method forgetIntentTokens()
.Consider using
NCIntentTerm
annotation instead for simpler access to intent tokens.- Parameters:
idx
- Index of the term (starting from0
).- Returns:
- List of tokens, potentially
null
, for given term. - See Also:
NCIntentTerm
,getTermTokens(String)
-
getTermTokens
List<NCToken> getTermTokens(String termId)
Gets tokens for given term. This is a companion method forgetIntentTokens()
.Consider using
NCIntentTerm
annotation instead for simpler access to intent tokens.- Parameters:
termId
- ID of the term for which to get tokens.- Returns:
- List of tokens, potentially
null
, for given term. - See Also:
NCIntentTerm
,getTermTokens(int)
-
getVariant
NCVariant getVariant()
Gets sentence parsing variant that produced the matching for this intent. Returned variant is one of the variants provided byNCContext.getVariants()
methods. Note that tokens returned by this method are a superset of the tokens returned bygetIntentTokens()
method, i.e. not all tokens from this variant may have been used in matching of the winning intent.- Returns:
- Sentence parsing variant that produced the matching for this intent.
- See Also:
getIntentTokens()
-
-