1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved. 2 3 Licensed under the Apache License, Version 2.0 (the "License"); 4 you may not use this file except in compliance with the License. 5 You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9 Unless required by applicable law or agreed to in writing, software 10 distributed under the License is distributed on an "AS IS" BASIS, 11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 See the License for the specific language governing permissions and 13 limitations under the License. 14 ==============================================================================*/ 15 #ifndef TENSORFLOW_LITE_SUPPORT_CUSTOM_OPS_KERNEL_SENTENCEPIECE_SENTENCEPIECE_CONSTANTS_H_ 16 #define TENSORFLOW_LITE_SUPPORT_CUSTOM_OPS_KERNEL_SENTENCEPIECE_SENTENCEPIECE_CONSTANTS_H_ 17 18 namespace tflite { 19 namespace ops { 20 namespace custom { 21 namespace sentencepiece { 22 23 // The constant is copied from 24 // https://github.com/google/sentencepiece/blob/master/src/unigram_model.cc 25 constexpr float kUnkPenalty = 10.0; 26 27 // These constants are copied from 28 // https://github.com/google/sentencepiece/blob/master/src/sentencepiece_processor.cc 29 // 30 // Replaces white space with U+2581 (LOWER ONE EIGHT BLOCK). 31 constexpr char kSpaceSymbol[] = "\xe2\x96\x81"; 32 33 // Encodes <unk> into U+2047 (DOUBLE QUESTION MARK), 34 // since this character can be useful both for user and 35 // developer. We can easily figure out that <unk> is emitted. 36 constexpr char kDefaultUnknownSymbol[] = " \xE2\x81\x87 "; 37 38 } // namespace sentencepiece 39 } // namespace custom 40 } // namespace ops 41 } // namespace tflite 42 43 #endif // TENSORFLOW_LITE_SUPPORT_CUSTOM_OPS_KERNEL_SENTENCEPIECE_SENTENCEPIECE_CONSTANTS_H_ 44