• 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 // Utility functions for working with FlatBuffers in the annotator model.
18 
19 #ifndef LIBTEXTCLASSIFIER_ANNOTATOR_FLATBUFFER_UTILS_H_
20 #define LIBTEXTCLASSIFIER_ANNOTATOR_FLATBUFFER_UTILS_H_
21 
22 #include <string>
23 
24 #include "annotator/model_generated.h"
25 #include "annotator/types.h"
26 
27 namespace libtextclassifier3 {
28 
29 // Resolves field lookups by name to the concrete field offsets in the regex
30 // rules of the model.
31 bool SwapFieldNamesForOffsetsInPath(ModelT* model);
32 
33 // Same as above but for a serialized model.
34 std::string SwapFieldNamesForOffsetsInPathInSerializedModel(
35     const std::string& model);
36 
37 std::string CreateDatetimeSerializedEntityData(
38     const DatetimeParseResult& parse_result);
39 
40 }  // namespace libtextclassifier3
41 
42 #endif  // LIBTEXTCLASSIFIER_ANNOTATOR_FLATBUFFER_UTILS_H_
43