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 SetEnabledModes(ModeFlag enabled_modes)40 void SetEnabledModes(ModeFlag enabled_modes) {} 41 ClassifyText(const std::string & text,CodepointSpan selection_indices,AnnotationUsecase annotation_usecase,const Optional<LocationContext> & location_context,const Permissions & permissions,ClassificationResult * classification_result)42 Status ClassifyText(const std::string& text, CodepointSpan selection_indices, 43 AnnotationUsecase annotation_usecase, 44 const Optional<LocationContext>& location_context, 45 const Permissions& permissions, 46 ClassificationResult* classification_result) const { 47 return Status(StatusCode::UNIMPLEMENTED, "Not implemented."); 48 } 49 Chunk(const std::string & text,AnnotationUsecase annotation_usecase,const Optional<LocationContext> & location_context,const Permissions & permissions,const AnnotateMode annotate_mode,ModeFlag mode,Annotations * result)50 Status Chunk(const std::string& text, AnnotationUsecase annotation_usecase, 51 const Optional<LocationContext>& location_context, 52 const Permissions& permissions, const AnnotateMode annotate_mode, 53 ModeFlag mode, Annotations* result) const { 54 return Status::OK; 55 } 56 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,ModeFlag mode,Annotations * results)57 Status ChunkMultipleSpans( 58 const std::vector<std::string>& text_fragments, 59 const std::vector<FragmentMetadata>& fragment_metadata, 60 AnnotationUsecase annotation_usecase, 61 const Optional<LocationContext>& location_context, 62 const Permissions& permissions, const AnnotateMode annotate_mode, 63 ModeFlag mode, Annotations* results) const { 64 return Status::OK; 65 } 66 LookUpEntity(const std::string & id)67 StatusOr<std::string> LookUpEntity(const std::string& id) const { 68 return Status(StatusCode::UNIMPLEMENTED, "Not implemented."); 69 } 70 LookUpEntityProperty(const std::string & mid_str,const std::string & property)71 StatusOr<std::string> LookUpEntityProperty( 72 const std::string& mid_str, const std::string& property) const { 73 return Status(StatusCode::UNIMPLEMENTED, "Not implemented"); 74 } 75 }; 76 77 } // namespace libtextclassifier3 78 79 #endif // LIBTEXTCLASSIFIER_ANNOTATOR_KNOWLEDGE_KNOWLEDGE_ENGINE_DUMMY_H_ 80