| --- |
| 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> |
| <div class="accordion" id="cheats"> |
| <div class="card"> |
| <div class="card-header" id="q1"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat1"> |
| Quick Install |
| </button> |
| </h2> |
| </div> |
| <div id="cheat1" class="show" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-install-src" role="tab">Source</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-install-bin" role="tab">Binary</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-install-github" role="tab">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">Maven <img src="/images/java2-h20.png" 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-h18.png" 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-h18.png" 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-h16.png" 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 source |
| release (<code>apache-nlpcraft-incubating-<b>{{site.latest_version}}</b>.zip</code>). Once downloaded: |
| </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#src">Download</a> latest binary |
| release (<code>apache-nlpcraft-incubating-bin-<b>{{site.latest_version}}</b>.zip</code>). Once downloaded: |
| </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"> |
| <dependency> |
| <groupId>org.apache.nlpcraft</groupId> |
| <artifactId>nlpcraft</artifactId> |
| <version>{{site.latest_version}}</version> |
| </dependency> |
| </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> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q2"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat2"> |
| Start <span class="amp">&</span> Stop REST Server |
| </button> |
| </h2> |
| </div> |
| <div id="cheat2" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-srv-script" role="tab">NLPCraft CLI</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-class" role="tab">Java Class <img src="/images/java2-h20.png" alt=""></a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-srv-docker" role="tab"><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"> |
| <p></p> |
| <p> |
| Start the server: |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=start-server # Get help. |
| $ bin/nlpcraft.sh start-server # Start server. |
| </pre> |
| <p> |
| Stop the server: |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=stop-server # Get help. |
| $ bin/nlpcraft.sh stop-server # Stop server. |
| $ bin/nlpcraft.sh stop # Stop both server and probe. |
| </pre> |
| </div> |
| <div class="tab-pane fade show" id="nav-srv-class" role="tabpanel"> |
| <p></p> |
| <p> |
| If using 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-<b>{{site.latest_version}}</b>-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-<b>{{site.latest_version}}</b>-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 (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-<b>{{site.latest_version}}</b>-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> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q3"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat3"> |
| Start <span class="amp">&</span> Stop REST Probe |
| </button> |
| </h2> |
| </div> |
| <div id="cheat3" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-probe-script" role="tab">NLPCraft CLI</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-probe-class" role="tab">Java Class <img src="/images/java2-h20.png" alt=""></a> |
| </div> |
| </nav> |
| <div class="tab-content"> |
| <div class="tab-pane fade show active" id="nav-probe-script" role="tabpanel"> |
| <p></p> |
| <p> |
| Start the probe: |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=start-probe # Get help. |
| $ 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> |
| <p> |
| Stop the probe: |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=stop-probe # Get help. |
| $ bin/nlpcraft.sh stop-probe # Stop probe. |
| $ bin/nlpcraft.sh stop # Stop server and probe. |
| </pre> |
| </div> |
| <div class="tab-pane fade show" id="nav-probe-class" role="tabpanel"> |
| <p></p> |
| <p> |
| If using 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-<b>{{site.latest_version}}</b>-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-<b>{{site.latest_version}}</b>-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 (like the |
| default <code>nlpcraft.conf</code> contains configuration for both the server and the data probe). |
| </p> |
| </dd> |
| </dl> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q4"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat4"> |
| Model Auto-Test |
| </button> |
| </h2> |
| </div> |
| <div id="cheat4" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <p></p> |
| <p> |
| Auto model validation consists |
| of starting an <a href="/tools/embedded_probe.html">embedded probe</a>, scanning for |
| <a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a> annotations and their corresponding callback methods, submitting each |
| sample input sentences from <a target="javadoc" href="/apis/latest/org/apache/nlpcraft/model/NCIntentSample.html">@NCIntentSample</a> annotation and checking that resulting |
| intent matches the intent the sample was attached to. |
| </p> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-script" role="tab">NLPCraft CLI</a> |
| <a class="nav-item nav-link" data-toggle="tab" href="#nav-class" role="tab">Java Class <img src="/images/java2-h20.png" alt=""></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 help -c=test-model # Get help. |
| $ 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> |
| </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> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q5"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat5"> |
| New Project Stub |
| </button> |
| </h2> |
| </div> |
| <div id="cheat5" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-prj-script" role="tab">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 help -c=gen-project # Get help. |
| $ 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> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q6"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat6"> |
| New Model Stub |
| </button> |
| </h2> |
| </div> |
| <div id="cheat6" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-mdl-script" role="tab">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 help -c=gen-model # Get help. |
| $ 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> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="card"> |
| <div class="card-header" id="q7"> |
| <h2 class="mb-0"> |
| <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#cheat7"> |
| Testing With REST |
| </button> |
| </h2> |
| </div> |
| <div id="cheat7" class="collapse" data-parent="#cheats"> |
| <div class="card-body"> |
| <nav> |
| <div class="nav nav-tabs" role="tablist"> |
| <a class="nav-item nav-link active" data-toggle="tab" href="#nav-rest-script" role="tab">NLPCraft CLI</a> |
| </div> |
| </nav> |
| <div class="tab-content"> |
| <div class="tab-pane fade show active" id="nav-rest-script" role="tabpanel"> |
| <p></p> |
| <p> |
| Using <code>ask</code> command: |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=ask # Get help. |
| $ bin/nlpcraft.sh ask --txt="User request" --mdlId=my.model.id # REST 'ask/sync' call. |
| </pre> |
| <p> |
| Using <code>call</code> command (for REPL mode): |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=call # Get help. |
| $ 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 |
| </pre> |
| <p> |
| Using <code>rest</code> command (for command line mode): |
| </p> |
| <pre class="brush: bash"> |
| $ bin/nlpcraft.sh help -c=rest # Get help. |
| $ 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> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="bq success"> |
| <p> |
| <b>NOTES:</b> |
| </p> |
| <ul> |
| <li> |
| <a href="/tools/script.html">NLPCraft CLI</a> is available as <code>nlpcraft.sh</code> for |
| <i class="fab fa-fw fa-linux"></i> and <code>nlpcraft.cmd</code> |
| for <i class="fab fa-fw fa-windows"></i>. |
| </li> |
| <li> |
| Run <code class="script">bin/nlpcraft.sh help --cmd=xxx</code> to get a full help on <code>xxx</code> command. |
| </li> |
| </ul> |
| </div> |
| </section> |
| </div> |
| <div class="col-md-2 third-column"> |
| <ul class="side-nav"> |
| {% include quick-links.html %} |
| </ul> |
| </div> |
| |
| |
| |
| |