Home | History | Annotate | Download | only in script
      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 #ifndef NLP_SAFT_COMPONENTS_LANG_ID_MOBILE_SCRIPT_SCRIPT_DETECTOR_H_
     18 #define NLP_SAFT_COMPONENTS_LANG_ID_MOBILE_SCRIPT_SCRIPT_DETECTOR_H_
     19 
     20 #include "lang_id/common/registry.h"
     21 
     22 namespace libtextclassifier3 {
     23 namespace mobile {
     24 
     25 // Base class for Unicode script detectors.  Individual detectors may differ in
     26 // code size, speed, precision, etc.  You can use the registration mechanism to
     27 // get the ScriptDetector that's most appropriate to your application.
     28 class ScriptDetector : public RegisterableClass<ScriptDetector> {
     29  public:
     30   virtual ~ScriptDetector() = default;
     31 
     32   // Returns a number between 0 and GetMaxScript() (inclusive on both ends) that
     33   // indicates the script of the UTF8 character that starts at address |s| and
     34   // has |num_bytes|.
     35   virtual int GetScript(const char *s, int num_bytes) const = 0;
     36 
     37   // Returns max result that can be returned by GetScript().
     38   virtual int GetMaxScript() const = 0;
     39 };
     40 
     41 SAFTM_DECLARE_CLASS_REGISTRY_NAME(ScriptDetector);
     42 
     43 }  // namespace mobile
     44 }  // namespace nlp_saft
     45 
     46 #endif  // NLP_SAFT_COMPONENTS_LANG_ID_MOBILE_SCRIPT_SCRIPT_DETECTOR_H_
     47