blob: c8286a68e16c60c69702b137c0825919ea6caf37 [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (11.0.2) on Fri Jul 30 09:54:56 PDT 2021 -->
<title>NCIntentSample (Apache NLPCraft 0.9.0)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2021-07-30">
<link rel="stylesheet" type="text/css" href="../../../../stylesheet.css" title="Style">
<link rel="stylesheet" type="text/css" href="../../../../jquery/jquery-ui.css" title="Style">
<script type="text/javascript" src="../../../../script.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip/dist/jszip.min.js"></script>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils.min.js"></script>
<!--[if IE]>
<script type="text/javascript" src="../../../../jquery/jszip-utils/dist/jszip-utils-ie.min.js"></script>
<![endif]-->
<script type="text/javascript" src="../../../../jquery/jquery-3.3.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-migrate-3.0.1.js"></script>
<script type="text/javascript" src="../../../../jquery/jquery-ui.js"></script>
</head>
<body>
<script type="text/javascript"><!--
try {
if (location.href.indexOf('is-external=true') == -1) {
parent.document.title="NCIntentSample (Apache NLPCraft 0.9.0)";
}
}
catch(err) {
}
//-->
var pathtoroot = "../../../../";
var useModuleDirectories = true;
loadScripts(document, 'script');</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
<header role="banner">
<nav role="navigation">
<div class="fixedNav"><link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"> <script src="https://nlpcraft.apache.org/javadoc/resources/sh/scripts/XRegExp.js" type="text/javascript"></script> <script src="https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shCore.js" type="text/javascript"></script> <script src="https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shAutoloader.js" type="text/javascript"></script> <link href="https://nlpcraft.apache.org/javadoc/resources/sh/styles/shCoreNLPCraft.css" rel="stylesheet" type="text/css" title="Style"> <link href="https://nlpcraft.apache.org/javadoc/resources/sh/styles/shThemeNLPCraft.css" rel="stylesheet" type="text/css" title="Style"> <link href="https://fonts.googleapis.com/css?family=Roboto+Mono" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"> <script async defer src="https://buttons.github.io/buttons.js"></script>
<!-- ========= START OF TOP NAVBAR ======= -->
<div class="topNav"><a id="navbar.top">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.top" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.top.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/NCIntentSample.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage">Apache NLPCraft <span style="font-size: 80%">0.9.0</span></div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_top">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<ul class="navListSearch">
<li><label for="search">SEARCH:</label>
<input type="text" id="search" value="search" disabled="disabled">
<input type="reset" id="reset" value="reset" disabled="disabled">
</li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_top");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a id="skip.navbar.top">
<!-- -->
</a></div>
<!-- ========= END OF TOP NAVBAR ========= -->
</div>
<div class="navPadding">&nbsp;</div>
<script type="text/javascript"><!--
$('.navPadding').css('padding-top', $('.fixedNav').css("height"));
//-->
</script>
</nav>
</header>
<!-- ======== START OF CLASS DATA ======== -->
<main role="main">
<div class="header">
<div class="subTitle"><span class="packageLabelInType">Package</span>&nbsp;<a href="package-summary.html">org.apache.nlpcraft.model</a></div>
<h2 title="Annotation Type NCIntentSample" class="title">Annotation Type NCIntentSample</h2>
</div>
<div class="contentContainer">
<div class="description">
<ul class="blockList">
<li class="blockList">
<hr>
<pre><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/Retention.html?is-external=true" title="class or interface in java.lang.annotation" class="externalLink">@Retention</a>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/RetentionPolicy.html?is-external=true#RUNTIME" title="class or interface in java.lang.annotation" class="externalLink">RUNTIME</a>)
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/Target.html?is-external=true" title="class or interface in java.lang.annotation" class="externalLink">@Target</a>(<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/ElementType.html?is-external=true#METHOD" title="class or interface in java.lang.annotation" class="externalLink">METHOD</a>)
<a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/annotation/Repeatable.html?is-external=true" title="class or interface in java.lang.annotation" class="externalLink">@Repeatable</a>(<a href="NCIntentSample.NCIntentSampleList.html" title="annotation in org.apache.nlpcraft.model">NCIntentSampleList.class</a>)
public @interface <span class="memberNameLabel">NCIntentSample</span></pre>
<div class="block">Annotation to define samples of the user input that should match an intent. This
annotation should be used together with <a href="NCIntent.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntent</code></a> or <a href="NCIntentRef.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentRef</code></a> annotations on the callback
methods. Method can have multiple annotations of this type and each annotation can define multiple input
examples. See similar <a href="NCIntentSampleRef.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSampleRef</code></a> annotation that allows to load samples from external resources like
file or URL.
<p>
The corpus of intent samples serve several important roles in NLPCraft:
<ul>
<li>
It provide code level documentation on what type of user input given intent is supposed to match on.
In many cases having <a href="NCIntent.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntent</code></a> and <a href="NCIntentSample.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSample</code></a> annotations on the intent callback
method allows to see all the main ingredients of the language comprehension in one place.
</li>
<li>
It provides a necessary corpus for automated unit and regression testing used by
<a href="tools/test/NCTestAutoModelValidator.html" title="class in org.apache.nlpcraft.model.tools.test"><code>NCTestAutoModelValidator</code></a> class from
<a href="https://nlpcraft.apache.org/tools/test_framework.html">built-in test framework</a>.
This class auto-validates that provided samples are matched on by their corresponding intents.
</li>
<li>
This corpus is used by various statistical tools like
<a href="https://nlpcraft.apache.org/tools/syn_tool.html">synonyms tool</a> 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.
</li>
</ul>
<p>
Here's an example of using this annotation (from <a target=_new href="https://nlpcraft.apache.org/examples/light_switch.html">LightSwitch</a> example):
<pre class="brush: java, highlight: [2]">
@NCIntent("intent=act term(act)={has(tok_groups(), 'act')} term(loc)={trim(tok_id()) == 'ls:loc'}*")
@NCIntentSample(Array(
"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 = {
...
}
</pre>
<p>
Read full documentation in <a target=_ href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent Matching</a> section and review
<a target=_ href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.</div>
<dl>
<dt><span class="seeLabel">See Also:</span></dt>
<dd><a href="NCIntentSampleRef.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSampleRef</code></a>,
<a href="NCIntent.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntent</code></a>,
<a href="NCIntentRef.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentRef</code></a>,
<a href="NCIntentTerm.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentTerm</code></a>,
<a href="NCIntentSkip.html" title="class in org.apache.nlpcraft.model"><code>NCIntentSkip</code></a>,
<a href="NCIntentMatch.html" title="interface in org.apache.nlpcraft.model"><code>NCIntentMatch</code></a>,
<a href="NCModel.html#onMatchedIntent(org.apache.nlpcraft.model.NCIntentMatch)"><code>NCModel.onMatchedIntent(NCIntentMatch)</code></a>,
<a href="tools/test/NCTestAutoModelValidator.html" title="class in org.apache.nlpcraft.model.tools.test"><code>NCTestAutoModelValidator</code></a></dd>
</dl>
</li>
</ul>
</div>
<div class="summary">
<ul class="blockList">
<li class="blockList">
<!-- =========== ANNOTATION TYPE REQUIRED MEMBER SUMMARY =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="annotation.type.required.element.summary">
<!-- -->
</a>
<h3>Required Element Summary</h3>
<table class="memberSummary">
<caption><span>Required Elements</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Modifier and Type</th>
<th class="colSecond" scope="col">Required Element</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tr class="altColor">
<td class="colFirst"><code><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>[]</code></td>
<th class="colSecond" scope="row"><code><span class="memberNameLink"><a href="#value()">value</a></span></code></th>
<td class="colLast">
<div class="block">Gets a list of user input samples that should match corresponding intent.</div>
</td>
</tr>
</table>
</li>
</ul>
</section>
</li>
</ul>
</div>
<div class="details">
<ul class="blockList">
<li class="blockList">
<!-- ============ ANNOTATION TYPE MEMBER DETAIL =========== -->
<section role="region">
<ul class="blockList">
<li class="blockList"><a id="annotation.type.element.detail">
<!-- -->
</a>
<h3>Element Detail</h3>
<a id="value()">
<!-- -->
</a>
<ul class="blockListLast">
<li class="blockList">
<h4>value</h4>
<pre><a href="https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/String.html?is-external=true" title="class or interface in java.lang" class="externalLink">String</a>[]&nbsp;value</pre>
<div class="block">Gets a list of user input samples that should match corresponding intent. This annotation should be
attached the intent callback method.</div>
<dl>
<dt><span class="returnLabel">Returns:</span></dt>
<dd>Set of user input examples that should match corresponding intent.</dd>
</dl>
</li>
</ul>
</li>
</ul>
</section>
</li>
</ul>
</div>
</div>
</main>
<!-- ========= END OF CLASS DATA ========= -->
<footer role="contentinfo">
<nav role="navigation">
<!-- ======= START OF BOTTOM NAVBAR ====== -->
<div class="bottomNav"><a id="navbar.bottom">
<!-- -->
</a>
<div class="skipNav"><a href="#skip.navbar.bottom" title="Skip navigation links">Skip navigation links</a></div>
<a id="navbar.bottom.firstrow">
<!-- -->
</a>
<ul class="navList" title="Navigation">
<li><a href="../../../../index.html">Overview</a></li>
<li><a href="package-summary.html">Package</a></li>
<li class="navBarCell1Rev">Class</li>
<li><a href="class-use/NCIntentSample.html">Use</a></li>
<li><a href="package-tree.html">Tree</a></li>
<li><a href="../../../../deprecated-list.html">Deprecated</a></li>
<li><a href="../../../../index-all.html">Index</a></li>
<li><a href="../../../../help-doc.html">Help</a></li>
</ul>
<div class="aboutLanguage"><span style="vertical-align: super">Apache NLPCraft <span style="font-size: 80%">0.9.0</span></span> <a style="vertical-align: super; margin-right: 10px" href="https://github.com/apache/incubator-nlpcraft" target="github"><i class="fa fa-github github-logo"></i></a> <a class="github-button" href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples" data-icon="octicon-eye" aria-label="NLPCraft Examples">Examples</a> <a class="github-button" href="https://github.com/apache/incubator-nlpcraft" data-icon="octicon-star" aria-label="Star on GitHub">Star</a> <a class="github-button" href="https://github.com/apache/incubator-nlpcraft/fork" data-icon="octicon-repo-forked" aria-label="Fork on GitHub">Fork</a> <script type="text/javascript"> SyntaxHighlighter.defaults["auto-links"] = false; SyntaxHighlighter.defaults["tab-size"] = 2; SyntaxHighlighter.autoloader( 'java https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushJava.js', 'js jscript javascript https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushJScript.js', 'text plain https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushPlain.js', 'py python https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushPython.js', 'ruby rails ror rb https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushRuby.js', 'scala https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushScala.js', 'sql https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushSql.js', 'xml xhtml xslt html https://nlpcraft.apache.org/javadoc/resources/sh/scripts/shBrushXml.js' ); SyntaxHighlighter.all(); </script></div>
</div>
<div class="subNav">
<ul class="navList" id="allclasses_navbar_bottom">
<li><a href="../../../../allclasses.html">All&nbsp;Classes</a></li>
</ul>
<div>
<script type="text/javascript"><!--
allClassesLink = document.getElementById("allclasses_navbar_bottom");
if(window==top) {
allClassesLink.style.display = "block";
}
else {
allClassesLink.style.display = "none";
}
//-->
</script>
<noscript>
<div>JavaScript is disabled on your browser.</div>
</noscript>
</div>
<div>
<ul class="subNavList">
<li>Summary:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.required.element.summary">Required</a>&nbsp;|&nbsp;</li>
<li>Optional</li>
</ul>
<ul class="subNavList">
<li>Detail:&nbsp;</li>
<li>Field&nbsp;|&nbsp;</li>
<li><a href="#annotation.type.element.detail">Element</a></li>
</ul>
</div>
<a id="skip.navbar.bottom">
<!-- -->
</a></div>
<!-- ======== END OF BOTTOM NAVBAR ======= -->
</nav>
<p class="legalCopy"><small><center> <br/> <span style="font-size: larger">Copyright &#169; 2021 Apache Software Foundation</span> <br/> <br/> <img src="https://www.apache.org/img/ASF20thAnniversary.jpg" height="64px" alt="ASF Logo"> </center></small></p>
</footer>
</body>
</html>