-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathauto_segmenter_config.h
More file actions
42 lines (34 loc) · 1.42 KB
/
auto_segmenter_config.h
File metadata and controls
42 lines (34 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef IFT_CONFIG_AUTO_SEGMENTER_CONFIG_H_
#define IFT_CONFIG_AUTO_SEGMENTER_CONFIG_H_
#include <optional>
#include <string>
#include "absl/status/statusor.h"
#include "absl/strings/string_view.h"
#include "hb.h"
#include "ift/config/segmenter_config.pb.h"
namespace ift::config {
class AutoSegmenterConfig {
public:
// Analyzes the provided font face and generates an appropriate segmenter
// configuration.
//
// primary_script: an optional name of a script or language frequency data
// file (e.g., "Script_cyrillic", "Language_fr").
// Defaults to "Script_latin" if not provided.
//
// quality_level: ranges from 1-8, sets the segmenting time to segmentation
// quality tradeoff. Lower values have shorter segmenting
// times, high values have longer segmenting times but
// typically results in better segmentation quality.
static absl::StatusOr<SegmenterConfig> GenerateConfig(
hb_face_t* face, std::optional<std::string> primary_script = std::nullopt,
std::optional<int> quality_level = std::nullopt);
// Returns the base script for a given language.
// For example, "Language_fr" -> "Script_latin".
static absl::StatusOr<std::string> GetBaseScriptForLanguage(
absl::string_view language);
private:
AutoSegmenterConfig() = delete;
};
} // namespace ift::config
#endif // IFT_CONFIG_AUTO_SEGMENTER_CONFIG_H_