blob: ebd714f62e9828a748d9cf33a953c66b1e14511d [file] [log] [blame]
---
active_crumb: Cheat Sheet <i class="fa fa-fw fa-magic"></i>
layout: documentation
id: cheat_sheet
---
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<div id="cheat-sheet" class="col-md-8 second-column">
<section>
<h2 class="section-title">Frequent Operations</h2>
<div style="display: flex">
<div>
<a href="#cs1">Quick Install</a><br/>
<a href="#cs2">Start <span class="amp">&amp;</span> Stop REST Server</a><br/>
<a href="#cs3">Start <span class="amp">&amp;</span> Stop Probe</a><br/>
<a href="#cs4">Model Auto-Test</a>
</div>
<div style="margin-left: 30px">
<a href="#cs5">New Project Stub</a><br/>
<a href="#cs6">New Model Stub</a><br/>
<a href="#cs7">Testing with REST</a><br/>
</div>
</div>
</section>
<section id="cs1">
<h2 class="section-title">Quick Install</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-install-src" role="tab" aria-controls="nav-home" aria-selected="true">Source</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-bin" role="tab" aria-controls="nav-home" aria-selected="true">Binary</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-github" role="tab" aria-controls="nav-home" aria-selected="true">GitHub <i class="fab fa-fw fa-github"></i></a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-maven" role="tab" aria-controls="nav-home" aria-selected="true">Maven <img src="/images/java2.png" height="20px" alt=""></a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-grape" role="tab" aria-controls="nav-profile" aria-selected="false">Grape <img src="/images/groovy.png" height="18px" alt=""></a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-gradle" role="tab" aria-controls="nav-profile" aria-selected="false">Gradle <img src="/images/kotlin.png" height="18px" alt=""></a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-install-sbt" role="tab" aria-controls="nav-contact" aria-selected="false">SBT <img src="/images/scala-logo.png" height="16px" alt=""></a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-install-src" role="tabpanel">
<p></p>
<p>
<a href="/download.html#src">Download</a> latest (<code><b>{{site.latest_version}}</b></code>) source release.
</p>
<pre class="brush: bash">
$ unzip -q apache-nlpcraft-incubating-{{site.latest_version}}.zip
$ cd apache-nlpcraft-incubating-{{site.latest_version}}
$ mvn clean package -DskipTests
</pre>
<p>
Built JARs and Javadoc will be located in <code>target</code> sub-folder.
</p>
</div>
<div class="tab-pane fade show" id="nav-install-bin" role="tabpanel">
<p></p>
<p>
<a href="/download.html#zip">Download</a> latest (<code><b>{{site.latest_version}}</b></code>) binary release.
</p>
<pre class="brush: bash">
$ unzip -q apache-nlpcraft-incubating-bin-{{site.latest_version}}.zip
</pre>
</div>
<div class="tab-pane fade show" id="nav-install-github" role="tabpanel">
<pre class="brush: bash">
$ git clone https://github.com/apache/incubator-nlpcraft.git
$ mvn clean package
</pre>
</div>
<div class="tab-pane fade show" id="nav-install-maven" role="tabpanel">
<pre class="brush: xml">
&lt;dependency&gt;
&lt;groupId&gt;org.apache.nlpcraft&lt;/groupId&gt;
&lt;artifactId&gt;nlpcraft&lt;/artifactId&gt;
&lt;version&gt;{{site.latest_version}}&lt;/version&gt;
&lt;/dependency&gt;
</pre>
<p>
<b>NOTE:</b> to get <a href="/tools/script.html">NLPCraft CLI script</a> you still need to
download <a href="/download.html#zip">binary</a> ZIP or <a href="/download.html#build">build</a> from <a href="/download.html#src">source</a>.
</p>
</div>
<div class="tab-pane fade" id="nav-install-grape" role="tabpanel">
<pre class="brush: java">
@Grab ('org.apache.nlpcraft:nlpcraft:{{site.latest_version}}')
</pre>
<p>
<b>NOTE:</b> to get <a href="/tools/script.html">NLPCraft CLI script</a> you still need to
download <a href="/download.html#zip">binary</a> ZIP or <a href="/download.html#build">build</a> from <a href="/download.html#src">source</a>.
</p>
</div>
<div class="tab-pane fade" id="nav-install-gradle" role="tabpanel">
<pre class="brush: java">
dependencies {
runtime group: 'org.apache.nlpcraft', name: 'nlpcraft', version: '{{site.latest_version}}'
}
</pre>
<p>
<b>NOTE:</b> to get <a href="/tools/script.html">NLPCraft CLI script</a> you still need to
download <a href="/download.html#zip">binary</a> ZIP or <a href="/download.html#build">build</a> from <a href="/download.html#src">source</a>.
</p>
</div>
<div class="tab-pane fade" id="nav-install-sbt" role="tabpanel">
<pre class="brush: scala">
libraryDependencies += "org.apache.nlpcraft" % "nlpcraft" % "{{site.latest_version}}"
</pre>
<p>
<b>NOTE:</b> to get <a href="/tools/script.html">NLPCraft CLI script</a> you still need to
download <a href="/download.html#zip">binary</a> ZIP or <a href="/download.html#build">build</a> from <a href="/download.html#src">source</a>.
</p>
</div>
</div>
</section>
<section id="cs2">
<h2 class="section-title">Start <span class="amp">&amp;</span> Stop REST Server</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-srv-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-class" role="tab" aria-controls="nav-home" aria-selected="true">Java Class</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-docker" role="tab" aria-controls="nav-home" aria-selected="true"><i class="fab fa-docker"></i> Docker</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-srv-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh start-server # Start server.
</pre>
<pre class="brush: bash">
$ bin/nlpcraft.sh stop-server # Stop server.
$ bin/nlpcraft.sh stop # Stop both server and probe.
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=xxx</code> to get a full help on <code>xxx</code> command.
</li>
</ul>
</div>
<div class="tab-pane fade show" id="nav-srv-class" role="tabpanel">
<p></p>
<p>
If using just executable JAR:
</p>
<pre class="brush: bash">
$ java -Xms1024m -jar apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar -server
</pre>
<p>
If specifying additional classpath components and need <code>-cp</code> parameter:
</p>
<pre class="brush: bash">
$ java -Xms1024m -cp apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar org.apache.nlpcraft.NCStart -server
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
Make sure to provide correct path to <code>apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar</code> file.
</li>
<li>
Class <code>org.apache.nlpcraft.NCStart</code> is a common entry point for all NLPCraft runtime components.
</li>
<li>
Class <code>org.apache.nlpcraft.NCStart</code> should be used to star REST server from IDE.
</li>
</ul>
<p>
Parameters:
</p>
<dl>
<dt>
<code>-server</code>
</dt>
<dd>
<em>Mandatory</em> parameter to indicate that you are starting the REST server.
</dd>
<dt><code>-config=path</code></dt>
<dd>
<em>Optional</em> parameter to provide configuration file path.
Server will automatically look for <code>nlpcraft.conf</code> configuration file in the same directory
as <code>apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar</code> file. If the configuration
file has different name or in different location use <code>-config=path</code> parameter
where <code>path</code> is an absolute path to the configuration file. Note that the server and the data
probe can use the same file for their configuration (just like the
default <code>nlpcraft.conf</code> contains configuration for both the server and the data probe).
</dd>
<dt><code>-igniteConfig=path</code></dt>
<dd>
<em>Optional</em> parameter to provide <a target=_ href="https://ignite.apache.org/">Apache Ignite</a> configuration file path.
Note that Apache Ignite is used as a cluster computing plane and a default distributed storage.
Server will automatically look for <code>ignite.xml</code>
configuration file in the same directory as <code>apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar</code> file.
If the configuration file has different name or in different location use <code>-igniteConfig=path</code> parameter
where <code>path</code> is an absolute path to the Ignite configuration file.
</dd>
</dl>
</div>
<div class="tab-pane fade show" id="nav-srv-docker" role="tabpanel">
<p></p>
<p>
If Docker image is available for given version you can start REST server as follows:
</p>
<pre class="brush: bash">
$ docker run -m 8G -p 8081:8081 -p 8201:8201 -p 8202:8202 nlpcraftserver/server:{{site.latest_version}}
</pre>
</div>
</div>
</section>
<section id="cs3">
<h2 class="section-title">Start <span class="amp">&amp;</span> Stop Probe</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-probe-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-probe-class" role="tab" aria-controls="nav-home" aria-selected="true">Java Class</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-probe-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh start-probe # Start probe with default config.
$ bin/nlpcraft.sh start-probe --cfg=~/myapp/nlpcraft.conf --mdls=my.package.Model --cp=~/myapp/target/classes --jmvOpts="-ea -Xms2048m" --timeoutMins=5
</pre>
<pre class="brush: bash">
$ bin/nlpcraft.sh stop-probe # Stop probe.
$ bin/nlpcraft.sh stop # Stop server and probe.
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=xxx</code> to get a full help on <code>xxx</code> command.
</li>
</ul>
</div>
<div class="tab-pane fade show" id="nav-probe-class" role="tabpanel">
<p></p>
<p>
If using just executable JAR:
</p>
<pre class="brush: bash">
$ java -jar apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar -probe
</pre>
<p>
If specifying additional classpath components and need <code>-cp</code> parameter:
</p>
<pre class="brush: bash">
java -cp apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar:/my/project/classes org.apache.nlpcraft.NCStart -probe -config=/my/project/probe.conf
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<code>/my/project</code> directory contains user-defined model implementation
</li>
<li>
Make sure to provide correct path to <code>apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar</code> file.
</li>
<li>
Class <code>org.apache.nlpcraft.NCStart</code> is a common entry point for all NLPCraft runtime components.
</li>
<li>
Class <code>org.apache.nlpcraft.NCStart</code> should be used to star data probe from IDE.
</li>
</ul>
<p>
Parameters:
</p>
<dl>
<dt>
<code>-probe</code>
</dt>
<dd>
<em>Mandatory</em> parameter to indicate that you are starting a data probe.
</dd>
<dt><code>-config=path</code></dt>
<dd>
<p>
<em>Optional</em> parameter to provide probe configuration file path.
Data probe will automatically look for <code>nlpcraft.conf</code> configuration file in the same directory
as <code>apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar</code> file. If the configuration
file has different name or in different location use <code>-config=path</code> parameter
where <code>path</code> is an absolute path to the data probe configuration file. Note that the server and the data
probe can use the same file for their configuration (just like the
default <code>nlpcraft.conf</code> contains configuration for both the server and the data probe).
</p>
</dd>
</dl>
</div>
</div>
</section>
<section id="cs4">
<h2 class="section-title">Model Auto-Test</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
<a class="nav-item nav-link" data-toggle="tab" href="#nav-class" role="tab" aria-controls="nav-home" aria-selected="true">Java Class</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh test-model # All default parameters.
$ bin/nlpcraft.sh test-model --mdls=my.package.Model --cp=~/myapp/target/classes --jmvOpts="-ea -Xms2048m"
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=test-model</code> to get a full help on this command.
</li>
</ul>
</div>
<div class="tab-pane fade show" id="nav-class" role="tabpanel">
<pre class="brush: bash">
java -cp apache-nlpcraft-incubating-{{site.latest_version}}-all-deps.jar -DNLPCRAFT_TEST_MODELS=my.package.Model org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
Make sure to add necessary classpath components.
</li>
<li>
<code>NLPCRAFT_TEST_MODELS</code> system property that should contain comma separate list of the data model classes to test.
</li>
<li>
You can also use <code>org.apache.nlpcraft.model.tools.test.NCTestAutoModelValidator</code> class
directly to call it programmatically from the code or from IDE.
</li>
</ul>
</div>
</div>
</section>
<section id="cs5">
<h2 class="section-title">New Project Stub</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-prj-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-prj-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh gen-project -n=MyProject -l=scala -b=sbt # Scala/SBT project stub.
$ bin/nlpcraft.sh gen-project -n=MyProject -l=kotlin -p=com.mycompany.nlp -o # Kotlin/Maven project stub.
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=gen-project</code> to get a full help on this command.
</li>
</ul>
</div>
</div>
</section>
<section id="cs6">
<h2 class="section-title">New Model Stub</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-mdl-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-mdl-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh gen-model --filePath=~/myapp/myModel.json --mdlId=my.model.id # JSON model stub.
$ bin/nlpcraft.sh gen-model -f=c:/tmp/myModel.yaml -m=my.model.id -o # YAML model stub.
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=gen-model</code> to get a full help on this command.
</li>
</ul>
</div>
</div>
</section>
<section id="cs7">
<h2 class="section-title">Testing with REST</h2>
<nav>
<div class="nav nav-tabs" role="tablist">
<a class="nav-item nav-link active" data-toggle="tab" href="#nav-rest-script" role="tab" aria-controls="nav-home" aria-selected="true">NLPCraft CLI</a>
</div>
</nav>
<div class="tab-content">
<div class="tab-pane fade show active" id="nav-rest-script" role="tabpanel">
<pre class="brush: bash">
$ bin/nlpcraft.sh ask --txt="User request" --mdlId=my.model.id # REST 'ask/sync' call.
$ bin/nlpcraft.sh call -p=signin --email=admin@admin.com --passwd=admin
$ bin/nlpcraft.sh call --path=ask/sync --acsTok=qwerty123456 --txt="User request" --mdlId=my.model.id --data='{"data1": true, "data2": 123, "data3": "some text"}' --enableLog=false
$ bin/nlpcraft.sh rest -p=signin -j='{"email": "admin@admin.com", "passwd": "admin"}' # Linux/Unix/MacOS REST call.
$ bin/nlpcraft.cmd rest --path=signin --json='{\"email\": \"admin@admin.com\", \"passwd\": \"admin\"}' # Window REST call.
</pre>
<p>
<b>NOTES:</b>
</p>
<ul>
<li>
<a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for Unix/Linux/MacOS and <code>nlpcraft.cmd</code> for Windows.
</li>
<li>
Run <code>bin/nlpcraft.sh help --cmd=xxx</code> to get a full help on <code>xxx</code> command.
</li>
</ul>
</div>
</div>
</section>
</div>
<div class="col-md-2 third-column">
<ul class="side-nav">
{% include quick-links.html %}
</ul>
</div>