Repository: deepjavalibrary/djl
Pull request #1927 (2022-08-18 18:10:37)

[api] Move TokenClassificationServingTranslator.java to api package
Change-Id: I21581a46209b379d96ebaa75ec70daeb1a4c664f

## Description ##

Brief description of what this PR is about

- If this change is a backward incompatible change, why must this change be made?
- Interesting edge cases to note here



Patch:
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/NamedEntity.java b/api/src/main/java/ai/djl/modality/nlp/translator/NamedEntity.java
similarity index 98%
rename from extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/NamedEntity.java
rename to api/src/main/java/ai/djl/modality/nlp/translator/NamedEntity.java
index 19325d5e5..26841c603 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/NamedEntity.java
+++ b/api/src/main/java/ai/djl/modality/nlp/translator/NamedEntity.java
@@ -10,7 +10,7 @@
  * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
  * and limitations under the License.
  */
-package ai.djl.huggingface.translator;
+package ai.djl.modality.nlp.translator;
 
 /** A class that represents a {@code NamedEntity} object. */
 public class NamedEntity {
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationServingTranslator.java b/api/src/main/java/ai/djl/modality/nlp/translator/TokenClassificationServingTranslator.java
similarity index 98%
rename from extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationServingTranslator.java
rename to api/src/main/java/ai/djl/modality/nlp/translator/TokenClassificationServingTranslator.java
index 172b836b4..9c54446a2 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationServingTranslator.java
+++ b/api/src/main/java/ai/djl/modality/nlp/translator/TokenClassificationServingTranslator.java
@@ -10,7 +10,7 @@
  * OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
  * and limitations under the License.
  */
-package ai.djl.huggingface.translator;
+package ai.djl.modality.nlp.translator;
 
 import ai.djl.modality.Input;
 import ai.djl.modality.Output;
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslator.java b/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslator.java
index 5249f358b..7eceb2eff 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslator.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslator.java
@@ -15,6 +15,7 @@ package ai.djl.huggingface.translator;
 import ai.djl.huggingface.tokenizers.Encoding;
 import ai.djl.huggingface.tokenizers.HuggingFaceTokenizer;
 import ai.djl.huggingface.tokenizers.jni.CharSpan;
+import ai.djl.modality.nlp.translator.NamedEntity;
 import ai.djl.ndarray.NDArray;
 import ai.djl.ndarray.NDList;
 import ai.djl.ndarray.NDManager;
diff --git a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslatorFactory.java b/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslatorFactory.java
index d5bf25518..556b7e4eb 100644
--- a/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslatorFactory.java
+++ b/extensions/tokenizers/src/main/java/ai/djl/huggingface/translator/TokenClassificationTranslatorFactory.java
@@ -15,6 +15,8 @@ package ai.djl.huggingface.translator;
 import ai.djl.Model;
 import ai.djl.modality.Input;
 import ai.djl.modality.Output;
+import ai.djl.modality.nlp.translator.NamedEntity;
+import ai.djl.modality.nlp.translator.TokenClassificationServingTranslator;
 import ai.djl.translate.TranslateException;
 import ai.djl.translate.Translator;
 import ai.djl.translate.TranslatorFactory;


Test patch:
diff --git a/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/TranslatorTest.java b/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/TranslatorTest.java
index 72decd31b..2cad1353b 100644
--- a/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/TranslatorTest.java
+++ b/extensions/tokenizers/src/test/java/ai/djl/huggingface/tokenizers/TranslatorTest.java
@@ -15,7 +15,6 @@ package ai.djl.huggingface.tokenizers;
 import ai.djl.Model;
 import ai.djl.ModelException;
 import ai.djl.huggingface.translator.FillMaskTranslatorFactory;
-import ai.djl.huggingface.translator.NamedEntity;
 import ai.djl.huggingface.translator.QuestionAnsweringTranslatorFactory;
 import ai.djl.huggingface.translator.TokenClassificationTranslatorFactory;
 import ai.djl.inference.Predictor;
@@ -23,6 +22,7 @@ import ai.djl.modality.Classifications;
 import ai.djl.modality.Input;
 import ai.djl.modality.Output;
 import ai.djl.modality.nlp.qa.QAInput;
+import ai.djl.modality.nlp.translator.NamedEntity;
 import ai.djl.ndarray.NDArray;
 import ai.djl.ndarray.NDList;
 import ai.djl.ndarray.NDManager;