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
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#include "patterns.h"
|
|
2
|
+
#include <phonemis/base/processor/layers/num2word/primitives.h>
|
|
3
|
+
#include <phonemis/utils/conversions.h>
|
|
4
|
+
|
|
5
|
+
#include <array>
|
|
6
|
+
#include <optional>
|
|
7
|
+
#include <string>
|
|
8
|
+
|
|
9
|
+
namespace phonemis::fr {
|
|
10
|
+
|
|
11
|
+
using namespace processor;
|
|
12
|
+
using namespace processor::num2word;
|
|
13
|
+
|
|
14
|
+
namespace {
|
|
15
|
+
int roman_digit(char32_t c) {
|
|
16
|
+
switch (c) {
|
|
17
|
+
case U'I':
|
|
18
|
+
return 1;
|
|
19
|
+
case U'V':
|
|
20
|
+
return 5;
|
|
21
|
+
case U'X':
|
|
22
|
+
return 10;
|
|
23
|
+
case U'L':
|
|
24
|
+
return 50;
|
|
25
|
+
case U'C':
|
|
26
|
+
return 100;
|
|
27
|
+
default:
|
|
28
|
+
return 0;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// The value of a Roman numeral written in its canonical form (XIX, not XVIIII).
|
|
33
|
+
std::optional<int> roman_value(std::u32string_view numeral) {
|
|
34
|
+
int value = 0;
|
|
35
|
+
for (size_t i = 0; i < numeral.size(); ++i) {
|
|
36
|
+
int digit = roman_digit(numeral[i]);
|
|
37
|
+
value += i + 1 < numeral.size() && digit < roman_digit(numeral[i + 1]) ? -digit : digit;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
static constexpr std::array<std::pair<int, std::u32string_view>, 9> kSymbols = {
|
|
41
|
+
{{100, U"C"}, {90, U"XC"}, {50, U"L"}, {40, U"XL"}, {10, U"X"}, {9, U"IX"}, {5, U"V"}, {4, U"IV"}, {1, U"I"}}};
|
|
42
|
+
std::u32string canonical;
|
|
43
|
+
for (int rest = value; const auto& [symbol_value, symbol] : kSymbols) {
|
|
44
|
+
for (; rest >= symbol_value; rest -= symbol_value) {
|
|
45
|
+
canonical += symbol;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return canonical == numeral ? std::optional(value) : std::nullopt;
|
|
49
|
+
}
|
|
50
|
+
} // namespace
|
|
51
|
+
|
|
52
|
+
std::optional<Match> RomanOrdinalPattern::match(std::u32string_view text, size_t position) const {
|
|
53
|
+
if (!is_clear_before(text, position)) {
|
|
54
|
+
return std::nullopt;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Two Roman digits or more, or a single I (Ier)
|
|
58
|
+
size_t end = position;
|
|
59
|
+
while (end < text.size() && roman_digit(text[end])) {
|
|
60
|
+
end++;
|
|
61
|
+
}
|
|
62
|
+
std::u32string_view numeral = text.substr(position, end - position);
|
|
63
|
+
if (numeral.size() < 2 && numeral != U"I") {
|
|
64
|
+
return std::nullopt;
|
|
65
|
+
}
|
|
66
|
+
auto value = roman_value(numeral);
|
|
67
|
+
if (!value) {
|
|
68
|
+
return std::nullopt;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
for (auto suffix : keys_at(text, end, {U"er", U"re", U"ère", U"e", U"ème"})) {
|
|
72
|
+
if (is_clear_after(text, end + suffix.size())) {
|
|
73
|
+
std::u32string digits = utils::conversions::utf8_to_u32(std::to_string(*value));
|
|
74
|
+
return Match{.kind = Kind::ORDINAL,
|
|
75
|
+
.span = {position, end + suffix.size()},
|
|
76
|
+
.numbers = {{.span = {position, end}, .integer = digits}},
|
|
77
|
+
.suffix = suffix};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
return std::nullopt;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
} // namespace phonemis::fr
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <phonemis/base/processor/layers/num2word/pattern.h>
|
|
4
|
+
|
|
5
|
+
namespace phonemis::fr {
|
|
6
|
+
|
|
7
|
+
// XXe, XIXème, Ier: an ordinal written in Roman numerals. Its number is the value of the numeral.
|
|
8
|
+
class RomanOrdinalPattern : public processor::num2word::Pattern {
|
|
9
|
+
public:
|
|
10
|
+
RomanOrdinalPattern() : Pattern(processor::num2word::Kind::ORDINAL) {}
|
|
11
|
+
|
|
12
|
+
std::optional<processor::num2word::Match> match(std::u32string_view text, size_t position) const override;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
} // namespace phonemis::fr
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
#include <phonemis/base/ipipeline.h>
|
|
8
8
|
#include <phonemis/base/phonemizer/hybrid_phonemizer.h>
|
|
9
9
|
#include <phonemis/base/phonemizer/lexicon_phonemizer.h>
|
|
10
|
+
#include <phonemis/base/processor/preprocessor.h>
|
|
10
11
|
#include <phonemis/base/processor/processor.h>
|
|
11
|
-
#include <phonemis/base/processor/trim_layer.h>
|
|
12
12
|
#include <phonemis/base/tokenizer/tokenizer.h>
|
|
13
13
|
#include <phonemis/utils/conversions.h>
|
|
14
14
|
|
|
@@ -24,8 +24,8 @@ public:
|
|
|
24
24
|
phonemizer_(config.phonemizer) {
|
|
25
25
|
|
|
26
26
|
// 1. Setup Preprocessing layers
|
|
27
|
-
preprocessor_
|
|
28
|
-
|
|
27
|
+
preprocessor_ = processor::make_preprocessor<Num2Word>(
|
|
28
|
+
config.preprocessor, {.terms = &constants::term2word::kTerms, .symbols = &constants::sym2word::kSymbols});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
// Performs a preprocessing stage of the pipeline.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
+
#include <phonemis/base/processor/common/conditions.h>
|
|
4
|
+
#include <phonemis/base/processor/layers/normalize/types.h>
|
|
5
|
+
#include <phonemis/base/processor/layers/num2word/notation.h>
|
|
6
|
+
#include <phonemis/base/processor/layers/term2word/types.h>
|
|
3
7
|
#include <phonemis/base/tokenizer/types.h>
|
|
4
8
|
|
|
5
9
|
#include <array>
|
|
@@ -12,8 +16,25 @@
|
|
|
12
16
|
|
|
13
17
|
namespace phonemis::hi::constants {
|
|
14
18
|
|
|
19
|
+
// --- Character Normalization ---
|
|
20
|
+
namespace normalize {
|
|
21
|
+
using ::phonemis::processor::normalize::Characters;
|
|
22
|
+
|
|
23
|
+
// Echo's classes, but the zero-width non-joiner and joiner stay: they decide how Devanagari letters join
|
|
24
|
+
inline const Characters kCharacters = {
|
|
25
|
+
{U"…", U"..."}, // Ellipsis
|
|
26
|
+
{U"«»„“”‟˝", U"\""}, // Quotes
|
|
27
|
+
{U"‘’‚‛´`ʼ", U"'"}, // Apostrophes
|
|
28
|
+
{U"\u200b\ufeff", U""} // Invisible: zero-width space, byte order mark
|
|
29
|
+
};
|
|
30
|
+
} // namespace normalize
|
|
31
|
+
|
|
15
32
|
// --- Number to Word Normalization ---
|
|
16
33
|
namespace num2word {
|
|
34
|
+
using ::phonemis::processor::num2word::DateFormat;
|
|
35
|
+
using ::phonemis::processor::num2word::Joiners;
|
|
36
|
+
using ::phonemis::processor::num2word::keys_of;
|
|
37
|
+
using ::phonemis::processor::num2word::Notation;
|
|
17
38
|
// Hindi has unique cardinal words for every number 0-99 — they are not
|
|
18
39
|
// compositionally derivable from tens + units like in most European
|
|
19
40
|
// languages. Above 99 the construction becomes regular: hundreds use
|
|
@@ -53,10 +74,10 @@ namespace num2word {
|
|
|
53
74
|
|
|
54
75
|
// Currencies. Hindi loanword currencies are invariable in form, so only the
|
|
55
76
|
// singular noun is stored.
|
|
56
|
-
inline const std::unordered_map<
|
|
57
|
-
{U
|
|
58
|
-
{U
|
|
59
|
-
{U
|
|
77
|
+
inline const std::unordered_map<std::u32string, std::u32string> kCurrencies = {
|
|
78
|
+
{U"$", U"डॉलर"},
|
|
79
|
+
{U"€", U"यूरो"},
|
|
80
|
+
{U"£", U"पाउंड"}
|
|
60
81
|
};
|
|
61
82
|
|
|
62
83
|
// Months: standard Gregorian month names in Hindi (used as-is in dates).
|
|
@@ -84,15 +105,46 @@ namespace num2word {
|
|
|
84
105
|
U"वाँ", U"वीं", U"वें"
|
|
85
106
|
};
|
|
86
107
|
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
108
|
+
// Ordinal suffixes after digits, in the order of OrdinalForms: 5वाँ, 5वीं, 5वें
|
|
109
|
+
inline const std::vector<std::u32string> kOrdinalSuffixes = {
|
|
110
|
+
U"वाँ", U"वीं", U"वें"
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
// --- Notation: how numbers are written ---
|
|
114
|
+
inline const Notation kNotation = {
|
|
115
|
+
.group_separators = U",", .decimal_separators = U".", .time_separators = U":", .currencies = keys_of(kCurrencies),
|
|
116
|
+
.fractions = true
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
// Words between numbers: 3.8.10, 10.0.0.51, 10-15, 1920x1080, 2:1, -5, 2 + 2
|
|
120
|
+
inline const Joiners kJoiners = {
|
|
121
|
+
.point = U"दशमलव", .dot = U"दशमलव", .range = U" से ", .by = U"गुणा", .score = U" ", .minus = U"माइनस", .plus = U"प्लस"
|
|
93
122
|
};
|
|
123
|
+
|
|
124
|
+
// 27.03.2026, 27-03-2026: the year has four digits
|
|
125
|
+
inline const DateFormat kDateFormat = {.separators = U".-/", .short_year = false};
|
|
94
126
|
} // namespace num2word
|
|
95
127
|
|
|
128
|
+
// --- Symbols to Word Normalization ---
|
|
129
|
+
namespace sym2word {
|
|
130
|
+
using ::phonemis::processor::Readings;
|
|
131
|
+
|
|
132
|
+
// TODO: not verified against a reference verbalizer yet
|
|
133
|
+
inline const Readings kSymbols = {
|
|
134
|
+
{U"&", {U"और"}}, {U"+", {U"प्लस"}}, {U"=", {U"बराबर"}}, {U"%", {U"प्रतिशत"}}, {U"@", {U"एट"}},
|
|
135
|
+
{U"°", {U"डिग्री"}}, {U"$", {U"डॉलर"}}, {U"€", {U"यूरो"}}, {U"£", {U"पाउंड"}}, {U"₹", {U"रुपये"}}
|
|
136
|
+
};
|
|
137
|
+
} // namespace sym2word
|
|
138
|
+
|
|
139
|
+
// --- Terms to Word Normalization ---
|
|
140
|
+
namespace term2word {
|
|
141
|
+
using ::phonemis::processor::term2word::Terms;
|
|
142
|
+
|
|
143
|
+
inline const Terms kTerms = {
|
|
144
|
+
.web = {.dot = U"डॉट", .at = U"एट", .slash = U"स्लैश"}
|
|
145
|
+
};
|
|
146
|
+
} // namespace term2word
|
|
147
|
+
|
|
96
148
|
// --- Tokenization Rules ---
|
|
97
149
|
namespace tokenizer {
|
|
98
150
|
using ::phonemis::tokenizer::split::Rule;
|
|
@@ -1,162 +1,113 @@
|
|
|
1
|
-
#include "num2word.h"
|
|
2
1
|
#include "constants.h"
|
|
3
|
-
#include
|
|
2
|
+
#include "num2word.h"
|
|
3
|
+
#include <phonemis/base/processor/layers/num2word/numerals.h>
|
|
4
|
+
#include <phonemis/base/processor/layers/num2word/patterns.h>
|
|
5
|
+
|
|
4
6
|
#include <algorithm>
|
|
5
|
-
#include <cmath>
|
|
6
7
|
#include <cstddef>
|
|
7
|
-
#include <cstdlib>
|
|
8
8
|
|
|
9
9
|
namespace phonemis::hi {
|
|
10
10
|
|
|
11
|
-
using namespace constants;
|
|
12
|
-
using namespace
|
|
11
|
+
using namespace constants::num2word;
|
|
12
|
+
using namespace processor;
|
|
13
|
+
using namespace processor::num2word;
|
|
13
14
|
|
|
14
15
|
namespace {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
// align with the column order used in `kOrdinalsSpecial` and `kOrdinalEndings`.
|
|
18
|
-
enum class OrdinalForm : std::size_t { MASCULINE = 0, FEMININE = 1, PLURAL = 2 };
|
|
19
|
-
|
|
20
|
-
// Maps an ordinal suffix to a gender/number form. The base scanner only
|
|
21
|
-
// captures the alpha portion ("व") of a Devanagari suffix because matras and
|
|
22
|
-
// nasal marks aren't classified as alphabetic, so the masculine form is the
|
|
23
|
-
// only one selectable through digit-attached notation in raw text. Direct
|
|
24
|
-
// API callers can pass the full ending ("वाँ", "वीं", "वें") to pick a
|
|
25
|
-
// specific form.
|
|
26
|
-
OrdinalForm form_from_suffix(std::u32string_view suffix) {
|
|
27
|
-
if (suffix == U"वीं") return OrdinalForm::FEMININE;
|
|
28
|
-
if (suffix == U"वें") return OrdinalForm::PLURAL;
|
|
29
|
-
return OrdinalForm::MASCULINE;
|
|
16
|
+
uint64_t value(const Number& number) {
|
|
17
|
+
return value_of(number.integer).value_or(0);
|
|
30
18
|
}
|
|
31
19
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return U"माइनस " + to_cardinal_int(std::abs(value));
|
|
20
|
+
// Every number up to 99 is its own word; then "<digit> सौ", and the Indian scales (हज़ार, लाख, करोड़)
|
|
21
|
+
std::u32string cardinal(uint64_t n) {
|
|
22
|
+
if (n < 100) {
|
|
23
|
+
return kCardinals.at(static_cast<int32_t>(n));
|
|
37
24
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return
|
|
25
|
+
if (n < 1000) {
|
|
26
|
+
uint64_t rest = n % 100;
|
|
27
|
+
return kCardinals.at(static_cast<int32_t>(n / 100)) + U" सौ" + (rest ? U" " + cardinal(rest) : U"");
|
|
41
28
|
}
|
|
42
29
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (rest == 0) return head;
|
|
50
|
-
return head + U" " + to_cardinal_int(rest);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Indian-numbering decomposition (हज़ार / लाख / करोड़) in descending order.
|
|
54
|
-
// Unlike Western numbering, the next scale up after हज़ार multiplies by 100
|
|
55
|
-
// (lakh = 100k) and then 100 again (crore = 10M), so 1,000,000 reads as
|
|
56
|
-
// "दस लाख" rather than as a million-scoped phrase.
|
|
57
|
-
for (auto it = num2word::kLargeCardinals.rbegin(); it != num2word::kLargeCardinals.rend(); ++it) {
|
|
58
|
-
int64_t base = it->first;
|
|
59
|
-
if (static_cast<int64_t>(value) >= base) {
|
|
60
|
-
int32_t high = value / static_cast<int32_t>(base);
|
|
61
|
-
int32_t low = value % static_cast<int32_t>(base);
|
|
62
|
-
|
|
63
|
-
// Hindi keeps the leading "एक" in front of every scale noun (e.g.
|
|
64
|
-
// 1000 -> "एक हज़ार", 100000 -> "एक लाख"), unlike European languages
|
|
65
|
-
// that drop the multiplier of one.
|
|
66
|
-
std::u32string res = to_cardinal_int(high) + U" " + it->second;
|
|
67
|
-
if (low > 0) {
|
|
68
|
-
res += U" " + to_cardinal_int(low);
|
|
69
|
-
}
|
|
70
|
-
return res;
|
|
30
|
+
// Hindi keeps the "एक" of every scale: एक हज़ार, एक लाख
|
|
31
|
+
for (auto it = kLargeCardinals.rbegin(); it != kLargeCardinals.rend(); ++it) {
|
|
32
|
+
auto base = static_cast<uint64_t>(it->first);
|
|
33
|
+
if (n >= base) {
|
|
34
|
+
uint64_t low = n % base;
|
|
35
|
+
return cardinal(n / base) + U" " + it->second + (low ? U" " + cardinal(low) : U"");
|
|
71
36
|
}
|
|
72
37
|
}
|
|
73
|
-
|
|
74
|
-
return conversions::utf8_to_u32(std::to_string(value));
|
|
38
|
+
return U"";
|
|
75
39
|
}
|
|
76
40
|
|
|
77
|
-
std::u32string
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
std::string value_str = conversions::u32_to_utf8(repr);
|
|
83
|
-
|
|
84
|
-
// Trim trailing zeros and any dangling decimal point.
|
|
85
|
-
auto rit = std::find_if(value_str.rbegin(), value_str.rend(),
|
|
86
|
-
[](char c) { return c != '0'; });
|
|
87
|
-
value_str = std::string(value_str.begin(), rit.base());
|
|
88
|
-
if (!value_str.empty() && value_str.back() == '.') {
|
|
89
|
-
value_str.pop_back();
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
size_t dot_pos = value_str.find('.');
|
|
93
|
-
if (dot_pos == std::string::npos) {
|
|
94
|
-
return to_cardinal_int(value_str.empty() ? 0 : std::stoi(value_str));
|
|
41
|
+
std::u32string digits(std::u32string_view text) {
|
|
42
|
+
std::vector<std::u32string> words;
|
|
43
|
+
for (char32_t c : text) {
|
|
44
|
+
words.push_back(cardinal(c - U'0'));
|
|
95
45
|
}
|
|
96
|
-
|
|
97
|
-
std::string integer_part_str = value_str.substr(0, dot_pos);
|
|
98
|
-
std::string fractional_part_str = value_str.substr(dot_pos + 1);
|
|
99
|
-
int32_t integer_part = integer_part_str.empty() ? 0 : std::stoi(integer_part_str);
|
|
100
|
-
|
|
101
|
-
// Hindi reads the fractional part digit-by-digit (e.g. 0.05 -> "शून्य
|
|
102
|
-
// दशमलव शून्य पाँच"), unlike languages that verbalize it as a whole number.
|
|
103
|
-
std::u32string frac_words;
|
|
104
|
-
for (char c : fractional_part_str) {
|
|
105
|
-
if (!frac_words.empty()) frac_words += U" ";
|
|
106
|
-
frac_words += to_cardinal_int(c - '0');
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return to_cardinal_int(integer_part) + U" दशमलव " + frac_words;
|
|
46
|
+
return join(words);
|
|
110
47
|
}
|
|
48
|
+
} // namespace
|
|
111
49
|
|
|
112
|
-
|
|
113
|
-
|
|
50
|
+
Num2Word::Num2Word() : Num2WordLayer(kNotation, kJoiners) {
|
|
51
|
+
add_pattern(std::make_unique<DatePattern>(kDateFormat));
|
|
52
|
+
add_pattern(std::make_unique<SuffixPattern>(Kind::ORDINAL, kOrdinalSuffixes));
|
|
53
|
+
}
|
|
114
54
|
|
|
115
|
-
|
|
116
|
-
|
|
55
|
+
std::u32string Num2Word::read_number(const Number& number, const NumberReading& reading) const {
|
|
56
|
+
if (number.fraction.empty() && spoken_digits(number, 7)) {
|
|
57
|
+
return digits(number.integer);
|
|
117
58
|
}
|
|
118
59
|
|
|
119
|
-
//
|
|
120
|
-
|
|
121
|
-
|
|
60
|
+
// The fraction is read digit by digit, without its trailing zeros: 0.50 -> शून्य दशमलव पाँच
|
|
61
|
+
std::u32string_view fraction = number.fraction;
|
|
62
|
+
fraction = fraction.substr(0, fraction.find_last_not_of(U'0') + 1);
|
|
63
|
+
std::u32string integer = cardinal(value(number));
|
|
64
|
+
return fraction.empty() ? integer : integer + U" दशमलव " + digits(fraction);
|
|
122
65
|
}
|
|
123
66
|
|
|
124
|
-
std::u32string Num2Word::
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
return it->second;
|
|
67
|
+
std::u32string Num2Word::read_code_digits(std::u32string_view text) const {
|
|
68
|
+
auto n = value_of(text);
|
|
69
|
+
if ((text.size() > 1 && text[0] == U'0') || text.size() >= 7 || !n) {
|
|
70
|
+
return digits(text);
|
|
129
71
|
}
|
|
130
|
-
return
|
|
72
|
+
return cardinal(*n);
|
|
131
73
|
}
|
|
132
74
|
|
|
133
|
-
std::u32string Num2Word::
|
|
134
|
-
//
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (denominator == 3) return to_cardinal_int(numerator) + U" तिहाई";
|
|
138
|
-
if (denominator == 4) return to_cardinal_int(numerator) + U" चौथाई";
|
|
139
|
-
return to_cardinal_int(numerator) + U" बटा " + to_cardinal_int(denominator);
|
|
75
|
+
std::u32string Num2Word::read_date(const Match& match, const NumberReading& reading) const {
|
|
76
|
+
// सत्ताईस मार्च दो हज़ार छब्बीस
|
|
77
|
+
return cardinal(value(match.numbers[0])) + U" " + kMonths[value(match.numbers[1])] + U" " +
|
|
78
|
+
cardinal(value(match.numbers[2]));
|
|
140
79
|
}
|
|
141
80
|
|
|
142
|
-
std::u32string Num2Word::
|
|
143
|
-
//
|
|
144
|
-
|
|
81
|
+
std::u32string Num2Word::read_fraction(const Match& match, const NumberReading& reading) const {
|
|
82
|
+
// Common fractions have their own nouns, others are "<a> बटा <b>"
|
|
83
|
+
uint64_t a = value(match.numbers[0]), b = value(match.numbers[1]);
|
|
84
|
+
if (a == 1 && b == 2) {
|
|
85
|
+
return U"आधा";
|
|
86
|
+
}
|
|
87
|
+
if (b == 3 || b == 4) {
|
|
88
|
+
return cardinal(a) + (b == 3 ? U" तिहाई" : U" चौथाई");
|
|
89
|
+
}
|
|
90
|
+
return cardinal(a) + U" बटा " + cardinal(b);
|
|
145
91
|
}
|
|
146
92
|
|
|
147
|
-
std::u32string Num2Word::
|
|
148
|
-
|
|
149
|
-
|
|
93
|
+
std::u32string Num2Word::read_ordinal(const Match& match, const NumberReading& reading) const {
|
|
94
|
+
// The suffix gives the form: masculine (वाँ), feminine (वीं) or plural (वें)
|
|
95
|
+
size_t form = std::ranges::find(kOrdinalSuffixes, match.suffix) - kOrdinalSuffixes.begin();
|
|
96
|
+
uint64_t n = value(match.numbers[0]);
|
|
97
|
+
|
|
98
|
+
// पहला, दूसरा, तीसरा, चौथा, छठा: irregular
|
|
99
|
+
if (auto it = kOrdinalsSpecial.find(static_cast<int32_t>(n)); n < 10 && it != kOrdinalsSpecial.end()) {
|
|
100
|
+
return it->second[form];
|
|
150
101
|
}
|
|
151
|
-
return
|
|
102
|
+
return cardinal(n) + kOrdinalEndings[form];
|
|
152
103
|
}
|
|
153
104
|
|
|
154
|
-
std::u32string Num2Word::
|
|
155
|
-
return
|
|
105
|
+
std::u32string Num2Word::read_money(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
106
|
+
return read_number(number, reading) + U" " + kCurrencies.at(std::u32string(match.unit));
|
|
156
107
|
}
|
|
157
108
|
|
|
158
|
-
|
|
159
|
-
return
|
|
109
|
+
std::u32string Num2Word::read_percent(const Number& number, const Match& match, const NumberReading& reading) const {
|
|
110
|
+
return read_number(number, reading) + U" प्रतिशत";
|
|
160
111
|
}
|
|
161
112
|
|
|
162
|
-
} // namespace phonemis::hi
|
|
113
|
+
} // namespace phonemis::hi
|
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
#pragma once
|
|
2
2
|
|
|
3
|
-
#include <phonemis/base/processor/num2word/layer.h>
|
|
3
|
+
#include <phonemis/base/processor/layers/num2word/layer.h>
|
|
4
|
+
|
|
4
5
|
#include <string>
|
|
5
|
-
#include <variant>
|
|
6
6
|
|
|
7
7
|
namespace phonemis::hi {
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
// Hindi numbers are read without context so far.
|
|
10
|
+
struct NumberReading {};
|
|
11
|
+
|
|
12
|
+
// TODO: outdated - Hindi readings predate the context-aware design and have no reference verbalizer.
|
|
13
|
+
// Missing: Indian digit grouping (1,00,000), Devanagari digits, units and context (gender) of the counted noun.
|
|
14
|
+
class Num2Word : public processor::num2word::Num2WordLayer<NumberReading> {
|
|
10
15
|
public:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
Num2Word();
|
|
17
|
+
|
|
18
|
+
protected:
|
|
19
|
+
using Context = processor::Context;
|
|
20
|
+
using Match = processor::num2word::Match;
|
|
21
|
+
using Number = processor::num2word::Number;
|
|
22
|
+
|
|
23
|
+
// Resolution
|
|
24
|
+
NumberReading resolve(const Match& match, const Context& context) const override { return {}; }
|
|
25
|
+
|
|
26
|
+
// Readings
|
|
27
|
+
std::u32string read_number(const Number& number, const NumberReading& reading) const override;
|
|
28
|
+
std::u32string read_code_digits(std::u32string_view digits) const override;
|
|
29
|
+
std::u32string read_date(const Match& match, const NumberReading& reading) const override;
|
|
30
|
+
std::u32string read_fraction(const Match& match, const NumberReading& reading) const override;
|
|
31
|
+
std::u32string read_ordinal(const Match& match, const NumberReading& reading) const override;
|
|
32
|
+
std::u32string read_money(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
33
|
+
std::u32string read_percent(const Number& number, const Match& match, const NumberReading& reading) const override;
|
|
23
34
|
};
|
|
24
35
|
|
|
25
|
-
} // namespace phonemis::hi
|
|
36
|
+
} // namespace phonemis::hi
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
#include <phonemis/base/ipipeline.h>
|
|
9
9
|
#include <phonemis/base/phonemizer/hybrid_phonemizer.h>
|
|
10
10
|
#include <phonemis/base/phonemizer/lexicon_phonemizer.h>
|
|
11
|
+
#include <phonemis/base/processor/preprocessor.h>
|
|
11
12
|
#include <phonemis/base/processor/processor.h>
|
|
12
|
-
#include <phonemis/base/processor/trim_layer.h>
|
|
13
13
|
#include <phonemis/base/tokenizer/tokenizer.h>
|
|
14
14
|
|
|
15
15
|
#include <memory>
|
|
@@ -24,8 +24,10 @@ public:
|
|
|
24
24
|
phonemizer_(make_phonemizer_config(config.phonemizer)) {
|
|
25
25
|
|
|
26
26
|
// 1. Setup Preprocessing layers
|
|
27
|
-
preprocessor_
|
|
28
|
-
|
|
27
|
+
preprocessor_ =
|
|
28
|
+
processor::make_preprocessor<Num2Word>(config.preprocessor, {.characters = &constants::normalize::kCharacters,
|
|
29
|
+
.terms = &constants::term2word::kTerms,
|
|
30
|
+
.symbols = &constants::sym2word::kSymbols});
|
|
29
31
|
}
|
|
30
32
|
|
|
31
33
|
// Performs a preprocessing stage of the pipeline.
|