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