• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.textclassifier;
18 
19 import android.os.LocaleList;
20 import com.android.textclassifier.common.ModelFile;
21 import com.android.textclassifier.common.ModelType.ModelTypeDef;
22 import com.android.textclassifier.utils.IndentingPrintWriter;
23 import javax.annotation.Nullable;
24 
25 /**
26  * Interface to list model files, find the best model file for a use case and dump internal state
27  */
28 interface ModelFileManager {
29 
30   /**
31    * Returns the best model file for the given localelist, {@code null} if nothing is found.
32    *
33    * @param modelType the type of model to look up (e.g. annotator, lang_id, etc.)
34    * @param localePreferences an ordered list of user preferences for locales, use {@code null} if
35    *     there is no preference.
36    * @param detectedLocales an ordered list of locales detected from the Tcs request text, use
37    *     {@code null} if no detected locales are provided
38    */
39   @Nullable
findBestModelFile( @odelTypeDef String modelType, @Nullable LocaleList localePreferences, @Nullable LocaleList detectedLocales)40   ModelFile findBestModelFile(
41       @ModelTypeDef String modelType,
42       @Nullable LocaleList localePreferences,
43       @Nullable LocaleList detectedLocales);
44 
45   /**
46    * Dumps the internal state for debugging.
47    *
48    * @param printWriter writer to write dumped states
49    */
dump(IndentingPrintWriter printWriter)50   void dump(IndentingPrintWriter printWriter);
51 }
52