ml: Move tclib model file installation to tclib's ebuild.

We used to put the model installation in mlservice's ebuild because we
thought the unit test can not see the model files in the standard
location. It turns it can. So it is better to install the model files
in its own ebuild.

Now we do not need to load the model file in
`MachineLearningServiceImpl` and can put the model initialization all
in "text_classifier_impl.cc"

Also removed a unit test on testing non-exist model file for tclib
because it seems there is no such tests for all the other models.

BUG=none
TEST=FEATURES=test emerge-nocturne ml

Cq-Depend: 2472978
Change-Id: I4ac44446b99815705e2c82dc543b41170c7f7fb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/2473178
Reviewed-by: Andrew Moylan <amoylan@chromium.org>
Commit-Queue: Honglin Yu <honglinyu@chromium.org>
Tested-by: Honglin Yu <honglinyu@chromium.org>
diff --git a/ml/machine_learning_service_impl.cc b/ml/machine_learning_service_impl.cc
index 39ff78d..bf9778b 100644
--- a/ml/machine_learning_service_impl.cc
+++ b/ml/machine_learning_service_impl.cc
@@ -50,12 +50,6 @@
 // `LoadFlatBufferModel`, `LoadTextClassifier` or LoadHandwritingModel).
 constexpr char kMetricsRequestName[] = "LoadModelResult";
 
-constexpr char kTextClassifierModelFile[] =
-    "mlservice-model-text_classifier_en-v711.fb";
-
-constexpr char kLanguageIdentificationModelFile[] =
-    "mlservice-model-language_identification-20190924.smfb";
-
 constexpr char kIcuDataFilePath[] = "/opt/google/chrome/icudtl.dat";
 
 }  // namespace
@@ -65,7 +59,6 @@
     base::Closure disconnect_handler,
     const std::string& model_dir)
     : icu_data_(nullptr),
-      text_classifier_model_filename_(kTextClassifierModelFile),
       builtin_model_metadata_(GetBuiltinModelMetadata()),
       model_dir_(model_dir),
       receiver_(this,
@@ -86,11 +79,6 @@
   }
 }
 
-void MachineLearningServiceImpl::SetTextClassifierModelFilenameForTesting(
-    const std::string& filename) {
-  text_classifier_model_filename_ = filename;
-}
-
 void MachineLearningServiceImpl::Clone(
     mojo::PendingReceiver<MachineLearningService> receiver) {
   clone_receivers_.Add(this, std::move(receiver));
@@ -182,22 +170,8 @@
   RequestMetrics request_metrics("TextClassifier", kMetricsRequestName);
   request_metrics.StartRecordingPerformanceMetrics();
 
-  // Attempt to load model.
-  std::string model_path = model_dir_ + text_classifier_model_filename_;
-  auto scoped_mmap =
-      std::make_unique<libtextclassifier3::ScopedMmap>(model_path);
-  if (!scoped_mmap->handle().ok()) {
-    LOG(ERROR) << "Failed to load the text classifier model file '"
-               << model_path << "'.";
-    std::move(callback).Run(LoadModelResult::LOAD_MODEL_ERROR);
-    request_metrics.RecordRequestEvent(LoadModelResult::LOAD_MODEL_ERROR);
-    return;
-  }
-
   // Create the TextClassifier.
-  if (!TextClassifierImpl::Create(&scoped_mmap,
-                                  model_dir_ + kLanguageIdentificationModelFile,
-                                  std::move(receiver))) {
+  if (!TextClassifierImpl::Create(std::move(receiver))) {
     LOG(ERROR) << "Failed to create TextClassifierImpl object.";
     std::move(callback).Run(LoadModelResult::LOAD_MODEL_ERROR);
     request_metrics.RecordRequestEvent(LoadModelResult::LOAD_MODEL_ERROR);