This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch NLPCRAFT-513
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft-website.git
The following commit(s) were added to refs/heads/NLPCRAFT-513 by this push:
new 5ff871e Review.
5ff871e is described below
commit 5ff871e7f3365fb2221277a90c0aec1e1c757c73
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Oct 19 11:36:17 2022 -0700
Review.
---
examples/calculator.html | 63 +++++++++++++---------------
examples/light_switch.html | 6 +--
examples/light_switch_fr.html | 98 ++++++++++++++++++++++++-------------------
3 files changed, 87 insertions(+), 80 deletions(-)
diff --git a/examples/calculator.html b/examples/calculator.html
index 2e25b30..2d95088 100644
--- a/examples/calculator.html
+++ b/examples/calculator.html
@@ -27,7 +27,7 @@ fa_icon: fa-cube
<h2 class="section-title">Overview <a href="#"><i class="top-link fas
fa-fw fa-angle-double-up"></i></a></h2>
<p>
This example provides a very simple calculator implementation.
- It supports restricted set of arithmetic operations under integer
numeric values.
+ It supports restricted set of arithmetic operations for numeric
values.
</p>
<p>
<b>Complexity:</b> <span class="complexity-one-star"><i class="fas
fa-star"></i> <i class="far fa-star"></i> <i class="far
fa-star"></i></span><br/>
@@ -76,12 +76,7 @@ fa_icon: fa-cube
<section id="model">
<h2 class="section-title">Data Model<a href="#"><i class="top-link fas
fa-fw fa-angle-double-up"></i></a></h2>
<p>
- All elements definitions can be provided programmatically inside
Scala model <code>CalculatorModel</code> class as well.
- </p>
- </section>
- <section id="code">
- <h2 class="section-title">Model Class <a href="#"><i class="top-link
fas fa-fw fa-angle-double-up"></i></a></h2>
- <p>
+ All element definitions are provided programmatically inside Scala
model <code>CalculatorModel</code> class.
Open <code>src/main/scala/demo/<b>CalculatorModel.scala</b></code>
file and replace its content with the following code:
</p>
<pre class="brush: scala, highlight: [11, 12, 14, 21, 22, 23, 31, 35,
41, 47, 56, 61]">
@@ -154,44 +149,46 @@ fa_icon: fa-cube
calc(mem.getOrElse(throw new NCRejection("Memory is
empty.")), op.mkText, nne(y))
</pre>
<p>
- There are two intents with simple logic. First returns arithmetic
operation result under two input parameters,
- second uses last operation result instead of first input value.
- Also, the implication here is that arithmetic operations notations
- (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>)
are used as is for simplifying the given example,
- without any synonyms for them.
+ There are two intents with simple logic. First returns arithmetic
operation result with two input parameters,
+ second uses last operation result instead of the first argument.
Note also that the arithmetic notations
+ (<code>+</code>, <code>-</code>, <code>*</code>, <code>/</code>)
are used as is for without any additional synonyms.
Let's review this implementation step by step:
</p>
<ul>
<li>
- On <code>line 11</code> declared <code>CalculatorModel</code>,
model companion object, which contains
+ <code>Line 11</code> declares <code>CalculatorModel</code>,
model companion object, which contains
static content and helper methods.
</li>
<li>
- On <code>line 12</code> defined arithmetic operations map,
with notations as keys and functions definitions as values.
+ <code>Line 12</code> defines arithmetic operations map with
notations as keys and functions definitions as values.
+ </li>
+ <li>
+ <code>Line 14</code> defines model pipeline based on three
built components.
+ <code>Line 21</code> defines Stanford token parser
<code>NCStanfordNLPTokenParser</code>
+ (we use Stanford NLP components in this example).
+ </li>
+ <li>
+ <code>Line 22</code> declares entity parser
<code>NCNLPEntityParser</code>
+ which allows to find arithmetic operations notations.
</li>
<li>
- On <code>line 14</code> defined model pipeline, based on three
built components.
- On <code>line 21</code> defined Stanford token parser
<code>NCStanfordNLPTokenParser</code>,
- we have to use it because our model uses Stanford NLP
components.
- On <code>line 22</code> entity parser
<code>NCNLPEntityParser</code>,
- which allows find arithmetic operations notations.
- On <code>line 23</code> defined entity parser
<code>NCStanfordNLPEntityParser</code>,
+ <code>Line 23</code> defines entity parser
<code>NCStanfordNLPEntityParser</code>,
which allows to find numerics in the text input.
</li>
<li>
- On <code>line 31</code> declared <code>CalculatorModel</code>
model class.
+ <code>Line 31</code> declares<code>CalculatorModel</code>
model class.
</li>
<li>
- On <code>line 35</code> declared variable named
<code>mem</code>, last operation result.
+ <code>line 35</code> declares variable named <code>mem</code>
which act as a holder for the last operation result.
</li>
<li>
- <code>Lines 41 and 47</code> annotates intents
<code>calc</code> and its callback method <code>onMatch</code>.
- Intent <code>calc</code> requires one arithmetic operation
notation and two numerics as this operation arguments.
+ <code>Lines 41 and 47</code> annotate intents
<code>calc</code> and its callback method <code>onMatch()</code>.
+ Intent <code>calc</code> requires one arithmetic operation
notation and two numerics as its arguments.
</li>
<li>
- <code>Lines 56 and 61</code> annotates intents
<code>calcMem</code> and its callback method <code>onMatchMem</code>.
- Intent <code>calcMem</code> requires one arithmetic operation
notation and one numeric as this operation second arguments.
- As first argument it uses last operation result, if there is
existed.
+ <code>Lines 56 and 61</code> annotate intents
<code>calcMem</code> and its callback method <code>onMatchMem()</code>.
+ Intent <code>calcMem</code> requires one arithmetic operation
notation and one numeric as its second arguments.
+ Note that it attempts to use last operation result as its
first argument, if one exists.
</li>
</ul>
</section>
@@ -199,8 +196,8 @@ fa_icon: fa-cube
<section id="testing">
<h2 class="section-title">Testing <a href="#"><i class="top-link fas
fa-fw fa-angle-double-up"></i></a></h2>
<p>
- The test defined in <code>CalculatorModelSpec</code> allows to
check that all input test sentences are
- processed correctly and trigger the expected intents
<code>calc</code> and <code>calcMem</code>:
+ The test provided in <code>CalculatorModelSpec</code> allows to
check that all input test sentences are
+ processed correctly and trigger the expected intents
<code>calc</code> or <code>calcMem</code>:
</p>
<pre class="brush: scala, highlight: [9, 10, 15, 16]">
package demo
@@ -228,18 +225,18 @@ fa_icon: fa-cube
On <code>line 9</code> the client for our model is created.
</li>
<li>
- On <code>line 10</code> a method <code>ask</code> is called.
Its result is checked with expected value.
+ On <code>line 10</code> the method <code>ask()</code> is
called. Its result is checked with expected value.
</li>
<li>
- Note that for inputs on <code>lines 15, 16</code> expected
<code>calcMem</code> intent triggering,
- and <code>calc</code> intent for another inputs lines.
+ Note that test sentences on <code>lines 15, 16</code> trigger
<code>calcMem</code> intent while other sentences
+ trigger <code>calc</code> intent.
</li>
</ul>
<p>
You can run this test via SBT task <code>executeTests</code> or
using IDE.
</p>
<pre class="brush: scala, highlight: []">
- PS C:\apache\incubator-nlpcraft-examples\calculator> sbt
executeTests
+ $ sbt executeTests
</pre>
</section>
<section>
diff --git a/examples/light_switch.html b/examples/light_switch.html
index 96db20d..aea3015 100644
--- a/examples/light_switch.html
+++ b/examples/light_switch.html
@@ -193,8 +193,8 @@ fa_icon: fa-cube
</li>
<li>
<code>Lines 10 and 11</code> annotates intents <code>ls</code>
and its callback method <code>onMatch</code>.
- Intent <code>ls</code> requires one action (a token belonging
to the group act) and optional list of light locations
- (zero or more tokens with ID ls:loc) - by default we assume
the entire house as a default location.
+ Intent <code>ls</code> requires one action (a token belonging
to the group <code>act</code>) and optional list of light locations
+ (zero or more tokens with ID <code>ls:loc</code>) - by default
we assume the entire house as a default location.
</li>
<li>
<code>Lines 14 and 15</code> map terms from detected intent to
the formal method parameters of the
@@ -268,7 +268,7 @@ fa_icon: fa-cube
You can run this test via SBT task <code>executeTests</code> or
using IDE.
</p>
<pre class="brush: scala, highlight: []">
- PS C:\apache\incubator-nlpcraft-examples\lightswitch> sbt
executeTests
+ $ sbt executeTests
</pre>
</section>
<section>
diff --git a/examples/light_switch_fr.html b/examples/light_switch_fr.html
index bde8512..d3d0047 100644
--- a/examples/light_switch_fr.html
+++ b/examples/light_switch_fr.html
@@ -66,12 +66,12 @@ fa_icon: fa-cube
<p>Create the following files so that resulting project structure
would look like the following:</p>
<ul>
<li><code>lightswitch_model_fr.yaml</code> - YAML configuration
file, which contains model description.</li>
- <li><code>LightSwitchFrModel.scala</code> - Scala class, model
implementation.</li>
- <li><code>NCFrSemanticEntityParser.scala</code> - Scala class,
semantic entity parser, custom implementation for French language.</li>
- <li><code>NCFrLemmaPosTokenEnricher.scala</code> - Scala class,
lemma and point of speech token enricher, custom implementation for French
language.</li>
- <li><code>NCFrStopWordsTokenEnricher.scala</code> - Scala class,
stop-words token enricher, custom implementation for French language.</li>
- <li><code>NCFrTokenParser.scala</code> - Scala class, token
parser, custom implementation for French language.</li>
- <li><code>LightSwitchFrModelSpec.scala</code> - Scala tests class,
which allows to test your model.</li>
+ <li><code>LightSwitchFrModel.scala</code> - Model
implementation.</li>
+ <li><code>NCFrSemanticEntityParser.scala</code> - Semantic entity
parser, custom implementation for French language.</li>
+ <li><code>NCFrLemmaPosTokenEnricher.scala</code> - Lemma and point
of speech token enricher, custom implementation for French language.</li>
+ <li><code>NCFrStopWordsTokenEnricher.scala</code> - Stop-words
token enricher, custom implementation for French language.</li>
+ <li><code>NCFrTokenParser.scala</code> - Token parser, custom
implementation for French language.</li>
+ <li><code>LightSwitchFrModelSpec.scala</code> - Test that allows
to test your model.</li>
</ul>
<pre class="brush: plain, highlight: [7, 10, 14, 17, 18, 20, 24]">
| build.sbt
@@ -214,41 +214,38 @@ fa_icon: fa-cube
prepared configuration and pipeline into model.
</li>
<li>
- On <code>line 12</code> created model configuration with most
default parameters.
+ <code>Line 12</code> creates model configuration with most
default parameters.
</li>
<li>
- On <code>line 13</code> created pipeline, based on custom
French language components, which are described below.
+ <code>Line 13</code> creates pipeline based on custom French
language components:
<ul>
- <li><code>NCFrTokenParser</code>. Token parser.</li>
- <li><code>NCFrLemmaPosTokenEnricher</code>. Lemma and
point of speech token enricher.</li>
- <li><code>NCFrStopWordsTokenEnricher</code>. Stop-words
token enricher.</li>
- <li><code>NCFrSemanticEntityParser</code>. Semantic entity
parser extending.</li>
+ <li><code>NCFrTokenParser</code> - Token parser.</li>
+ <li><code>NCFrLemmaPosTokenEnricher</code> - Lemma and
point of speech token enricher.</li>
+ <li><code>NCFrStopWordsTokenEnricher</code> - Stop-words
token enricher.</li>
+ <li><code>NCFrSemanticEntityParser</code> - Semantic
entity parser extending.</li>
</ul>
- Note that <code>NCFrSemanticEntityParser</code> is based on
semantic model definition,
+ Note that <code>NCFrSemanticEntityParser</code> is based on
semantic model definition
described in <code>lightswitch_model_fr.yaml</code> file.
</li>
<li>
- <code>Lines 20 and 21</code> annotates intents <code>ls</code>
and its callback method <code>onMatch</code>.
- Intent <code>ls</code> requires one action (a token belonging
to the group act) and optional list of light locations
- (zero or more tokens with ID ls:loc) - by default we assume
the entire house as a default location.
+ <code>Lines 20 and 21</code> annotate intents <code>ls</code>
and its callback method <code>onMatch()</code>.
+ Intent <code>ls</code> requires one action (a token belonging
to the group <code>act</code>) and optional list of light locations
+ (zero or more tokens with ID <code>ls:loc</code>) - by default
we assume the entire house as a default location.
</li>
<li>
<code>Lines 24 and 25</code> map terms from detected intent to
the formal method parameters of the
- <code>onMatch</code> method.
+ <code>onMatch()</code> method.
</li>
<li>
On the <code>line 32</code> the intent callback simply returns
a confirmation message.
</li>
</ul>
-
- <p>
- Lets review each custom pipeline components.
- </p>
-
+ </section>
+ <section id="code">
+ <h2 class="section-title">Custom Components <a href="#"><i
class="top-link fas fa-fw fa-angle-double-up"></i></a></h2>
<p>
Open
<code>src/main/scala/demo/nlp/token/parser/<b>NCFrTokenParser.scala</b></code>
file and replace its content with the following code:
</p>
-
<pre class="brush: scala, highlight: [19]">
package demo.nlp.token.parser
@@ -278,11 +275,15 @@ fa_icon: fa-cube
toks.toList
</pre>
- <p>
- <code>NCFrTokenParser</code> is simple wrapper, which implements
<code>NCTokenParser</code> based on
- open source solution <a href="https://languagetool.org">Language
Tool</a> solution.
- On <code>line 19</code> <code>NCToken</code> instances created.
- </p>
+ <ul>
+ <li>
+ <code>NCFrTokenParser</code> is a simple wrapper which
implements <code>NCTokenParser</code> based on
+ open source <a href="https://languagetool.org">Language
Tool</a> library.
+ </li>
+ <li>
+ On <code>line 19</code> the <code>NCToken</code> instances
created.
+ </li>
+ </ul>
<p>
Open
<code>src/main/scala/demo/nlp/token/enricher/<b>NCFrLemmaPosTokenEnricher.scala</b></code>
file and replace its content with the following code:
@@ -320,11 +321,15 @@ fa_icon: fa-cube
() // Otherwise NPE.
}
</pre>
- <p>
- <code>NCFrLemmaPosTokenEnricher</code> lemma and point of speech
tokens enricher, based on
- open source solution <a href="https://languagetool.org">Language
Tool</a> solution.
- On <code>line 27 and 28</code> tokens are enriched by
<code>pos</code> and <code>lemma</code> data.
- </p>
+ <ul>
+ <li>
+ <code>NCFrLemmaPosTokenEnricher</code> lemma and point of
speech tokens enricher based on
+ open source <a href="https://languagetool.org">Language
Tool</a> library.
+ </li>
+ <li>
+ On <code>line 27 and 28</code> the tokens are enriched by
<code>pos</code> and <code>lemma</code> data.
+ </li>
+ </ul>
<p>
Open
<code>src/main/scala/demo/nlp/token/enricher/<b>NCFrStopWordsTokenEnricher.scala</b></code>
file and replace its content with the following code:
@@ -357,11 +362,15 @@ fa_icon: fa-cube
pos.startsWith("D")
)
</pre>
- <p>
- <code>NCFrStopWordsTokenEnricher</code> stop-words tokens
enricher, based on
- open source solution <a href="https://lucene.apache.org/">Apache
Lucene</a> solution.
- On <code>line 17</code> tokens are enriched by
<code>stopword</code> flags data.
- </p>
+ <ul>
+ <li>
+ <code>NCFrStopWordsTokenEnricher</code> is a stop-words tokens
enricher based on
+ open source <a href="https://lucene.apache.org/">Apache
Lucene</a> library.
+ </li>
+ <li>
+ On <code>line 17</code> tokens are enriched by
<code>stopword</code> flags data.
+ </li>
+ </ul>
<p>
Open
<code>src/main/scala/demo/nlp/entity/parser/<b>NCFrSemanticEntityParser.scala</b></code>
file and replace its content with the following code:
@@ -383,11 +392,12 @@ fa_icon: fa-cube
mdlSrcOpt = Option(src)
)
</pre>
- <p>
- <code>NCFrSemanticEntityParser</code> extends
<code>NCSemanticEntityParser</code>
- It uses stemmer implementation from <a
href="https://opennlp.apache.org/">Apache OpenNLP</a> solution
- on <code>line 8</code> and already described
<code>NCFrTokenParser</code> token parser implementation on <code>line
12</code>.
- </p>
+ <ul>
+ <li>
+ <code>NCFrSemanticEntityParser</code> extends
<code>NCSemanticEntityParser</code>.
+ It uses stemmer implementation from <a
href="https://opennlp.apache.org/">Apache OpenNLP</a> project.
+ </li>
+ </ul>
</section>
<section id="testing">
@@ -452,7 +462,7 @@ fa_icon: fa-cube
You can run this test via SBT task <code>executeTests</code> or
using IDE.
</p>
<pre class="brush: scala, highlight: []">
- PS C:\apache\incubator-nlpcraft-examples\lightswitch_fr> sbt
executeTests
+ $ sbt executeTests
</pre>
</section>
<section>