This is an automated email from the ASF dual-hosted git repository.
sergeykamov 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 fa661e4 WIP.
fa661e4 is described below
commit fa661e4390e572684ec82449f27bbe80167648e1
Author: skhdl <[email protected]>
AuthorDate: Thu Oct 20 09:33:44 2022 +0400
WIP.
---
examples/light_switch_ru.html | 101 ++++++++++++++++++++++++------------------
1 file changed, 59 insertions(+), 42 deletions(-)
diff --git a/examples/light_switch_ru.html b/examples/light_switch_ru.html
index 80d8d44..1fb5aa8 100644
--- a/examples/light_switch_ru.html
+++ b/examples/light_switch_ru.html
@@ -48,7 +48,7 @@ fa_icon: fa-cube
ThisBuild / scalaVersion := "3.1.3"
lazy val root = (project in file("."))
.settings(
- name := "NLPCraft LightSwitch FR Example",
+ name := "NLPCraft LightSwitch RU Example",
version := "{{site.latest_version}}",
libraryDependencies += "org.apache.nlpcraft" % "nlpcraft" %
"{{site.latest_version}}",
libraryDependencies += "org.apache.lucene" %
"lucene-analyzers-common" % "8.11.2",
@@ -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_ru.yaml</code> - YAML configuration
file, which contains model description.</li>
- <li><code>LightSwitchRuModel.scala</code> - Scala class, model
implementation.</li>
- <li><code>NCRuSemanticEntityParser.scala</code> - Scala class,
semantic entity parser, custom implementation for Russian language.</li>
- <li><code>NCRuLemmaPosTokenEnricher.scala</code> - Scala class,
lemma and point of speech token enricher, custom implementation for Russian
language.</li>
- <li><code>NCRuStopWordsTokenEnricher.scala</code> - Scala class,
stop-words token enricher, custom implementation for Russian language.</li>
- <li><code>NCRuTokenParser.scala</code> - Scala class, token
parser, custom implementation for Russian language.</li>
- <li><code>LightSwitchRuModelSpec.scala</code> - Scala tests class,
which allows to test your model.</li>
+ <li><code>LightSwitchRuModel.scala</code> - Model
implementation.</li>
+ <li><code>NCRuSemanticEntityParser.scala</code> - Semantic entity
parser, custom implementation for Russian language.</li>
+ <li><code>NCRuLemmaPosTokenEnricher.scala</code> - Lemma and point
of speech token enricher, custom implementation for Russian language.</li>
+ <li><code>NCRuStopWordsTokenEnricher.scala</code> - Stop-words
token enricher, custom implementation for Russian language.</li>
+ <li><code>NCRuTokenParser.scala</code> - Token parser, custom
implementation for Russian language.</li>
+ <li><code>LightSwitchRuModelSpec.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
@@ -211,36 +211,36 @@ 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
Russian language components, which are described below.
+ <code>Line 13</code> creates pipeline, based on custom Russian
language components, which are described below.
<ul>
- <li><code>NCRuTokenParser</code>. Token parser.</li>
- <li><code>NCRuLemmaPosTokenEnricher</code>. Lemma and
point of speech token enricher.</li>
- <li><code>NCRuStopWordsTokenEnricher</code>. Stop-words
token enricher.</li>
- <li><code>NCRuSemanticEntityParser</code>. Semantic entity
parser extending.</li>
+ <li><code>NCRuTokenParser</code> - Token parser.</li>
+ <li><code>NCRuLemmaPosTokenEnricher</code> - Lemma and
point of speech token enricher.</li>
+ <li><code>NCRuStopWordsTokenEnricher</code> - Stop-words
token enricher.</li>
+ <li><code>NCRuSemanticEntityParser</code> - Semantic
entity parser extending.</li>
</ul>
- Note that <code>NCRuSemanticEntityParser</code> is based on
semantic model definition,
+ Note that <code>NCRuSemanticEntityParser</code> is based on
semantic model definition
described in <code>lightswitch_model_ru.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>NCRuTokenParser.scala</b></code>
file and replace its content with the following code:
@@ -275,11 +275,16 @@ fa_icon: fa-cube
toks.toList
</pre>
- <p>
- <code>NCRuTokenParser</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>NCRuTokenParser</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>NCRuLemmaPosTokenEnricher.scala</b></code>
file and replace its content with the following code:
@@ -317,11 +322,16 @@ fa_icon: fa-cube
() // Otherwise NPE.
}
</pre>
- <p>
- <code>NCRuLemmaPosTokenEnricher</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>NCRuLemmaPosTokenEnricher</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>NCRuStopWordsTokenEnricher.scala</b></code>
file and replace its content with the following code:
@@ -353,11 +363,16 @@ fa_icon: fa-cube
pos.startsWith("PREP")
)
</pre>
- <p>
- <code>NCRuStopWordsTokenEnricher</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>NCRuStopWordsTokenEnricher</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>NCRuSemanticEntityParser.scala</b></code>
file and replace its content with the following code:
@@ -379,11 +394,13 @@ fa_icon: fa-cube
mdlSrcOpt = Option(src)
)
</pre>
- <p>
- <code>NCRuSemanticEntityParser</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>NCRuTokenParser</code> token parser implementation on <code>line
12</code>.
- </p>
+
+ <ul>
+ <li>
+ <code>NCRuSemanticEntityParser</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">
@@ -439,7 +456,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_ru> sbt
executeTests
+ $ sbt executeTests
</pre>
</section>
<section>