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 #include "annotator/grammar/test-utils.h" 18 19 #include "utils/tokenizer.h" 20 21 namespace libtextclassifier3 { 22 CreateGrammarAnnotator(const::flatbuffers::DetachedBuffer & serialized_model)23GrammarAnnotator GrammarAnnotatorTest::CreateGrammarAnnotator( 24 const ::flatbuffers::DetachedBuffer& serialized_model) { 25 return GrammarAnnotator( 26 unilib_.get(), 27 flatbuffers::GetRoot<GrammarModel>(serialized_model.data()), 28 entity_data_builder_.get()); 29 } 30 SetTestTokenizerOptions(GrammarModelT * model)31void SetTestTokenizerOptions(GrammarModelT* model) { 32 model->tokenizer_options.reset(new GrammarTokenizerOptionsT); 33 model->tokenizer_options->tokenization_type = TokenizationType_ICU; 34 model->tokenizer_options->icu_preserve_whitespace_tokens = false; 35 model->tokenizer_options->tokenize_on_script_change = true; 36 } 37 38 } // namespace libtextclassifier3 39