blob: 41cec358e71e4d6e660dead12d141bbc73d9d0ec [file] [log] [blame]
<!DOCTYPE HTML>
<!-- NewPage -->
<html lang="en">
<head>
<!-- Generated by javadoc (11.0.8) on Fri Nov 20 12:32:33 PST 2020 -->
<title>org.apache.nlpcraft.model.tools.test (Apache NLPCraft 0.7.2)</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="dc.created" content="2020-11-20">
<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.4.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="org.apache.nlpcraft.model.tools.test (Apache NLPCraft 0.7.2)";
}
}
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 class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.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.7.2</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>
<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>
<main role="main">
<div class="header">
<h1 title="Package" class="title">Package&nbsp;org.apache.nlpcraft.model.tools.test</h1>
</div>
<div class="contentContainer">
<section role="region"><a id="package.description">
<!-- -->
</a>
<div class="block">Contains model testing framework.
<p>
Here's an code snippet of using direct <b>test client</b> for <code>Alarm Clock</code> example illustrating
the usage of test framework together with JUnit 5:
<pre class="brush: java">
public class AlarmTest {
private NCTestClient cli;
&#64;BeforeEach
void setUp() throws NCException, IOException {
NCEmbeddedProbe.start(AlarmModel.class);
cli = new NCTestClientBuilder().newBuilder().build();
cli.open("nlpcraft.alarm.ex");
}
&#64;AfterEach
void tearDown() throws NCException, IOException {
if (cli != null)
cli.close();
NCEmbeddedProbe.stop();
}
&#64;Test
public void test() throws NCException, IOException {
// Empty parameter.
assertTrue(cli.ask("").isFailed());
// Only latin charset is supported.
assertTrue(cli.ask("El tiempo en EspaƱa").isFailed());
// Should be passed.
assertTrue(cli.ask("Ping me in 3 minutes").isOk());
assertTrue(cli.ask("Buzz me in an hour and 15mins").isOk());
assertTrue(cli.ask("Set my alarm for 30s").isOk());
}
}
</pre>
<p>
You can also automatically <b>verify</b> the same model by using <a href="NCTestAutoModelValidator.html" title="class in org.apache.nlpcraft.model.tools.test"><code>NCTestAutoModelValidator</code></a> class without any
additional coding utilizing <a href="../../NCIntentSample.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSample</code></a> annotation on the models' callback method.
This automatic model validation consists of starting an embedded probe with a given model, scanning
for <a href="../../NCIntentSample.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSample</code></a> annotations and their corresponding callback methods,
submitting each sample input sentences from <a href="../../NCIntentSample.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSample</code></a> annotation and checking
that resulting intent matches the intent the sample was attached to.
<p>
Add necessary classpath and run the following command:
<pre class="brush: plain">
java -ea -DNLPCRAFT_TEST_MODELS=org.apache.nlpcraft.examples.alarm.AlarmModel org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
</pre></div>
</section>
<ul class="blockList">
<li class="blockList">
<table class="typeSummary">
<caption><span>Interface Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Interface</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="NCTestClient.html" title="interface in org.apache.nlpcraft.model.tools.test">NCTestClient</a></th>
<td class="colLast">
<div class="block">Model testing client.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colFirst" scope="row"><a href="NCTestResult.html" title="interface in org.apache.nlpcraft.model.tools.test">NCTestResult</a></th>
<td class="colLast">
<div class="block">Result of the test sentence processing.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary">
<caption><span>Class Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Class</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="NCTestAutoModelValidator.html" title="class in org.apache.nlpcraft.model.tools.test">NCTestAutoModelValidator</a></th>
<td class="colLast">
<div class="block">Auto-validator for models based on <a href="../../NCIntentSample.html" title="annotation in org.apache.nlpcraft.model"><code>NCIntentSample</code></a> annotations.</div>
</td>
</tr>
<tr class="rowColor">
<th class="colFirst" scope="row"><a href="NCTestClientBuilder.html" title="class in org.apache.nlpcraft.model.tools.test">NCTestClientBuilder</a></th>
<td class="colLast">
<div class="block">Test client builder for <a href="NCTestClient.html" title="interface in org.apache.nlpcraft.model.tools.test"><code>NCTestClient</code></a> instances.</div>
</td>
</tr>
</tbody>
</table>
</li>
<li class="blockList">
<table class="typeSummary">
<caption><span>Exception Summary</span><span class="tabEnd">&nbsp;</span></caption>
<tr>
<th class="colFirst" scope="col">Exception</th>
<th class="colLast" scope="col">Description</th>
</tr>
<tbody>
<tr class="altColor">
<th class="colFirst" scope="row"><a href="NCTestClientException.html" title="class in org.apache.nlpcraft.model.tools.test">NCTestClientException</a></th>
<td class="colLast">
<div class="block">Test client exception.</div>
</td>
</tr>
</tbody>
</table>
</li>
</ul>
</div>
</main>
<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 class="navBarCell1Rev">Package</li>
<li>Class</li>
<li><a href="package-use.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.7.2</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/src/main/scala/org/apache/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>
<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; 2020 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>