summaryrefslogtreecommitdiff
path: root/native/annotator
diff options
context:
space:
mode:
authorChang Li <licha@google.com>2020-05-21 15:09:37 +0100
committerChang Li <licha@google.com>2020-05-21 15:09:37 +0100
commitcac0b44b149a86b651026f31f4f20443076ddc92 (patch)
treee7817d1717ba6531f3847175649d9124560e2a47 /native/annotator
parente2a128a901befb2823e4ed1503afd7fb0a8f1575 (diff)
downloadlibtextclassifier-cac0b44b149a86b651026f31f4f20443076ddc92.tar.gz
Fix a cts test and export libtextclassifier
BUG: 156554531 Test: atest TextClassifierServiceTest Change-Id: I6f41a8296817126dcfbaebcfe1bc803b50fab5bd
Diffstat (limited to 'native/annotator')
-rw-r--r--native/annotator/annotator.cc8
-rw-r--r--native/annotator/experimental/experimental-dummy.h4
-rwxr-xr-xnative/annotator/experimental/experimental.fbs4
-rwxr-xr-xnative/annotator/model.fbs2
4 files changed, 16 insertions, 2 deletions
diff --git a/native/annotator/annotator.cc b/native/annotator/annotator.cc
index 93a3270..4b11c7e 100644
--- a/native/annotator/annotator.cc
+++ b/native/annotator/annotator.cc
@@ -556,6 +556,11 @@ void Annotator::ValidateAndInitialize() {
->do_conflict_resolution_in_raw_mode();
}
+#ifdef TC3_EXPERIMENTAL
+ TC3_LOG(WARNING) << "Enabling experimental annotators.";
+ InitializeExperimentalAnnotators();
+#endif
+
initialized_ = true;
}
@@ -694,7 +699,8 @@ bool Annotator::InitializePersonNameEngineFromFileDescriptor(int fd, int offset,
bool Annotator::InitializeExperimentalAnnotators() {
if (ExperimentalAnnotator::IsEnabled()) {
- experimental_annotator_.reset(new ExperimentalAnnotator(*unilib_));
+ experimental_annotator_.reset(
+ new ExperimentalAnnotator(*selection_feature_processor_, *unilib_));
return true;
}
return false;
diff --git a/native/annotator/experimental/experimental-dummy.h b/native/annotator/experimental/experimental-dummy.h
index d245387..0d50bca 100644
--- a/native/annotator/experimental/experimental-dummy.h
+++ b/native/annotator/experimental/experimental-dummy.h
@@ -20,6 +20,7 @@
#include <string>
#include <vector>
+#include "annotator/feature-processor.h"
#include "annotator/types.h"
#include "utils/utf8/unicodetext.h"
#include "utils/utf8/unilib.h"
@@ -32,7 +33,8 @@ class ExperimentalAnnotator {
// always disabled;
static constexpr bool IsEnabled() { return false; }
- explicit ExperimentalAnnotator(const UniLib& unilib) {}
+ explicit ExperimentalAnnotator(const FeatureProcessor& feature_processor,
+ const UniLib& unilib) {}
bool Annotate(const UnicodeText& context,
std::vector<AnnotatedSpan>* candidates) const {
diff --git a/native/annotator/experimental/experimental.fbs b/native/annotator/experimental/experimental.fbs
new file mode 100755
index 0000000..fff2d9e
--- /dev/null
+++ b/native/annotator/experimental/experimental.fbs
@@ -0,0 +1,4 @@
+namespace libtextclassifier3;
+table ExperimentalModel {
+}
+
diff --git a/native/annotator/model.fbs b/native/annotator/model.fbs
index 95e692d..bdb7a17 100755
--- a/native/annotator/model.fbs
+++ b/native/annotator/model.fbs
@@ -15,6 +15,7 @@
//
include "annotator/entity-data.fbs";
+include "annotator/experimental/experimental.fbs";
include "annotator/grammar/dates/dates.fbs";
include "utils/codepoint-range.fbs";
include "utils/flatbuffers.fbs";
@@ -657,6 +658,7 @@ table Model {
translate_annotator_options:TranslateAnnotatorOptions;
grammar_model:GrammarModel;
conflict_resolution_options:Model_.ConflictResolutionOptions;
+ experimental_model:ExperimentalModel;
}
// Method for selecting the center token.