This is an automated email from the ASF dual-hosted git repository.
aradzinski pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/master by this push:
new 827a7c1 WIP migration
827a7c1 is described below
commit 827a7c1bf3cb8189d90b66cb619b061dc65914ac
Author: Aaron Radzinski <[email protected]>
AuthorDate: Wed Oct 6 13:36:25 2021 -0700
WIP migration
---
.../org/apache/nlpcraft/common/util/NCUtils.scala | 1 -
.../scala/org/apache/nlpcraft/model/NCIntent.java | 89 +++++++++++++++++++++
.../org/apache/nlpcraft/model/NCIntentRef.java | 81 +++++++++++++++++++
.../org/apache/nlpcraft/model/NCIntentSample.java | 90 +++++++++++++++++++++
.../apache/nlpcraft/model/NCIntentSampleRef.java | 91 ++++++++++++++++++++++
.../org/apache/nlpcraft/model/NCIntentSkip.java | 60 ++++++++++++++
.../org/apache/nlpcraft/model/NCIntentTerm.java | 77 ++++++++++++++++++
.../apache/nlpcraft/model/NCModelAddClasses.java | 55 +++++++++++++
.../apache/nlpcraft/model/NCModelAddPackage.java | 55 +++++++++++++
9 files changed, 598 insertions(+), 1 deletion(-)
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
index 479ebb5..4cc3469 100644
--- a/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/common/util/NCUtils.scala
@@ -84,7 +84,6 @@ object NCUtils extends LazyLogging:
case None => false
case Some(v) => java.lang.Boolean.valueOf(v) == java.lang.Boolean.TRUE
-
/**
* Gets random value from given sequence.
*
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
new file mode 100644
index 0000000..c8963e1
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntent.java
@@ -0,0 +1,89 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.*;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Annotation to bind an intent with the method serving as its callback. This
annotation takes a string value
+ * that defines an intent via IDL. This annotation can also be applied to a
model's class in
+ * which case it will just declare the intent without binding it and the
callback method will need to
+ * use {@link NCIntentRef} annotation to actually bind it to the declared
intent. Note that multiple intents
+ * can be bound to the same callback method, but only one callback method can
be bound with a given intent.
+ * <p>
+ * Here's an example of using this annotation (from <a target=_new
href="https://nlpcraft.apache.org/examples/light_switch.html">LightSwitch</a>
example):
+ * <pre class="brush: java, highlight: [1,2]">
+ * {@literal @}NCIntent("import('intents.idl')")
+ * {@literal @}NCIntent("intent=act term(act)={has(tok_groups, 'act')}
term(loc)={# == 'ls:loc'}*")
+ * {@literal @}NCIntentSample(Array(
+ * "Turn the lights off in the entire house.",
+ * "Switch on the illumination in the master bedroom closet.",
+ * "Get the lights on.",
+ * "Please, put the light out in the upstairs bedroom."
+ * ))
+ * def onMatch(
+ * {@literal @}NCIntentTerm("act") actTok: NCToken,
+ * {@literal @}NCIntentTerm("loc") locToks: List[NCToken]
+ * ): NCResult = {
+ * ...
+ * }
+ * </pre>
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntentRef
+ * @see NCIntentTerm
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCModelAddClasses
+ * @see NCModelAddPackage
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ */
+@Documented
+@Retention(value=RUNTIME)
+@Target(value={METHOD, TYPE})
+@Repeatable(NCIntent.NCIntentList.class)
+public @interface NCIntent {
+ /**
+ * Intent specification using IDL.
+ *
+ * @return Intent specification using IDL.
+ */
+ String value() default "";
+
+ /**
+ * Grouping annotation required for when more than one {@link NCIntent}
annotation is used.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Documented
+ @Target(value={METHOD, TYPE})
+ @interface NCIntentList {
+ /**
+ * Gets the list of all {@link NCIntent} annotations attached to the
callback or class.
+ *
+ * @return List of all {@link NCIntent} annotations attached to the
callback or class.
+ */
+ NCIntent[] value();
+ }
+}
diff --git a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
new file mode 100644
index 0000000..3348ffe
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentRef.java
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.*;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation referencing an intent defined outside of callback method
declaration. Multiple such annotations
+ * can be applied to the callback method. Note that multiple intents can be
bound to the same callback method,
+ * but only one callback method can be bound with a given intent.
+ * <p>
+ * Here's an example of using this annotation (from <a target=_new
href="https://nlpcraft.apache.org/examples/alarm_clock.html">Alarm Clock</a>
example):
+ * <pre class="brush: java, highlight: [1]">
+ * {@literal @}NCIntentRef("alarm")
+ * {@literal @}NCIntentSampleRef("alarm_samples.txt")
+ * NCResult onMatch(
+ * NCIntentMatch ctx,
+ * {@literal @}NCIntentTerm("nums") List<NCToken> numToks
+ * ) {
+ * ...
+ * }
+ * </pre>
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntent
+ * @see NCIntentTerm
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCModelAddClasses
+ * @see NCModelAddPackage
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ */
+@Documented
+@Retention(value=RUNTIME)
+@Target(value=METHOD)
+@Repeatable(NCIntentRef.NCIntentRefList.class)
+public @interface NCIntentRef {
+ /**
+ * ID of the intent defined externally.
+ *
+ * @return ID of the intent defined externally.
+ */
+ String value() default "";
+
+ /**
+ * Grouping annotation required for when more than one {@link NCIntentRef}
annotation is used.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(value=METHOD)
+ @Documented
+ @interface NCIntentRefList {
+ /**
+ * Gets the list of all {@link NCIntentRef} annotations attached to
the callback.
+ *
+ * @return List of all {@link NCIntentRef} annotations attached to the
callback.
+ */
+ NCIntentRef[] value();
+ }
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
new file mode 100644
index 0000000..b18f44a
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSample.java
@@ -0,0 +1,90 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.*;
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * The corpus of intent samples that is used for documentaiton and model
auto-validation.
+ * <p>
+ * This annotation defines samples of the user input that should match an
intent. This
+ * annotation should be used together with {@link NCIntent} or {@link
NCIntentRef} annotations on the callback
+ * methods. Method can have multiple annotations of this type and each
annotation can define multiple input
+ * examples. See similar {@link NCIntentSampleRef} annotation that allows to
load samples from external resources like
+ * file or URL.
+ * <p>
+ * Here's an example of using this annotation (from <a target=_new
href="https://nlpcraft.apache.org/examples/light_switch.html">LightSwitch</a>
example):
+ * <pre class="brush: java, highlight: [2]">
+ * {@literal @}NCIntent("intent=act term(act)={has(tok_groups, 'act')}
term(loc)={# == 'ls:loc'}*")
+ * {@literal @}NCIntentSample(Array(
+ * "Turn the lights off in the entire house.",
+ * "Switch on the illumination in the master bedroom closet.",
+ * "Get the lights on.",
+ * "Please, put the light out in the upstairs bedroom."
+ * ))
+ * def onMatch(
+ * {@literal @}NCIntentTerm("act") actTok: NCToken,
+ * {@literal @}NCIntentTerm("loc") locToks: List[NCToken]
+ * ): NCResult = {
+ * ...
+ * }
+ * </pre>
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntentSampleRef
+ * @see NCIntent
+ * @see NCIntentRef
+ * @see NCIntentTerm
+ * @see NCModelAddClasses
+ * @see NCModelAddPackage
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ * @see NCTestAutoModelValidator
+ */
+@Retention(value=RUNTIME)
+@Target(value=METHOD)
+@Repeatable(NCIntentSample.NCIntentSampleList.class)
+public @interface NCIntentSample {
+ /**
+ * Gets a list of user input samples that should match corresponding
intent. This annotation should be
+ * attached the intent callback method.
+ *
+ * @return Set of user input examples that should match corresponding
intent.
+ */
+ String[] value();
+
+ /**
+ * Grouping annotation required for when more than one {@link
NCIntentSample} annotation is used.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(value=METHOD)
+ @Documented
+ @interface NCIntentSampleList {
+ /**
+ * Gets the list of all {@link NCIntentSample} annotations attached to
the callback.
+ *
+ * @return List of all {@link NCIntentSample} annotations attached to
the callback.
+ */
+ NCIntentSample[] value();
+ }
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
new file mode 100644
index 0000000..7df7228
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSampleRef.java
@@ -0,0 +1,91 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.Repeatable;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * The corpus of intent samples that is used for documentaiton and model
auto-validation.
+ * <p>
+ * This annotation allows to load these samples from the external sources like
local file or URL and
+ * should be used together with {@link NCIntent} or {@link NCIntentRef}
annotations on the callback
+ * methods. Method can have multiple annotations of this type and each
annotation can define multiple input
+ * examples. See similar {@link NCIntentSample} annotation that allows to
define samples in place.
+ * <p>
+ * Here's an example of using this annotation:
+ * <pre class="brush: java, highlight: [2]">
+ * {@literal @}NCIntentRef("alarm")
+ * {@literal @}NCIntentSampleRef("alarm_samples.txt")
+ * NCResult onMatch(
+ * NCIntentMatch ctx,
+ * {@literal @}NCIntentTerm("nums") List<NCToken> numToks
+ * ) {
+ * ...
+ * }
+ * </pre>
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntentSample
+ * @see NCIntent
+ * @see NCIntentRef
+ * @see NCIntentTerm
+ * @see NCModelAddClasses
+ * @see NCModelAddPackage
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ * @see NCTestAutoModelValidator
+ */
+@Retention(value=RUNTIME)
+@Target(value=METHOD)
+@Repeatable(NCIntentSampleRef.NCIntentSampleList.class)
+public @interface NCIntentSampleRef {
+ /**
+ * Local file path, classpath resource path or URL supported by {@link
java.net.URL} class. The content of the source
+ * should be a new-line separated list of string. Empty strings and
strings starting with '#" (hash) symbol will
+ * be ignored. This annotation should be attached the intent callback
method. Note that using this annotation is equivalent
+ * to using {@link NCIntentSample} annotation and listing all of its
samples in place instead of an external source.
+ *
+ * @return Local file path, classpath resource path or URL supported by
{@link java.net.URL} class.
+ */
+ String value();
+
+ /**
+ * Grouping annotation required for when more than one {@link
NCIntentSampleRef} annotation is used.
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(value=METHOD)
+ @Documented
+ @interface NCIntentSampleList {
+ /**
+ * Gets the list of all {@link NCIntentSampleRef} annotations attached
to the callback.
+ *
+ * @return List of all {@link NCIntentSampleRef} annotations attached
to the callback.
+ */
+ NCIntentSampleRef[] value();
+ }
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
new file mode 100644
index 0000000..a04ccd1
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentSkip.java
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import org.apache.nlpcraft.common.*;
+
+/**
+ * Control flow exception to skip current intent. This exception can be thrown
by the intent
+ * callback to indicate that current intent should be skipped (even though
+ * it was matched and its callback was called). If there's more than one
intent matched the next best matching intent
+ * will be selected and its callback will be called.
+ * <p>
+ * This exception becomes useful when it is hard or impossible to encode the
entire matching logic using just
+ * declarative IDL. In these cases the intent definition can be relaxed and
the "last mile" of intent
+ * matching can happen inside the intent callback's user logic. If it is
determined that intent in fact does
+ * not match then throwing this exception allows to try next best matching
intent, if any.
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html">Intent Matching</a>
section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntent
+ * @see NCIntentTerm
+ * @see NCIntentRef
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ */
+public class NCIntentSkip extends NCException {
+ /**
+ * Creates new intent skip exception.
+ */
+ public NCIntentSkip() {
+ super("Intent skipped.");
+ }
+
+ /**
+ * Creates new intent skip exception with given debug message.
+ *
+ * @param msg Skip message for debug output.
+ */
+ public NCIntentSkip(String msg) {
+ super(msg);
+ }
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
new file mode 100644
index 0000000..d8302ac
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCIntentTerm.java
@@ -0,0 +1,77 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.*;
+
+import static java.lang.annotation.ElementType.*;
+import static java.lang.annotation.RetentionPolicy.*;
+
+/**
+ * Annotation to mark callback parameter to receive intent term's tokens. This
is a companion annotation
+ * to {@link NCIntent} and {@link NCIntentRef} annotations and can only be
used for
+ * the parameters of the methods that are annotated with {@link NCIntent} or
{@link NCIntentRef}.
+ * {@code NCIntentTerm} takes a term ID as its only mandatory parameter and
should be applied to callback
+ * method parameters to get the tokens associated with that term (if and when
the intent was matched and that
+ * callback was invoked).
+ * <p>
+ * Note that if multiple intents bound to the same callback method, all such
intents should have the named
+ * terms specified by this annotation.
+ * <p>
+ * Here's an example of using this annotation (from <a target=_new
href="https://nlpcraft.apache.org/examples/light_switch.html">LightSwitch</a>
example):
+ * <pre class="brush: java, highlight: [10,11]">
+ * {@literal @}NCIntent("import('intents.idl')")
+ * {@literal @}NCIntent("intent=act term(act)={has(tok_groups, 'act')}
term(loc)={# == 'ls:loc'}*")
+ * {@literal @}NCIntentSample(Array(
+ * "Turn the lights off in the entire house.",
+ * "Switch on the illumination in the master bedroom closet.",
+ * "Get the lights on.",
+ * "Please, put the light out in the upstairs bedroom."
+ * ))
+ * def onMatch(
+ * {@literal @}NCIntentTerm("act") actTok: NCToken,
+ * {@literal @}NCIntentTerm("loc") locToks: List[NCToken]
+ * ): NCResult = {
+ * ...
+ * }
+ * </pre>
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCIntent
+ * @see NCIntentRef
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCModelAddClasses
+ * @see NCModelAddPackage
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ * @see NCModel#onMatchedIntent(NCIntentMatch)
+ */
+@Documented
+@Retention(value=RUNTIME)
+@Target(value=PARAMETER)
+public @interface NCIntentTerm {
+ /**
+ * ID of the intent term.
+ *
+ * @return ID of the intent term.
+ */
+ String value();
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
new file mode 100644
index 0000000..d8241d4
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddClasses.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation to add one or more classes that contain intent callbacks. This
annotation should be applied to the main
+ * model class. When found the internal intent detection algorithm will scan
these additional classes searching
+ * for intent callbacks.
+ * <p>
+ * Additionally with {@link NCModelAddPackage} annotation, these two
annotations allowing to have model implementation,
+ * i.e. intent callbacks, in external classes not linked through sub-type
relationship to the main model class. This
+ * approach provides greater modularity, isolated testability and overall
coding efficiencies for the larger models
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCModelAddPackage
+ * @see NCIntentRef
+ * @see NCIntentTerm
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ */
+@Retention(value=RUNTIME)
+@Target(value=TYPE)
+public @interface NCModelAddClasses {
+ /**
+ * Array of class instances to additionally scan for intent callbacks.
+ *
+ * @return Array of class instances to additionally scan for intent
callbacks.
+ */
+ Class<?>[] value();
+}
diff --git
a/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
new file mode 100644
index 0000000..41ca9dc
--- /dev/null
+++ b/nlpcraft/src/main/scala/org/apache/nlpcraft/model/NCModelAddPackage.java
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+
+package org.apache.nlpcraft.model;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+/**
+ * Annotation to add one or more JVM packages that contain classes with intent
callbacks. This annotation should be
+ * applied to the main model class. When found the internal intent detection
algorithm will recursively scan these
+ * additional packages and their classes searching for intent callbacks.
+ * <p>
+ * Additionally with {@link NCModelAddClasses} annotation, these two
annotations allowing to have model implementation,
+ * i.e. intent callbacks, in external classes not linked through sub-type
relationship to the main model class. This
+ * approach provides greater modularity, isolated testability and overall
coding efficiencies for the larger models
+ * <p>
+ * Read full documentation in <a target=_
href="https://nlpcraft.apache.org/intent-matching.html#binding">Intent
Matching</a> section and review
+ * <a target=_
href="https://github.com/apache/incubator-nlpcraft/tree/master/nlpcraft-examples">examples</a>.
+ *
+ * @see NCModelAddClasses
+ * @see NCIntentRef
+ * @see NCIntentTerm
+ * @see NCIntentSample
+ * @see NCIntentSampleRef
+ * @see NCIntentSkip
+ * @see NCIntentMatch
+ */
+@Retention(value=RUNTIME)
+@Target(value=TYPE)
+public @interface NCModelAddPackage {
+ /**
+ * Array of JVM package names to recursively scan for intent callbacks.
+ *
+ * @return Array of JVM package names to recursively scan for intent
callbacks.
+ */
+ String[] value();
+}