react-native-executorch 0.10.6 → 0.10.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/module/fetcher/telemetry.js +1 -1
- package/package.json +1 -1
- package/react-native-executorch.podspec +2 -0
- package/src/fetcher/telemetry.ts +1 -1
- package/third-party/common/phonemis/CMakeLists.txt +70 -14
- package/third-party/common/phonemis/README.md +183 -33
- package/third-party/common/phonemis/THIRD_PARTY_NOTICES.md +57 -0
- package/third-party/common/phonemis/knowledge/code_style.md +642 -0
- package/third-party/common/phonemis/licenses/Unicode-3.0.txt +39 -0
- package/third-party/common/phonemis/licenses/misaki-Apache-2.0.txt +201 -0
- package/third-party/common/phonemis/licenses/nlohmann-json-MIT.txt +21 -0
- package/third-party/common/phonemis/licenses/xsimd-BSD-3-Clause.txt +29 -0
- package/third-party/common/phonemis/src/phonemis/base/config.h +6 -0
- package/third-party/common/phonemis/src/phonemis/base/ipipeline.cpp +75 -0
- package/third-party/common/phonemis/src/phonemis/base/ipipeline.h +21 -0
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/constants.h +2 -5
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/lexicon_phonemizer.cpp +3 -4
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.cpp +17 -8
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.h +4 -0
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.cpp +21 -6
- package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.h +13 -4
- package/third-party/common/phonemis/src/phonemis/base/pipeline.cpp +8 -0
- package/third-party/common/phonemis/src/phonemis/base/pipeline.h +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.cpp +37 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.h +45 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/constants.h +10 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/context.cpp +105 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/context.h +49 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/document.cpp +173 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/document.h +67 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/text.cpp +75 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/text.h +60 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/common/types.h +18 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/config.h +53 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layer.h +9 -7
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/constants.h +20 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.cpp +89 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.h +35 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/types.h +16 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/kind.h +40 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/layer.h +382 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/notation.h +30 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.cpp +51 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.h +31 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern.h +30 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.cpp +17 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.h +31 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.cpp +811 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.h +285 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.cpp +64 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.h +23 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/types.h +94 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sanitizer/layer.cpp +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/{sanitizer_layer.h → layers/sanitizer/layer.h} +8 -8
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.cpp +65 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.h +29 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.cpp +170 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.h +40 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/types.h +25 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.cpp +47 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.h +19 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.cpp +60 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.h +45 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/processor.cpp +6 -7
- package/third-party/common/phonemis/src/phonemis/base/processor/processor.h +14 -10
- package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.cpp +89 -52
- package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.h +16 -9
- package/third-party/common/phonemis/src/phonemis/base/tokenizer/tokenizer.cpp +13 -12
- package/third-party/common/phonemis/src/phonemis/lang/de/constants.h +183 -19
- package/third-party/common/phonemis/src/phonemis/lang/de/num2word.cpp +355 -309
- package/third-party/common/phonemis/src/phonemis/lang/de/num2word.h +42 -17
- package/third-party/common/phonemis/src/phonemis/lang/de/patterns.cpp +56 -0
- package/third-party/common/phonemis/src/phonemis/lang/de/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/de/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/en/constants.h +181 -30
- package/third-party/common/phonemis/src/phonemis/lang/en/hmm_tagger.cpp +5 -7
- package/third-party/common/phonemis/src/phonemis/lang/en/num2word.cpp +232 -135
- package/third-party/common/phonemis/src/phonemis/lang/en/num2word.h +41 -16
- package/third-party/common/phonemis/src/phonemis/lang/en/pipeline.h +3 -10
- package/third-party/common/phonemis/src/phonemis/lang/es/constants.h +182 -60
- package/third-party/common/phonemis/src/phonemis/lang/es/num2word.cpp +247 -212
- package/third-party/common/phonemis/src/phonemis/lang/es/num2word.h +38 -18
- package/third-party/common/phonemis/src/phonemis/lang/es/patterns.cpp +50 -0
- package/third-party/common/phonemis/src/phonemis/lang/es/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/es/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/fr/constants.h +152 -26
- package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.cpp +252 -179
- package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.h +38 -15
- package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.cpp +83 -0
- package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/fr/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/hi/constants.h +62 -10
- package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.cpp +74 -123
- package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.h +27 -16
- package/third-party/common/phonemis/src/phonemis/lang/hi/pipeline.h +5 -3
- package/third-party/common/phonemis/src/phonemis/lang/it/constants.h +122 -42
- package/third-party/common/phonemis/src/phonemis/lang/it/num2word.cpp +200 -207
- package/third-party/common/phonemis/src/phonemis/lang/it/num2word.h +30 -18
- package/third-party/common/phonemis/src/phonemis/lang/it/patterns.cpp +25 -0
- package/third-party/common/phonemis/src/phonemis/lang/it/patterns.h +15 -0
- package/third-party/common/phonemis/src/phonemis/lang/it/pipeline.h +3 -3
- package/third-party/common/phonemis/src/phonemis/lang/pl/constants.h +346 -77
- package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.cpp +631 -246
- package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.h +47 -15
- package/third-party/common/phonemis/src/phonemis/lang/pl/pipeline.h +6 -6
- package/third-party/common/phonemis/src/phonemis/lang/pt/constants.h +201 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.cpp +365 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.h +53 -0
- package/third-party/common/phonemis/src/phonemis/lang/pt/pipeline.h +4 -2
- package/third-party/common/phonemis/src/phonemis/main.cpp +42 -11
- package/third-party/common/phonemis/src/phonemis/protophone/meta.h +24 -0
- package/third-party/common/phonemis/src/phonemis/protophone/numeric.h +26 -0
- package/third-party/common/phonemis/src/phonemis/protophone/protophone.cpp +525 -0
- package/third-party/common/phonemis/src/phonemis/protophone/protophone.h +80 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor.h +76 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor_utils.h +89 -0
- package/third-party/common/phonemis/src/phonemis/protophone/tensor_view.h +125 -0
- package/third-party/common/phonemis/src/phonemis/protophone/types.h +43 -0
- package/third-party/common/phonemis/src/phonemis/utils/strings.h +20 -14
- package/third-party/common/phonemis/src/phonemis/utils/unicode.h +15 -1
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_bit.hpp +232 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_details.hpp +386 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/utils/shifts.hpp +82 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx.hpp +2111 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2.hpp +1591 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2_128.hpp +170 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512bw.hpp +724 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512cd.hpp +28 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512dq.hpp +270 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512er.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512f.hpp +2919 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512pf.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx_128.hpp +164 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avxvnni.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common.hpp +26 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common_fwd.hpp +127 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_constants.hpp +393 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_emulated.hpp +787 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma4.hpp +92 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_isa.hpp +148 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon.hpp +3580 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon64.hpp +1614 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_rvv.hpp +1515 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_scalar.hpp +1210 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse2.hpp +2333 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse3.hpp +66 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_1.hpp +510 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_2.hpp +44 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_ssse3.hpp +186 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sve.hpp +1186 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vsx.hpp +947 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vxe.hpp +787 -0
- package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_wasm.hpp +1819 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_arch.hpp +242 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_config.hpp +633 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_x86.hpp +1121 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpuid.hpp +144 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_getauxval.hpp +159 -0
- package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_macros.hpp +78 -0
- package/third-party/common/phonemis/src/third-party/xsimd/math/xsimd_rem_pio2.hpp +707 -0
- package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
- package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_alignment.hpp +102 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_all_registers.hpp +57 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_api.hpp +3106 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx2_register.hpp +57 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512er_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512f_register.hpp +77 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx_register.hpp +79 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch.hpp +1666 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_constant.hpp +572 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_fwd.hpp +41 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_common_arch.hpp +49 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_emulated_register.hpp +80 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma4_register.hpp +50 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon64_register.hpp +55 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon_register.hpp +130 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_register.hpp +96 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_rvv_register.hpp +491 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse2_register.hpp +59 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse3_register.hpp +49 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_ssse3_register.hpp +48 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sve_register.hpp +216 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_traits.hpp +409 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_utils.hpp +462 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vsx_register.hpp +84 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vxe_register.hpp +86 -0
- package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_wasm_register.hpp +59 -0
- package/third-party/common/phonemis/src/third-party/xsimd/utils/bits.hpp +122 -0
- package/third-party/common/phonemis/src/third-party/xsimd/utils/xsimd_type_traits.hpp +145 -0
- package/third-party/common/phonemis/src/third-party/xsimd/xsimd.hpp +43 -0
- package/third-party/common/phonemis/src/phonemis/base/processor/constants.h +0 -11
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/config.h +0 -16
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.cpp +0 -271
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.h +0 -45
- package/third-party/common/phonemis/src/phonemis/base/processor/num2word/types.h +0 -29
- package/third-party/common/phonemis/src/phonemis/base/processor/sanitizer_layer.cpp +0 -22
- package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.cpp +0 -40
- package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.h +0 -22
|
@@ -1,194 +1,291 @@
|
|
|
1
|
-
#include "num2word.h"
|
|
2
1
|
#include "constants.h"
|
|
3
|
-
#include
|
|
4
|
-
#include <phonemis/
|
|
2
|
+
#include "num2word.h"
|
|
3
|
+
#include <phonemis/base/processor/layers/num2word/numerals.h>
|
|
4
|
+
#include <phonemis/base/processor/layers/num2word/patterns.h>
|
|
5
5
|
#include <phonemis/utils/strings.h>
|
|
6
|
-
#include <
|
|
7
|
-
#include <cmath>
|
|
8
|
-
#include <sstream>
|
|
9
|
-
#include <vector>
|
|
10
|
-
#include <iterator>
|
|
6
|
+
#include <phonemis/utils/unicode.h>
|
|
11
7
|
|
|
12
8
|
namespace phonemis::en {
|
|
13
9
|
|
|
14
|
-
using namespace constants;
|
|
15
|
-
using namespace
|
|
10
|
+
using namespace constants::num2word;
|
|
11
|
+
using namespace processor;
|
|
12
|
+
using namespace processor::num2word;
|
|
16
13
|
using namespace utils;
|
|
17
14
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return U"minus " + to_cardinal_int(std::abs(value));
|
|
21
|
-
}
|
|
15
|
+
namespace {
|
|
16
|
+
// Number words
|
|
22
17
|
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
std::u32string cardinal(uint64_t n) {
|
|
19
|
+
if (n < 20) {
|
|
20
|
+
return std::u32string(kOnes[n]);
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return
|
|
22
|
+
if (n < 100) {
|
|
23
|
+
return std::u32string(kTens[n / 10]) + (n % 10 ? U"-" + std::u32string(kOnes[n % 10]) : U"");
|
|
24
|
+
}
|
|
25
|
+
if (n < 1000) {
|
|
26
|
+
return std::u32string(kOnes[n / 100]) + U" hundred" + (n % 100 ? U" " + cardinal(n % 100) : U"");
|
|
27
|
+
}
|
|
28
|
+
for (const auto& [value, word] : kScaleWords) {
|
|
29
|
+
if (n >= value) {
|
|
30
|
+
return cardinal(n / value) + U" " + word + (n % value ? U" " + cardinal(n % value) : U"");
|
|
31
|
+
}
|
|
31
32
|
}
|
|
33
|
+
return U"";
|
|
34
|
+
}
|
|
32
35
|
|
|
33
|
-
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
int32_t low = value % static_cast<int32_t>(base);
|
|
36
|
+
std::u32string ordinal(uint64_t n) {
|
|
37
|
+
// Only the last word changes: twenty-first, one hundred and twelfth
|
|
38
|
+
std::u32string words = cardinal(n);
|
|
39
|
+
size_t start = words.find_last_of(U" -") + 1;
|
|
40
|
+
std::u32string last = words.substr(start);
|
|
41
|
+
words.erase(start);
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
43
|
+
if (auto it = kIrregularOrdinals.find(last); it != kIrregularOrdinals.end()) {
|
|
44
|
+
return words + it->second;
|
|
45
|
+
}
|
|
46
|
+
return words + (last.ends_with(U'y') ? last.substr(0, last.size() - 1) + U"ieth" : last + U"th");
|
|
47
|
+
}
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
// Year-style reading, also of 3-4 digit codes: nineteen oh five, two thousand seven, nine fifty-six
|
|
50
|
+
std::u32string pairs(uint64_t n) {
|
|
51
|
+
uint64_t high = n / 100, low = n % 100;
|
|
52
|
+
if (n >= 1000 && n % 1000 < 10) {
|
|
53
|
+
return cardinal(n);
|
|
54
|
+
}
|
|
55
|
+
if (low == 0) {
|
|
56
|
+
return cardinal(high) + U" hundred";
|
|
50
57
|
}
|
|
58
|
+
return cardinal(high) + U" " + (low < 10 ? U"oh " + std::u32string(kOnes[low]) : cardinal(low));
|
|
59
|
+
}
|
|
51
60
|
|
|
52
|
-
|
|
53
|
-
|
|
61
|
+
std::u32string digits(std::u32string_view text) {
|
|
62
|
+
std::vector<std::u32string> words;
|
|
63
|
+
for (char32_t c : text) {
|
|
64
|
+
words.emplace_back(kOnes[c - U'0']);
|
|
65
|
+
}
|
|
66
|
+
return join(words);
|
|
54
67
|
}
|
|
55
68
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
69
|
+
// a.m. and p.m. as their lowercase abbreviations are said; AM and PM stay as written
|
|
70
|
+
std::u32string ampm(std::u32string_view suffix) {
|
|
71
|
+
std::u32string base = strings::to_lower(suffix.substr(0, suffix.find_last_not_of(U'.') + 1));
|
|
72
|
+
bool lowercase = std::ranges::none_of(suffix, [](char32_t c) { return unicode::isupper(c); });
|
|
73
|
+
if (lowercase && (base == U"am" || base == U"pm")) {
|
|
74
|
+
return base == U"am" ? U"a.m." : U"p.m.";
|
|
75
|
+
}
|
|
76
|
+
return std::u32string(suffix);
|
|
77
|
+
}
|
|
60
78
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
[](char c) -> bool { return c != '0'; });
|
|
66
|
-
std::string value_str = std::string(tmp_str.begin(), rit.base());
|
|
79
|
+
uint64_t value(const Number& number) {
|
|
80
|
+
return value_of(number.integer).value_or(0);
|
|
81
|
+
}
|
|
82
|
+
} // namespace
|
|
67
83
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
84
|
+
Num2Word::Num2Word() : Num2WordLayer(kNotation, kJoiners) {
|
|
85
|
+
add_pattern(std::make_unique<DatePattern>(kDateFormat));
|
|
86
|
+
for (const auto& format : kPhoneFormats) {
|
|
87
|
+
add_pattern(std::make_unique<PhonePattern>(format));
|
|
88
|
+
}
|
|
89
|
+
add_pattern(std::make_unique<SuffixPattern>(Kind::ORDINAL, kOrdinalSuffixes));
|
|
90
|
+
add_pattern(std::make_unique<SuffixPattern>(Kind::DECADE, kDecadeSuffixes, kDecadeFormat));
|
|
91
|
+
}
|
|
72
92
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
93
|
+
// -----------------------
|
|
94
|
+
// ----- Resolution -----
|
|
95
|
+
// -----------------------
|
|
96
|
+
|
|
97
|
+
bool Num2Word::accept(const Match& match, const Context& context) const {
|
|
98
|
+
switch (match.kind) {
|
|
99
|
+
case Kind::FRACTION:
|
|
100
|
+
return kFractions.contains({value(match.numbers[0]), value(match.numbers[1])});
|
|
101
|
+
case Kind::SCALE:
|
|
102
|
+
return match.scale != U"K"; // 4K: a resolution
|
|
103
|
+
case Kind::TIME: {
|
|
104
|
+
uint64_t hours = value(match.numbers[0]);
|
|
105
|
+
// 7pm: an hour alone needs am or pm
|
|
106
|
+
if (match.numbers.size() == 1) {
|
|
107
|
+
return hours <= 12 && strings::contains(std::u32string_view(U"apAP"), match.suffix[0]);
|
|
108
|
+
}
|
|
109
|
+
// 1.13 is a decimal, unless a time is expected: at 10.30
|
|
110
|
+
bool decimal = match.separator == U'.' && match.suffix.empty() && !kTimeWords.contains(context.before());
|
|
111
|
+
return hours <= 24 && value(match.numbers[1]) <= 59 && !decimal;
|
|
76
112
|
}
|
|
113
|
+
default:
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
77
117
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
int32_t integer_part = integer_part_str.empty() ? 0 : std::stoi(integer_part_str);
|
|
83
|
-
std::u32string res = to_cardinal_int(integer_part) + U" point";
|
|
118
|
+
NumberReading Num2Word::resolve(const Match& match, const Context& context) const {
|
|
119
|
+
std::u32string previous = context.before();
|
|
120
|
+
std::u32string next = context.after();
|
|
121
|
+
std::u32string next_lower = strings::to_lower(next);
|
|
84
122
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
123
|
+
// 1999 people: a plural noun after a 4-digit number makes it a count, unless a year is expected (in 1999)
|
|
124
|
+
bool plural_noun =
|
|
125
|
+
kIrregularPlurals.contains(next_lower) || (next_lower.size() > 3 && next_lower.ends_with(U's') &&
|
|
126
|
+
!next_lower.ends_with(U"ss") && !kStopWords.contains(next_lower));
|
|
127
|
+
bool year_cue = kYearCues.contains(previous) || kMonths.contains(previous);
|
|
91
128
|
|
|
92
|
-
|
|
129
|
+
return {.after_month = kMonths.contains(previous),
|
|
130
|
+
.counted = plural_noun && !year_cue,
|
|
131
|
+
.attributive = !next.empty() && unicode::isalpha(next[0]) && !kStopWords.contains(next_lower)};
|
|
93
132
|
}
|
|
94
133
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
return num2word::kOrdinals.contains(word) ? num2word::kOrdinals.at(word) :
|
|
99
|
-
word.empty() ? U"th" :
|
|
100
|
-
word.back() == U'y' ? word.substr(0, word.length() - 1) + U"ieth" :
|
|
101
|
-
word + U"th";
|
|
102
|
-
};
|
|
134
|
+
// --------------------
|
|
135
|
+
// ----- Readings -----
|
|
136
|
+
// --------------------
|
|
103
137
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
138
|
+
std::u32string Num2Word::read_integer(const Number& number, const NumberReading& reading) const {
|
|
139
|
+
auto n = value_of(number.integer);
|
|
140
|
+
if (!n || spoken_digits(number, 5)) {
|
|
141
|
+
return digits(number.integer);
|
|
142
|
+
}
|
|
143
|
+
if (reading.after_month && *n >= 1 && *n <= 31) {
|
|
144
|
+
return ordinal(*n);
|
|
109
145
|
}
|
|
146
|
+
if (number.integer.size() == 4 && !number.grouped) {
|
|
147
|
+
return reading.counted ? cardinal(*n) : pairs(*n);
|
|
148
|
+
}
|
|
149
|
+
return cardinal(*n);
|
|
150
|
+
}
|
|
110
151
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
std::vector<std::u32string> parts = strings::split(last, U'-');
|
|
115
|
-
if (!parts.empty()) {
|
|
116
|
-
parts.back() = get_ordinal_suffix_word(parts.back());
|
|
117
|
-
last = parts.size() > 1 ? parts[0] + U"-" + parts[1] : parts[0];
|
|
118
|
-
}
|
|
119
|
-
} else {
|
|
120
|
-
last = get_ordinal_suffix_word(last);
|
|
152
|
+
std::u32string Num2Word::read_number(const Number& number, const NumberReading& reading) const {
|
|
153
|
+
if (number.fraction.empty()) {
|
|
154
|
+
return read_integer(number, reading);
|
|
121
155
|
}
|
|
122
156
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
157
|
+
// .5 has no zero before its point
|
|
158
|
+
std::u32string head = number.integer.empty() ? U"" : cardinal(value(number)) + U" ";
|
|
159
|
+
return head + (number.fraction == U"0" ? U"point oh" : U"point " + digits(number.fraction));
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
std::u32string Num2Word::read_code_digits(std::u32string_view text) const {
|
|
163
|
+
auto n = value_of(text);
|
|
164
|
+
if (text.size() > 1 && text[0] == U'0') {
|
|
165
|
+
std::vector<std::u32string> words;
|
|
166
|
+
for (char32_t c : text) {
|
|
167
|
+
words.emplace_back(c == U'0' ? U"oh" : kOnes[c - U'0']);
|
|
168
|
+
}
|
|
169
|
+
return join(words);
|
|
170
|
+
}
|
|
171
|
+
if (!n || text.size() > 4) {
|
|
172
|
+
return digits(text);
|
|
126
173
|
}
|
|
127
|
-
return
|
|
174
|
+
return text.size() <= 2 ? cardinal(*n) : pairs(*n);
|
|
128
175
|
}
|
|
129
176
|
|
|
130
|
-
std::u32string Num2Word::
|
|
131
|
-
|
|
132
|
-
|
|
177
|
+
std::u32string Num2Word::read_date(const Match& match, const NumberReading& reading) const {
|
|
178
|
+
std::u32string words = ordinal(value(match.numbers[0])) + U" " + kMonthNames[value(match.numbers[1]) - 1];
|
|
179
|
+
if (match.numbers.size() < 3) {
|
|
180
|
+
return words;
|
|
133
181
|
}
|
|
182
|
+
const Number& year = match.numbers[2];
|
|
183
|
+
return words + U" " + (year.integer.size() == 4 ? pairs(value(year)) : cardinal(value(year)));
|
|
184
|
+
}
|
|
134
185
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
return std::abs(arg - 1.0F) < 1e-6F;
|
|
145
|
-
}
|
|
146
|
-
}, number);
|
|
186
|
+
std::u32string Num2Word::read_phone(const Match& match, const NumberReading& reading) const {
|
|
187
|
+
// 1-555-...: the leading one joins the area code
|
|
188
|
+
std::vector<std::u32string> groups;
|
|
189
|
+
for (const auto& number : match.numbers) {
|
|
190
|
+
groups.push_back(number.integer);
|
|
191
|
+
}
|
|
192
|
+
if (match.text.starts_with(U"1-")) {
|
|
193
|
+
groups[0] = U"1" + groups[0];
|
|
194
|
+
}
|
|
147
195
|
|
|
148
|
-
|
|
149
|
-
|
|
196
|
+
std::vector<std::u32string> words;
|
|
197
|
+
for (const auto& group : groups) {
|
|
198
|
+
words.push_back(digits(group));
|
|
150
199
|
}
|
|
200
|
+
return join(words, U", ");
|
|
201
|
+
}
|
|
151
202
|
|
|
152
|
-
|
|
203
|
+
std::u32string Num2Word::read_fraction(const Match& match, const NumberReading& reading) const {
|
|
204
|
+
return kFractions.at({value(match.numbers[0]), value(match.numbers[1])});
|
|
153
205
|
}
|
|
154
206
|
|
|
155
|
-
std::u32string Num2Word::
|
|
156
|
-
|
|
157
|
-
|
|
207
|
+
std::u32string Num2Word::read_time(const Match& match, const NumberReading& reading) const {
|
|
208
|
+
std::u32string hours = cardinal(value(match.numbers[0]));
|
|
209
|
+
std::u32string suffix = ampm(match.suffix);
|
|
210
|
+
if (match.numbers.size() == 1) {
|
|
211
|
+
return hours + U" " + suffix;
|
|
158
212
|
}
|
|
159
213
|
|
|
160
|
-
|
|
214
|
+
// ten thirty, ten oh five, ten o'clock
|
|
215
|
+
const auto& minutes = match.numbers[1].integer;
|
|
216
|
+
std::u32string words = hours;
|
|
217
|
+
if (minutes != U"00") {
|
|
218
|
+
uint64_t m = value(match.numbers[1]);
|
|
219
|
+
words += minutes[0] == U'0' ? U" oh " + std::u32string(kOnes[m]) : U" " + cardinal(m);
|
|
220
|
+
}
|
|
221
|
+
if (!suffix.empty()) {
|
|
222
|
+
return words + U" " + suffix;
|
|
223
|
+
}
|
|
224
|
+
return words + (minutes == U"00" ? U" o'clock" : U"");
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
std::u32string Num2Word::read_ordinal(const Match& match, const NumberReading& reading) const {
|
|
228
|
+
return ordinal(value(match.numbers[0]));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
std::u32string Num2Word::read_decade(const Match& match, const NumberReading& reading) const {
|
|
232
|
+
return *plural(read_number(match.numbers[0], reading));
|
|
161
233
|
}
|
|
162
234
|
|
|
163
|
-
std::u32string Num2Word::
|
|
164
|
-
|
|
165
|
-
if (value == 0) return to_cardinal_int(0);
|
|
235
|
+
std::u32string Num2Word::read_money(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
236
|
+
const Forms& currency = kCurrencies.at(std::u32string(match.unit));
|
|
166
237
|
|
|
167
|
-
|
|
168
|
-
|
|
238
|
+
// A price: four ninety-nine, ninety-nine cents
|
|
239
|
+
if (number.fraction.size() == 2 && match.scale.empty()) {
|
|
240
|
+
uint64_t cents_value = value_of(number.fraction).value_or(0);
|
|
241
|
+
if (value(number) == 0) {
|
|
242
|
+
return cardinal(cents_value) + U" cents";
|
|
243
|
+
}
|
|
244
|
+
std::u32string cents =
|
|
245
|
+
number.fraction[0] == U'0' ? U"oh " + std::u32string(kOnes[cents_value]) : cardinal(cents_value);
|
|
246
|
+
Number whole{.integer = number.integer, .grouped = number.grouped};
|
|
247
|
+
return read_integer(whole, reading) + U" " + cents;
|
|
248
|
+
}
|
|
169
249
|
|
|
170
|
-
|
|
171
|
-
|
|
250
|
+
std::u32string words = read_number(number, reading);
|
|
251
|
+
if (!match.scale.empty()) {
|
|
252
|
+
words += U" " + kScales.at(std::u32string(match.scale));
|
|
172
253
|
}
|
|
254
|
+
bool one = number.integer == U"1" && number.fraction.empty() && match.scale.empty();
|
|
255
|
+
return words + U" " + (one || reading.attributive ? currency.one : currency.many);
|
|
256
|
+
}
|
|
173
257
|
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
to_cardinal_int(low);
|
|
258
|
+
std::u32string Num2Word::read_scale(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
259
|
+
return read_number(number, reading) + U" " + kScales.at(std::u32string(match.scale));
|
|
260
|
+
}
|
|
178
261
|
|
|
179
|
-
|
|
262
|
+
std::u32string Num2Word::read_percent(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
263
|
+
return read_number(number, reading) + U" percent" +
|
|
264
|
+
(match.suffix.empty() ? U"" : U" " + std::u32string(match.suffix));
|
|
180
265
|
}
|
|
181
266
|
|
|
182
|
-
|
|
183
|
-
|
|
267
|
+
std::u32string Num2Word::read_unit(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
268
|
+
const Forms& unit = kUnits.at(std::u32string(match.unit));
|
|
269
|
+
bool one = number.fraction.empty() && value(number) == 1;
|
|
270
|
+
return read_number(number, reading) + U" " + (one || reading.attributive ? unit.one : unit.many);
|
|
184
271
|
}
|
|
185
272
|
|
|
186
|
-
std::u32string Num2Word::
|
|
187
|
-
|
|
273
|
+
std::u32string Num2Word::read_range(const Number& from, const Number& to, const NumberReading& reading) const {
|
|
274
|
+
if (!from.fraction.empty() || !to.fraction.empty()) {
|
|
275
|
+
return joiners_.range;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 10-15 is "ten to fifteen"; but scores and abbreviated seasons keep "-": 51-44, 2016-17, 21-22
|
|
279
|
+
uint64_t a = value(from), b = value(to);
|
|
280
|
+
bool season = from.integer.size() == 2 && b == a + 1;
|
|
281
|
+
return from.integer.size() == to.integer.size() && b > a && !season ? joiners_.range : U"-";
|
|
188
282
|
}
|
|
189
283
|
|
|
190
|
-
std::u32string Num2Word::
|
|
191
|
-
|
|
284
|
+
std::optional<std::u32string> Num2Word::plural(std::u32string_view words) const {
|
|
285
|
+
if (words.ends_with(U'y')) {
|
|
286
|
+
return std::u32string(words.substr(0, words.size() - 1)) + U"ies";
|
|
287
|
+
}
|
|
288
|
+
return std::u32string(words) + (words.ends_with(U'x') ? U"es" : U"s");
|
|
192
289
|
}
|
|
193
290
|
|
|
194
291
|
} // namespace phonemis::en
|
|
@@ -1,26 +1,51 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <phonemis/base/processor/num2word/layer.h>
|
|
3
|
+
#include <phonemis/base/processor/layers/num2word/layer.h>
|
|
4
|
+
|
|
5
|
+
#include <optional>
|
|
4
6
|
#include <string>
|
|
5
|
-
#include <vector>
|
|
6
|
-
#include <map>
|
|
7
7
|
|
|
8
8
|
namespace phonemis::en {
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
// How an English number is read, from the words around it.
|
|
11
|
+
struct NumberReading {
|
|
12
|
+
bool after_month = false; // March 3: a day of the month, read as an ordinal
|
|
13
|
+
bool counted = false; // 1999 people: a count rather than a year
|
|
14
|
+
bool attributive = false; // a $5 bill: before a noun, the unit stays singular
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class Num2Word : public processor::num2word::Num2WordLayer<NumberReading> {
|
|
11
18
|
public:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
Num2Word();
|
|
20
|
+
|
|
21
|
+
protected:
|
|
22
|
+
using Context = processor::Context;
|
|
23
|
+
using Match = processor::num2word::Match;
|
|
24
|
+
using Number = processor::num2word::Number;
|
|
25
|
+
|
|
26
|
+
// Resolution
|
|
27
|
+
bool accept(const Match& match, const Context& context) const override;
|
|
28
|
+
NumberReading resolve(const Match& match, const Context& context) const override;
|
|
29
|
+
|
|
30
|
+
// Readings
|
|
31
|
+
std::u32string read_number(const Number& number, const NumberReading& reading) const override;
|
|
32
|
+
std::u32string read_code_digits(std::u32string_view digits) const override;
|
|
33
|
+
std::u32string read_date(const Match& match, const NumberReading& reading) const override;
|
|
34
|
+
std::u32string read_phone(const Match& match, const NumberReading& reading) const override;
|
|
35
|
+
std::u32string read_fraction(const Match& match, const NumberReading& reading) const override;
|
|
36
|
+
std::u32string read_time(const Match& match, const NumberReading& reading) const override;
|
|
37
|
+
std::u32string read_ordinal(const Match& match, const NumberReading& reading) const override;
|
|
38
|
+
std::u32string read_decade(const Match& match, const NumberReading& reading) const override;
|
|
39
|
+
std::u32string read_money(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
40
|
+
std::u32string read_scale(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
41
|
+
std::u32string read_percent(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
42
|
+
std::u32string read_unit(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
43
|
+
std::u32string read_range(const Number& from, const Number& to, const NumberReading& reading) const override;
|
|
44
|
+
std::optional<std::u32string> plural(std::u32string_view words) const override;
|
|
45
|
+
|
|
46
|
+
private:
|
|
47
|
+
// An integer as a year, a day of a month or a count, digit by digit if it is a code
|
|
48
|
+
std::u32string read_integer(const Number& number, const NumberReading& reading) const;
|
|
24
49
|
};
|
|
25
50
|
|
|
26
51
|
} // namespace phonemis::en
|
|
@@ -8,9 +8,8 @@
|
|
|
8
8
|
#include <phonemis/base/config.h>
|
|
9
9
|
#include <phonemis/base/ipipeline.h>
|
|
10
10
|
#include <phonemis/base/phonemizer/hybrid_phonemizer.h>
|
|
11
|
+
#include <phonemis/base/processor/preprocessor.h>
|
|
11
12
|
#include <phonemis/base/processor/processor.h>
|
|
12
|
-
#include <phonemis/base/processor/sanitizer_layer.h>
|
|
13
|
-
#include <phonemis/base/processor/trim_layer.h>
|
|
14
13
|
#include <phonemis/base/tagger/hmm_tagger.h>
|
|
15
14
|
#include <phonemis/base/tokenizer/tokenizer.h>
|
|
16
15
|
#include <phonemis/utils/conversions.h>
|
|
@@ -27,14 +26,8 @@ public:
|
|
|
27
26
|
phonemizer_(config.phonemizer) {
|
|
28
27
|
|
|
29
28
|
// 1. Setup Preprocessing layers
|
|
30
|
-
preprocessor_
|
|
31
|
-
|
|
32
|
-
preprocessor_.add_layer(std::make_unique<processor::SanitizerLayer>(
|
|
33
|
-
[](char32_t) { return true; },
|
|
34
|
-
[](char32_t c) {
|
|
35
|
-
auto it = constants::kSanitizerReplacements.find(c);
|
|
36
|
-
return it != constants::kSanitizerReplacements.end() ? it->second : c;
|
|
37
|
-
}));
|
|
29
|
+
preprocessor_ = processor::make_preprocessor<Num2Word>(
|
|
30
|
+
config.preprocessor, {.terms = &constants::term2word::kTerms, .symbols = &constants::sym2word::kSymbols});
|
|
38
31
|
|
|
39
32
|
// 2. Setup PoS tagger if specified
|
|
40
33
|
if (config.tagger.has_value()) {
|