• 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 #ifndef LIBTEXTCLASSIFIER_ANNOTATOR_KNOWLEDGE_KNOWLEDGE_ENGINE_DUMMY_H_
18 #define LIBTEXTCLASSIFIER_ANNOTATOR_KNOWLEDGE_KNOWLEDGE_ENGINE_DUMMY_H_
19 
20 #include <string>
21 
22 #include "annotator/model_generated.h"
23 #include "annotator/types.h"
24 #include "utils/base/status.h"
25 #include "utils/optional.h"
26 #include "utils/utf8/unilib.h"
27 
28 namespace libtextclassifier3 {
29 
30 // A dummy implementation of the knowledge engine.
31 class KnowledgeEngine {
32  public:
Initialize(const std::string & serialized_config,const UniLib * unilib)33   bool Initialize(const std::string& serialized_config, const UniLib* unilib) {
34     return true;
35   }
36 
SetPriorityScore(float priority_score)37   void SetPriorityScore(float priority_score) {}
38 
ClassifyText(const std::string & text,CodepointSpan selection_indices,AnnotationUsecase annotation_usecase,const Optional<LocationContext> & location_context,const Permissions & permissions,ClassificationResult * classification_result)39   bool ClassifyText(const std::string& text, CodepointSpan selection_indices,
40                     AnnotationUsecase annotation_usecase,
41                     const Optional<LocationContext>& location_context,
42                     const Permissions& permissions,
43                     ClassificationResult* classification_result) const {
44     return false;
45   }
46 
Chunk(const std::string & text,AnnotationUsecase annotation_usecase,const Optional<LocationContext> & location_context,const Permissions & permissions,std::vector<AnnotatedSpan> * result)47   bool Chunk(const std::string& text, AnnotationUsecase annotation_usecase,
48              const Optional<LocationContext>& location_context,
49              const Permissions& permissions,
50              std::vector<AnnotatedSpan>* result) const {
51     return true;
52   }
53 
ChunkMultipleSpans(const std::vector<std::string> & text_fragments,AnnotationUsecase annotation_usecase,const Optional<LocationContext> & location_context,const Permissions & permissions,std::vector<std::vector<AnnotatedSpan>> * results)54   Status ChunkMultipleSpans(
55       const std::vector<std::string>& text_fragments,
56       AnnotationUsecase annotation_usecase,
57       const Optional<LocationContext>& location_context,
58       const Permissions& permissions,
59       std::vector<std::vector<AnnotatedSpan>>* results) const {
60     return Status::OK;
61   }
62 
LookUpEntity(const std::string & id,std::string * serialized_knowledge_result)63   bool LookUpEntity(const std::string& id,
64                     std::string* serialized_knowledge_result) const {
65     return false;
66   }
67 };
68 
69 }  // namespace libtextclassifier3
70 
71 #endif  // LIBTEXTCLASSIFIER_ANNOTATOR_KNOWLEDGE_KNOWLEDGE_ENGINE_DUMMY_H_
72