blob: a1040035aeae55ce1e1a37e35a4e4a5f1865463a [file] [log] [blame]
<html><head><meta charset="utf-8"></meta><meta name="viewport" content="width=device-width, initial-scale=1"></meta><title>NCModel</title><link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico"></link><script type="text/javascript" src="../../../scripts/theme.js"></script><script type="text/javascript" src="../../../scripts/searchData.js" defer="true"></script><script type="text/javascript" src="../../../scripts/scastieConfiguration.js" defer="true"></script><link rel="stylesheet" href="../../../styles/nord-light.css"></link><link rel="stylesheet" href="../../../styles/scalastyle.css"></link><link rel="stylesheet" href="../../../styles/colors.css"></link><link rel="stylesheet" href="../../../styles/dotty-icons.css"></link><link rel="stylesheet" href="../../../styles/diagram.css"></link><link rel="stylesheet" href="../../../styles/filter-bar.css"></link><link rel="stylesheet" href="../../../styles/code-snippets.css"></link><link rel="stylesheet" href="../../../styles/searchbar.css"></link><link rel="stylesheet" href="../../../styles/social-links.css"></link><link rel="stylesheet" href="../../../styles/ux.css"></link><link rel="stylesheet" href="../../../styles/versions-dropdown.css"></link><link rel="stylesheet" href="../../../styles/fontawesome.css"></link><script type="text/javascript" src="../../../hljs/highlight.min.js" defer="true"></script><script type="text/javascript" src="../../../scripts/hljs-scala3.js" defer="true"></script><script type="text/javascript" src="../../../scripts/ux.js" defer="true"></script><script type="text/javascript" src="../../../scripts/common/component.js" defer="true"></script><script type="text/javascript" src="../../../scripts/common/utils.js" defer="true"></script><script type="text/javascript" src="../../../scripts/components/FilterBar.js" defer="true"></script><script type="text/javascript" src="../../../scripts/components/DocumentableList.js" defer="true"></script><script type="text/javascript" src="../../../scripts/components/Input.js" defer="true"></script><script type="text/javascript" src="../../../scripts/components/FilterGroup.js" defer="true"></script><script type="text/javascript" src="../../../scripts/components/Filter.js" defer="true"></script><script type="text/javascript" src="../../../scripts/scaladoc-scalajs.js" defer="true"></script><script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js" defer="true"></script><script type="text/javascript" src="https://d3js.org/d3.v6.min.js" defer="true"></script><script type="text/javascript" src="https://cdn.jsdelivr.net/npm/graphlib-dot@0.6.2/dist/graphlib-dot.min.js" defer="true"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dagre-d3/0.6.1/dagre-d3.min.js" defer="true"></script><script type="text/javascript" src="https://scastie.scala-lang.org/embedded.js" defer="true"></script><script type="text/javascript" src="../../../scripts/data.js" defer="true"></script><script>var pathToRoot = "../../../";</script></head><body><div id="container"><div id="leftColumn"><div id="logo"><span><div class="projectName">NLPCraft</div></span><div id="version"><div class="versions-dropdown"><div onclick="dropdownHandler()" id="dropdown-button" class="dropdownbtn dropdownbtnactive"><div class="projectVersion">1.0.0</div><div id="dropdown-content" class="dropdown-content"><input type="text" placeholder="Search..." id="dropdown-input" onkeyup="filterFunction()"></input></div></div></div></div><div class="socials"><a href="https://github.com/apache/incubator-nlpcraft"><span class="social-icon" data-icon-path="github-icon-white.png"></span></a></div></div><div id="paneSearch"></div><nav id="sideMenu2"><div class="ni expanded"><span class="nh expanded"><span class="ar"></span><a href="../../../index.html"><span>NLPCraft</span></a></span><div class="ni expanded"><span class="nh expanded"><span class="ar"></span><a href="../nlpcraft.html"><span class="micon pa"></span><span>org.apache.nlpcraft</span></a></span><div class="ni "><span class="nh "><a href="NCContext.html"><span class="micon tr"></span><span>NCContext</span></a></span></div><div class="ni "><span class="nh "><a href="NCConversation.html"><span class="micon tr"></span><span>NCConversation</span></a></span></div><div class="ni "><span class="nh "><a href="NCCuration.html"><span class="micon cl"></span><span>NCCuration</span></a></span></div><div class="ni "><span class="nh "><a href="NCDialogFlowItem.html"><span class="micon tr"></span><span>NCDialogFlowItem</span></a></span></div><div class="ni "><span class="nh "><a href="NCEntity.html"><span class="micon tr"></span><span>NCEntity</span></a></span></div><div class="ni "><span class="nh "><a href="NCEntityEnricher.html"><span class="micon tr"></span><span>NCEntityEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="NCEntityMapper.html"><span class="micon tr"></span><span>NCEntityMapper</span></a></span></div><div class="ni "><span class="nh "><a href="NCEntityParser.html"><span class="micon tr"></span><span>NCEntityParser</span></a></span></div><div class="ni "><span class="nh "><a href="NCEntityValidator.html"><span class="micon tr"></span><span>NCEntityValidator</span></a></span></div><div class="ni "><span class="nh "><a href="NCException.html"><span class="micon cl"></span><span>NCException</span></a></span></div><div class="ni "><span class="nh "><a href="NCIntentMatch.html"><span class="micon tr"></span><span>NCIntentMatch</span></a></span></div><div class="ni "><span class="nh "><a href="NCIntentSkip.html"><span class="micon cl"></span><span>NCIntentSkip</span></a></span></div><div class="ni "><span class="nh "><a href="NCLifecycle.html"><span class="micon tr"></span><span>NCLifecycle</span></a></span></div><div class="ni "><span class="nh "><a href="NCMatchedCallback.html"><span class="micon tr"></span><span>NCMatchedCallback</span></a></span></div><div class="ni expanded"><span class="nh selected"><a href="NCModel.html"><span class="micon tr"></span><span>NCModel</span></a></span></div><div class="ni "><span class="nh "><a href="NCModelClient.html"><span class="micon cl"></span><span>NCModelClient</span></a></span></div><div class="ni "><span class="nh "><a href="NCModelConfig$.html"><span class="micon ob"></span><span>NCModelConfig</span></a></span></div><div class="ni "><span class="nh "><a href="NCModelConfig.html"><span class="micon tr"></span><span>NCModelConfig</span></a></span></div><div class="ni "><span class="nh "><a href="NCPipeline.html"><span class="micon tr"></span><span>NCPipeline</span></a></span></div><div class="ni "><span class="nh "><a href="NCPipelineBuilder.html"><span class="micon cl"></span><span>NCPipelineBuilder</span></a></span></div><div class="ni "><span class="nh "><a href="NCPropertyMap.html"><span class="micon tr"></span><span>NCPropertyMap</span></a></span></div><div class="ni "><span class="nh "><a href="NCPropertyMapAdapter.html"><span class="micon cl"></span><span>NCPropertyMapAdapter</span></a></span></div><div class="ni "><span class="nh "><a href="NCRejection.html"><span class="micon cl"></span><span>NCRejection</span></a></span></div><div class="ni "><span class="nh "><a href="NCRequest.html"><span class="micon tr"></span><span>NCRequest</span></a></span></div><div class="ni "><span class="nh "><a href="NCResult$.html"><span class="micon ob"></span><span>NCResult</span></a></span></div><div class="ni "><span class="nh "><a href="NCResult.html"><span class="micon tr"></span><span>NCResult</span></a></span></div><div class="ni "><span class="nh "><a href="NCResultType.html"><span class="micon en"></span><span>NCResultType</span></a></span></div><div class="ni "><span class="nh "><a href="NCToken.html"><span class="micon tr"></span><span>NCToken</span></a></span></div><div class="ni "><span class="nh "><a href="NCTokenEnricher.html"><span class="micon tr"></span><span>NCTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="NCTokenParser.html"><span class="micon tr"></span><span>NCTokenParser</span></a></span></div><div class="ni "><span class="nh "><a href="NCTokenValidator.html"><span class="micon tr"></span><span>NCTokenValidator</span></a></span></div><div class="ni "><span class="nh "><a href="NCVariant.html"><span class="micon tr"></span><span>NCVariant</span></a></span></div><div class="ni "><span class="nh "><a href="NCVariantFilter.html"><span class="micon tr"></span><span>NCVariantFilter</span></a></span></div></div><div class="ni"><span class="nh "><span class="ar"></span><a href="nlp/enrichers.html"><span class="micon pa"></span><span>org.apache.nlpcraft.nlp.enrichers</span></a></span><div class="ni "><span class="nh "><a href="nlp/enrichers/NCBracketsTokenEnricher.html"><span class="micon cl"></span><span>NCBracketsTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/enrichers/NCDictionaryTokenEnricher.html"><span class="micon cl"></span><span>NCDictionaryTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/enrichers/NCEnStopWordsTokenEnricher.html"><span class="micon cl"></span><span>NCEnStopWordsTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/enrichers/NCOpenNLPTokenEnricher.html"><span class="micon cl"></span><span>NCOpenNLPTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/enrichers/NCQuotesTokenEnricher.html"><span class="micon cl"></span><span>NCQuotesTokenEnricher</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/enrichers/NCSwearWordsTokenEnricher.html"><span class="micon cl"></span><span>NCSwearWordsTokenEnricher</span></a></span></div></div><div class="ni"><span class="nh "><span class="ar"></span><a href="nlp/parsers.html"><span class="micon pa"></span><span>org.apache.nlpcraft.nlp.parsers</span></a></span><div class="ni "><span class="nh "><a href="nlp/parsers/NCNLPEntityParser.html"><span class="micon cl"></span><span>NCNLPEntityParser</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/parsers/NCOpenNLPEntityParser.html"><span class="micon cl"></span><span>NCOpenNLPEntityParser</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/parsers/NCOpenNLPTokenParser.html"><span class="micon cl"></span><span>NCOpenNLPTokenParser</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/parsers/NCSemanticElement.html"><span class="micon tr"></span><span>NCSemanticElement</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/parsers/NCSemanticEntityParser.html"><span class="micon cl"></span><span>NCSemanticEntityParser</span></a></span></div></div><div class="ni"><span class="nh "><span class="ar"></span><a href="nlp/stemmer.html"><span class="micon pa"></span><span>org.apache.nlpcraft.nlp.stemmer</span></a></span><div class="ni "><span class="nh "><a href="nlp/stemmer/NCEnStemmer.html"><span class="micon cl"></span><span>NCEnStemmer</span></a></span></div><div class="ni "><span class="nh "><a href="nlp/stemmer/NCStemmer.html"><span class="micon tr"></span><span>NCStemmer</span></a></span></div></div></div></nav></div><div id="main"><div id="leftToggler"><span class="icon-toggler"></span></div><div id="scaladoc-searchBar"></div><main id="main-content"><div class="breadcrumbs container"><a href="../../../index.html">NLPCraft</a>/<a href="../nlpcraft.html">org.apache.nlpcraft</a>/<a href="NCModel.html">NCModel</a></div><div id="content"><div><div class="cover-header"><span class="micon tr"></span><h1>NCModel</h1></div><div class="signature monospace"><span class="annotations monospace"></span><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">trait </span></span><a href="NCModel.html" class="documentableName ">NCModel</a><span>(<span t="k"></span><span t="k"></span>cfg: <a href="NCModelConfig.html" t="t">NCModelConfig</a>, <span t="k"></span>pipeline: <a href="NCPipeline.html" t="t">NCPipeline</a>)</span></div></div><div class="cover"><div class="doc"><p>Data model.</p>
<p>Data model is a key entity in NLPCraft and contains:</p>
<ul>
<li>Model <a href="NCModel.html#getConfig-0">configuration</a>.</li>
<li>Model <a href="NCModel.html#getPipeline-0">processing pipeline</a>.</li>
<li>Life-cycle callbacks.</li>
</ul>
<p>NLPCraft employs model-as-a-code approach where entire data model is an implementation of just this interface.
The instance of this interface is passed to <a href="NCModelClient.html">NCModelClient</a> class.
Note that the model-as-a-code approach natively supports any software life cycle tools and frameworks like various
build tools, CI/SCM tools, IDEs, etc. You don't need any additional tools to manage
some aspects of your data models - your entire model and all of its components are part of your project's
source code.</p>
</div><dl class="attributes"><dt>See also:</dt><dd><div><div><p><a href="NCModelClient.html">NCModelClient</a></p>
</div><div><p><a href="NCModelConfig.html">NCModelConfig</a></p>
</div><div><p><a href="NCPipeline.html">NCPipeline</a></p>
</div></div></dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L39">NCModel.scala</a></dd></dl></div><div class="tabs single"><div class="names"><button data-togglable="graph" class="tab showGraph">Graph</button><button data-togglable="supertypes" class="tab ">Supertypes</button></div><div class="contents"><div data-togglable="graph" class="tab showGraph"><div id="inheritance-diagram" class="diagram-class showGraph"><input value="Reset zoom" type="button" class="btn" onclick="zoomOut()"></input><svg id="graph"></svg><script type="text/dot" id="dot"> digraph g {
node0 [id=node0, label="<span style=\"color: #FFFFFF;\">trait <a href=\"NCModel.html\" t=\"t\">NCModel</a></span>", style="fill: #1CAACF;"];
node1 [id=node1, label="<span style=\"color: #FFFFFF;\">class <span data-unresolved-link=\"\" t=\"t\">Object</span></span>", style="fill: #45AD7D;"];
node2 [id=node2, label="<span style=\"color: #FFFFFF;\">class <span data-unresolved-link=\"\" t=\"t\">Any</span></span>", style="fill: #45AD7D;"];
node3 [id=node3, label="<span style=\"color: #FFFFFF;\">trait <span data-unresolved-link=\"\" t=\"t\">Matchable</span></span>", style="fill: #1CAACF;"];
node0 -> node1;
node1 -> node2;
node1 -> node3;
node3 -> node2;
}
</script></div></div><div data-togglable="supertypes" class="tab "><div class="symbol monospace"><div>class <span data-unresolved-link="" t="t">Object</span></div><div>trait <span data-unresolved-link="" t="t">Matchable</span></div><div>class <span data-unresolved-link="" t="t">Any</span></div></div></div></div></div><div class="documentableFilter"><div class="filterUpperContainer"><button class="filterToggleButton" data-test-id="filterToggleButton">
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
<path d="M0 0h24v24H0z" fill="none"/>
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
</svg>
</button><input class="filterableInput" placeholder="Filter all members" data-test-id="filterBarInput"></input></div><div class="filterLowerContainer"></div></div><div class="membersList"><div class="tabs"><div class="names"><button data-togglable="Value members" class="tab selected">Value members</button></div><div class="contents"><div data-togglable="Value members" class="tab selected"><h2 data-togglable="Value members">Value members</h2><div class="documentableList"><h3 class="groupHeader">Concrete methods</h3><div class="documentableElement" id="getConfig-0"><a link="NCModel.html#getConfig-0" class="documentableAnchor"></a><div><span class="annotations monospace"></span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#getConfig-0" class="documentableName ">getConfig</a><span>: <a href="NCModelConfig.html" t="t">NCModelConfig</a></span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>Gets model configuration.</p>
</div><div class="cover"><div class="doc"><p>Gets model configuration.</p>
</div><dl class="attributes"><dt>Returns:</dt><dd><p>Model configuration.</p>
</dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L45">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="getPipeline-0"><a link="NCModel.html#getPipeline-0" class="documentableAnchor"></a><div><span class="annotations monospace"></span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#getPipeline-0" class="documentableName ">getPipeline</a><span>: <a href="NCPipeline.html" t="t">NCPipeline</a></span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>Gets model NLP processing pipeline.</p>
</div><div class="cover"><div class="doc"><p>Gets model NLP processing pipeline.</p>
</div><dl class="attributes"><dt>Returns:</dt><dd><p>NLP processing pipeline.</p>
</dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L52">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="onContext-38d"><a link="NCModel.html#onContext-38d" class="documentableAnchor"></a><div><span class="annotations monospace"><a href="https://www.scala-lang.org/api/2.13.8/scala/throws.html" t="t">@throws</a>(scala.throws.$lessinit$greater$default$1[org.apache.nlpcraft.NCRejection]) </span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#onContext-38d" class="documentableName ">onContext</a><span>(<span t="k"></span><span t="k"></span>ctx: <a href="NCContext.html" t="t">NCContext</a>): <a href="https://www.scala-lang.org/api/2.13.8/scala/Option.html" t="t">Option</a>[<a href="NCResult.html" t="t">NCResult</a>]</span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>A callback that is called when a fully assembled query context is ready. This is the first of the callbacks
that is called on the model and right before the intent matching is performed. It's called always once per
input query processing. Typical use case for this callback is to perform logging, debugging, statistic or
usage collection, explicit update or initialization of conversation context, security audit or validation, etc.</p>
</div><div class="cover"><div class="doc"><p>A callback that is called when a fully assembled query context is ready. This is the first of the callbacks
that is called on the model and right before the intent matching is performed. It's called always once per
input query processing. Typical use case for this callback is to perform logging, debugging, statistic or
usage collection, explicit update or initialization of conversation context, security audit or validation, etc.</p>
<p>Default implementation returns <code>None</code>.</p>
</div><dl class="attributes"><dt>Value parameters:</dt><dd><dl class="attributes"><dt>ctx</dt><dd><p>Input query context.</p>
</dd></dl></dd><dt>Returns:</dt><dd><p>Optional query result to return interrupting the default processing workflow. Specifically, if
this method returns a <code>Some</code> result, it will be returned to the caller immediately interrupting
default processing workflow. If the method returns <code>None</code> - the default processing flow will continue.</p>
</dd><dt>Throws:</dt><dd><dl class="attributes"><dt>NCRejection</dt><dd><p>This callback can throw the rejection exception to abort input query processing.</p>
</dd></dl></dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L69">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="onError-fffff759"><a link="NCModel.html#onError-fffff759" class="documentableAnchor"></a><div><span class="annotations monospace"></span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#onError-fffff759" class="documentableName ">onError</a><span>(<span t="k"></span><span t="k"></span>ctx: <a href="NCContext.html" t="t">NCContext</a>, <span t="k"></span>e: <a href="https://www.scala-lang.org/api/2.13.8/scala.html#Throwable" t="t">Throwable</a>): <a href="https://www.scala-lang.org/api/2.13.8/scala/Option.html" t="t">Option</a>[<a href="NCResult.html" t="t">NCResult</a>]</span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>A callback that is called when intent callback failed with unexpected exception. Note that this callback may
not be called at all, and if called - it's called only once. Typical use case for this callback is
to perform logging, debugging, statistic or usage collection, explicit update or initialization of conversation
context, security audit or validation, etc.</p>
</div><div class="cover"><div class="doc"><p>A callback that is called when intent callback failed with unexpected exception. Note that this callback may
not be called at all, and if called - it's called only once. Typical use case for this callback is
to perform logging, debugging, statistic or usage collection, explicit update or initialization of conversation
context, security audit or validation, etc.</p>
<p>Default implementation is a no-op returning <code>None</code>.</p>
</div><dl class="attributes"><dt>Value parameters:</dt><dd><dl class="attributes"><dt>ctx</dt><dd><p>Intent match context - the same instance that's passed to the matched intent that produced this error.</p>
</dd><dt>e</dt><dd><p>Failure exception.</p>
</dd></dl></dd><dt>Returns:</dt><dd><p>Optional query result to return interrupting the default workflow. Specifically, if this method
returns a <code>Some</code> result, it will be returned to the caller immediately overriding default
behavior and existing query result or error processing, if any. If the method returns <code>None</code> - the
default processing flow will continue.</p>
</dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L154">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="onMatchedIntent-946"><a link="NCModel.html#onMatchedIntent-946" class="documentableAnchor"></a><div><span class="annotations monospace"><a href="https://www.scala-lang.org/api/2.13.8/scala/throws.html" t="t">@throws</a>(scala.throws.$lessinit$greater$default$1[org.apache.nlpcraft.NCRejection]) </span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#onMatchedIntent-946" class="documentableName ">onMatchedIntent</a><span>(<span t="k"></span><span t="k"></span>ctx: <a href="NCContext.html" t="t">NCContext</a>, <span t="k"></span>im: <a href="NCIntentMatch.html" t="t">NCIntentMatch</a>): <a href="https://www.scala-lang.org/api/2.13.8/scala/Boolean.html" t="t">Boolean</a></span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>A callback that is called when intent was successfully matched but right before its callback is called. This
callback is called after <a href="NCModel.html#onContext-38d">onContext</a> is called and may be called multiple times depending on its return
value. If <code>true</code> is returned than the default processing workflow will continue and the
matched intent's callback will be called. However, if <code>false</code> is returned than the entire existing set of
parsing variants will be matched against all declared intents again. Returning <code>false</code> allows this
method to alter the state of the model (like soft-reset conversation or change metadata) and force a
full re-evaluation of the parsing variants against all declared intents again.</p>
</div><div class="cover"><div class="doc"><p>A callback that is called when intent was successfully matched but right before its callback is called. This
callback is called after <a href="NCModel.html#onContext-38d">onContext</a> is called and may be called multiple times depending on its return
value. If <code>true</code> is returned than the default processing workflow will continue and the
matched intent's callback will be called. However, if <code>false</code> is returned than the entire existing set of
parsing variants will be matched against all declared intents again. Returning <code>false</code> allows this
method to alter the state of the model (like soft-reset conversation or change metadata) and force a
full re-evaluation of the parsing variants against all declared intents again.</p>
<p>Note that user logic should be careful not to induce infinite loop in this behavior.
Note that this callback may not be called at all based on the return value of <a href="NCModel.html#onContext-38d">onContext</a> callback.
Typical use case for this callback is to perform logging, debugging, statistic or usage collection, explicit
update or initialization of conversation context, security audit or validation, etc.</p>
<p>By default, this method returns <code>true</code>.</p>
</div><dl class="attributes"><dt>Value parameters:</dt><dd><dl class="attributes"><dt>im</dt><dd><p>Intent match context - the same instance that's passed to the matched intent callback.</p>
</dd></dl></dd><dt>Returns:</dt><dd><p>If <code>true</code> is returned than the default workflow will continue and the matched intent's
callback will be called. However, if <code>false</code> is returned than the entire existing set of
parsing variants will be matched against all declared intents again. Returning false allows this
method to alter the state of the model (like soft-reset conversation or change metadata) and force
the re-evaluation of the parsing variants against all declared intents again. Note that user logic
should be careful not to induce infinite loop in this behavior.</p>
</dd><dt>Throws:</dt><dd><dl class="attributes"><dt>NCRejection</dt><dd><p>This callback can throw the rejection exception to abort user request processing. In this
case the <a href="NCModel.html#onRejection-4fa">onRejection</a> callback will be called next.</p>
</dd></dl></dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L98">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="onRejection-4fa"><a link="NCModel.html#onRejection-4fa" class="documentableAnchor"></a><div><span class="annotations monospace"></span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#onRejection-4fa" class="documentableName ">onRejection</a><span>(<span t="k"></span><span t="k"></span>ctx: <a href="NCContext.html" t="t">NCContext</a>, <span t="k"></span>im: <a href="https://www.scala-lang.org/api/2.13.8/scala/Option.html" t="t">Option</a>[<a href="NCIntentMatch.html" t="t">NCIntentMatch</a>], <span t="k"></span>e: <a href="NCRejection.html" t="t">NCRejection</a>): <a href="https://www.scala-lang.org/api/2.13.8/scala/Option.html" t="t">Option</a>[<a href="NCResult.html" t="t">NCResult</a>]</span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>A callback that is called when intent callback threw NCRejection exception. This callback is called
after <a href="NCModel.html#onMatchedIntent-946">onMatchedIntent</a> is called. Note that this callback may not be called at all,
and if called - it's called only once. Typical use case for this callback is to perform logging, debugging,
statistic or usage collection, explicit update or initialization of conversation context, security audit or
validation, etc.</p>
</div><div class="cover"><div class="doc"><p>A callback that is called when intent callback threw NCRejection exception. This callback is called
after <a href="NCModel.html#onMatchedIntent-946">onMatchedIntent</a> is called. Note that this callback may not be called at all,
and if called - it's called only once. Typical use case for this callback is to perform logging, debugging,
statistic or usage collection, explicit update or initialization of conversation context, security audit or
validation, etc.</p>
<p>Default implementation is a no-op returning <code>None</code>.</p>
</div><dl class="attributes"><dt>Value parameters:</dt><dd><dl class="attributes"><dt>ctx</dt><dd><p>Intent match context - the same instance that's passed to the matched intent that produced this error.</p>
</dd><dt>e</dt><dd><p>Rejection exception.</p>
</dd><dt>im</dt><dd><p>Optional intent match context - the same instance that's passed to the matched intent callback
that produced this result. It is <code>None</code> if rejection was triggered outside the intent callback.</p>
</dd></dl></dd><dt>Returns:</dt><dd><p>Optional query result to return interrupting the default workflow. Specifically, if this method
returns a <code>Some</code> result, it will be returned to the caller immediately overriding default behavior
and existing query result or error processing, if any. If the method returns <code>None</code> - the default
processing flow will continue.</p>
</dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L137">NCModel.scala</a></dd></dl></div></div></div></div></div><div class="documentableElement" id="onResult-fffffaf3"><a link="NCModel.html#onResult-fffffaf3" class="documentableAnchor"></a><div><span class="annotations monospace"></span></div><div class="header monospace"><div class="signature"><span class="modifiers"></span><span class="kind"><span t="k">def </span></span><a href="NCModel.html#onResult-fffffaf3" class="documentableName ">onResult</a><span>(<span t="k"></span><span t="k"></span>ctx: <a href="NCContext.html" t="t">NCContext</a>, <span t="k"></span>im: <a href="NCIntentMatch.html" t="t">NCIntentMatch</a>, <span t="k"></span>res: <a href="NCResult.html" t="t">NCResult</a>): <a href="https://www.scala-lang.org/api/2.13.8/scala/Option.html" t="t">Option</a>[<a href="NCResult.html" t="t">NCResult</a>]</span></div></div><div class="docs"><span class="modifiers"></span><div><div class="originInfo"></div><div class="memberDocumentation"><div class="documentableBrief doc"><p>A callback that is called when successful result is obtained from the intent callback and right before
sending it back to the caller. This callback is called after <a href="NCModel.html#onMatchedIntent-946">onMatchedIntent</a> is called.
Note that this callback may not be called at all, and if called - it's called only once. Typical use case
for this callback is to perform logging, debugging, statistic or usage collection, explicit update or
initialization of conversation context, security audit or validation, etc.</p>
</div><div class="cover"><div class="doc"><p>A callback that is called when successful result is obtained from the intent callback and right before
sending it back to the caller. This callback is called after <a href="NCModel.html#onMatchedIntent-946">onMatchedIntent</a> is called.
Note that this callback may not be called at all, and if called - it's called only once. Typical use case
for this callback is to perform logging, debugging, statistic or usage collection, explicit update or
initialization of conversation context, security audit or validation, etc.</p>
<p>Default implementation is a no-op returning <code>None</code>.</p>
</div><dl class="attributes"><dt>Value parameters:</dt><dd><dl class="attributes"><dt>im</dt><dd><p>Intent match context - the same instance that's passed to the matched intent callback
that produced this result.</p>
</dd><dt>res</dt><dd><p>Existing result.</p>
</dd></dl></dd><dt>Returns:</dt><dd><p>Optional query result to return interrupting the default workflow. Specifically, if this
method returns a <code>Some</code> result, it will be returned to the caller immediately overriding
default behavior and existing query result or error processing, if any. If the method returns <code>None</code> -
the default processing flow will continue.</p>
</dd><dt>Source:</dt><dd><a href="https://github.com/apache/incubator-nlpcraft/blob/master/nlpcraft/src/main/scala/org/apache/nlpcraft/NCModel.scala#L117">NCModel.scala</a></dd></dl></div></div></div></div></div></div></div></div></div></div></div></div></main><footer><div id="generated-by"><span class="footer-text">Generated by</span><a href="https://github.com/lampepfl/dotty/tree/master/scaladoc"><img src="../../../images/scaladoc_logo.svg" alt="scaladoc" class="scaladoc_logo"></img><img src="../../../images/scaladoc_logo_dark.svg" alt="scaladoc" class="scaladoc_logo_dark"></img></a></div><span id="footer-text">Apache NLPCraft</span><div class="socials"><span class="footer-text">Social links</span><a href="https://github.com/apache/incubator-nlpcraft"><span class="social-icon" data-icon-path="github-icon-black.png"></span></a></div><div class="mode"><span class="footer-text">Mode</span><label id="theme-toggle" class="switch"><input type="checkbox"></input><span class="slider"></span></label></div><span class="go-to-top-icon"><a href="#container"><span class="icon-vertical_align_top"></span><span class="footer-text">Back to top</span></a></span></footer></div></div></body></html>