ml: add the mojo API of langid
Please see text_classifier.mojom for the interface.
BUG=chromium:1086044
TEST=unit test
TEST=on device (eve), langid works from chromium.
Cq-Depend: chromium:2289247
Change-Id: I8f88f63016321b7f2c534d6e031aaeaa1795b27e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2289248
Reviewed-by: Andrew Moylan <amoylan@chromium.org>
Tested-by: Honglin Yu <honglinyu@chromium.org>
Commit-Queue: Honglin Yu <honglinyu@chromium.org>
diff --git a/ml/text_classifier_impl.h b/ml/text_classifier_impl.h
index 172974a..e12fc83 100644
--- a/ml/text_classifier_impl.h
+++ b/ml/text_classifier_impl.h
@@ -26,19 +26,21 @@
: public chromeos::machine_learning::mojom::TextClassifier {
public:
// Interface to create new `TextClassifierImpl` object. This function will
- // automatically achieve strong binding.The model object will be deleted when
+ // automatically achieve strong binding. The model object will be deleted when
// the corresponding mojo connection meets error.
// Will return false if it fails to create the annotator object, otherwise
// return true.
static bool Create(
- std::unique_ptr<libtextclassifier3::ScopedMmap>* mmap,
+ std::unique_ptr<libtextclassifier3::ScopedMmap>* annotator_model_mmap,
+ const std::string& langid_model_path,
chromeos::machine_learning::mojom::TextClassifierRequest request);
private:
// A private constructor, call `TextClassifierImpl::Create` to create new
// objects.
explicit TextClassifierImpl(
- std::unique_ptr<libtextclassifier3::ScopedMmap>* mmap,
+ std::unique_ptr<libtextclassifier3::ScopedMmap>* annotator_model_mmap,
+ const std::string& langid_model_path,
chromeos::machine_learning::mojom::TextClassifierRequest request);
void SetConnectionErrorHandler(base::Closure connection_error_handler);
@@ -53,8 +55,15 @@
chromeos::machine_learning::mojom::TextSuggestSelectionRequestPtr request,
SuggestSelectionCallback callback) override;
+ // chromeos::machine_learning::mojom::TextClassifier:
+ void FindLanguages(const std::string& text,
+ FindLanguagesCallback callback) override;
+
std::unique_ptr<libtextclassifier3::Annotator> annotator_;
+ std::unique_ptr<libtextclassifier3::mobile::lang_id::LangId>
+ language_identifier_;
+
mojo::Binding<chromeos::machine_learning::mojom::TextClassifier> binding_;
DISALLOW_COPY_AND_ASSIGN(TextClassifierImpl);