react-native-executorch 0.10.5 → 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.
Files changed (251) hide show
  1. package/README.md +10 -1
  2. package/android/build.gradle.kts +4 -3
  3. package/ios/RnExecutorch.mm +15 -17
  4. package/lib/module/fetcher/fetcher.js +35 -122
  5. package/lib/module/fetcher/fetcher.js.map +1 -1
  6. package/lib/module/fetcher/telemetry.js +1 -1
  7. package/lib/module/index.js +12 -13
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/module/models.js +4 -2
  10. package/lib/module/models.js.map +1 -1
  11. package/lib/typescript/src/fetcher/fetcher.d.ts +3 -7
  12. package/lib/typescript/src/fetcher/fetcher.d.ts.map +1 -1
  13. package/lib/typescript/src/models.d.ts.map +1 -1
  14. package/package.json +9 -7
  15. package/react-native-executorch.podspec +6 -2
  16. package/src/fetcher/fetcher.ts +38 -131
  17. package/src/fetcher/telemetry.ts +1 -1
  18. package/src/models.ts +6 -1
  19. package/third-party/common/phonemis/CMakeLists.txt +70 -14
  20. package/third-party/common/phonemis/README.md +183 -33
  21. package/third-party/common/phonemis/THIRD_PARTY_NOTICES.md +57 -0
  22. package/third-party/common/phonemis/knowledge/code_style.md +642 -0
  23. package/third-party/common/phonemis/licenses/Unicode-3.0.txt +39 -0
  24. package/third-party/common/phonemis/licenses/misaki-Apache-2.0.txt +201 -0
  25. package/third-party/common/phonemis/licenses/nlohmann-json-MIT.txt +21 -0
  26. package/third-party/common/phonemis/licenses/xsimd-BSD-3-Clause.txt +29 -0
  27. package/third-party/common/phonemis/src/phonemis/base/config.h +6 -0
  28. package/third-party/common/phonemis/src/phonemis/base/ipipeline.cpp +75 -0
  29. package/third-party/common/phonemis/src/phonemis/base/ipipeline.h +21 -0
  30. package/third-party/common/phonemis/src/phonemis/base/phonemizer/constants.h +2 -5
  31. package/third-party/common/phonemis/src/phonemis/base/phonemizer/lexicon_phonemizer.cpp +3 -4
  32. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.cpp +17 -8
  33. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/neural_phonemizer.h +4 -0
  34. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.cpp +21 -6
  35. package/third-party/common/phonemis/src/phonemis/base/phonemizer/nn/tokenizer.h +13 -4
  36. package/third-party/common/phonemis/src/phonemis/base/pipeline.cpp +8 -0
  37. package/third-party/common/phonemis/src/phonemis/base/pipeline.h +19 -0
  38. package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.cpp +37 -0
  39. package/third-party/common/phonemis/src/phonemis/base/processor/common/conditions.h +45 -0
  40. package/third-party/common/phonemis/src/phonemis/base/processor/common/constants.h +10 -0
  41. package/third-party/common/phonemis/src/phonemis/base/processor/common/context.cpp +105 -0
  42. package/third-party/common/phonemis/src/phonemis/base/processor/common/context.h +49 -0
  43. package/third-party/common/phonemis/src/phonemis/base/processor/common/document.cpp +173 -0
  44. package/third-party/common/phonemis/src/phonemis/base/processor/common/document.h +67 -0
  45. package/third-party/common/phonemis/src/phonemis/base/processor/common/text.cpp +75 -0
  46. package/third-party/common/phonemis/src/phonemis/base/processor/common/text.h +60 -0
  47. package/third-party/common/phonemis/src/phonemis/base/processor/common/types.h +18 -0
  48. package/third-party/common/phonemis/src/phonemis/base/processor/config.h +53 -0
  49. package/third-party/common/phonemis/src/phonemis/base/processor/layer.h +9 -7
  50. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/constants.h +20 -0
  51. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.cpp +89 -0
  52. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/layer.h +35 -0
  53. package/third-party/common/phonemis/src/phonemis/base/processor/layers/normalize/types.h +16 -0
  54. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/kind.h +40 -0
  55. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/layer.h +382 -0
  56. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/notation.h +30 -0
  57. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.cpp +51 -0
  58. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/numerals.h +31 -0
  59. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern.h +30 -0
  60. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.cpp +17 -0
  61. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/pattern_set.h +31 -0
  62. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.cpp +811 -0
  63. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/patterns.h +285 -0
  64. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.cpp +64 -0
  65. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/primitives.h +23 -0
  66. package/third-party/common/phonemis/src/phonemis/base/processor/layers/num2word/types.h +94 -0
  67. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sanitizer/layer.cpp +19 -0
  68. package/third-party/common/phonemis/src/phonemis/base/processor/{sanitizer_layer.h → layers/sanitizer/layer.h} +8 -8
  69. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.cpp +65 -0
  70. package/third-party/common/phonemis/src/phonemis/base/processor/layers/sym2word/layer.h +29 -0
  71. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.cpp +170 -0
  72. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/layer.h +40 -0
  73. package/third-party/common/phonemis/src/phonemis/base/processor/layers/term2word/types.h +25 -0
  74. package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.cpp +47 -0
  75. package/third-party/common/phonemis/src/phonemis/base/processor/layers/trim/layer.h +19 -0
  76. package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.cpp +60 -0
  77. package/third-party/common/phonemis/src/phonemis/base/processor/preprocessor.h +45 -0
  78. package/third-party/common/phonemis/src/phonemis/base/processor/processor.cpp +6 -7
  79. package/third-party/common/phonemis/src/phonemis/base/processor/processor.h +14 -10
  80. package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.cpp +89 -52
  81. package/third-party/common/phonemis/src/phonemis/base/tagger/hmm_tagger.h +16 -9
  82. package/third-party/common/phonemis/src/phonemis/base/tokenizer/tokenizer.cpp +13 -12
  83. package/third-party/common/phonemis/src/phonemis/lang/de/constants.h +183 -19
  84. package/third-party/common/phonemis/src/phonemis/lang/de/num2word.cpp +355 -309
  85. package/third-party/common/phonemis/src/phonemis/lang/de/num2word.h +42 -17
  86. package/third-party/common/phonemis/src/phonemis/lang/de/patterns.cpp +56 -0
  87. package/third-party/common/phonemis/src/phonemis/lang/de/patterns.h +15 -0
  88. package/third-party/common/phonemis/src/phonemis/lang/de/pipeline.h +3 -3
  89. package/third-party/common/phonemis/src/phonemis/lang/en/constants.h +181 -30
  90. package/third-party/common/phonemis/src/phonemis/lang/en/hmm_tagger.cpp +5 -7
  91. package/third-party/common/phonemis/src/phonemis/lang/en/num2word.cpp +232 -135
  92. package/third-party/common/phonemis/src/phonemis/lang/en/num2word.h +41 -16
  93. package/third-party/common/phonemis/src/phonemis/lang/en/pipeline.h +3 -10
  94. package/third-party/common/phonemis/src/phonemis/lang/es/constants.h +182 -60
  95. package/third-party/common/phonemis/src/phonemis/lang/es/num2word.cpp +247 -212
  96. package/third-party/common/phonemis/src/phonemis/lang/es/num2word.h +38 -18
  97. package/third-party/common/phonemis/src/phonemis/lang/es/patterns.cpp +50 -0
  98. package/third-party/common/phonemis/src/phonemis/lang/es/patterns.h +15 -0
  99. package/third-party/common/phonemis/src/phonemis/lang/es/pipeline.h +3 -3
  100. package/third-party/common/phonemis/src/phonemis/lang/fr/constants.h +152 -26
  101. package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.cpp +252 -179
  102. package/third-party/common/phonemis/src/phonemis/lang/fr/num2word.h +38 -15
  103. package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.cpp +83 -0
  104. package/third-party/common/phonemis/src/phonemis/lang/fr/patterns.h +15 -0
  105. package/third-party/common/phonemis/src/phonemis/lang/fr/pipeline.h +3 -3
  106. package/third-party/common/phonemis/src/phonemis/lang/hi/constants.h +62 -10
  107. package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.cpp +74 -123
  108. package/third-party/common/phonemis/src/phonemis/lang/hi/num2word.h +27 -16
  109. package/third-party/common/phonemis/src/phonemis/lang/hi/pipeline.h +5 -3
  110. package/third-party/common/phonemis/src/phonemis/lang/it/constants.h +122 -42
  111. package/third-party/common/phonemis/src/phonemis/lang/it/num2word.cpp +200 -207
  112. package/third-party/common/phonemis/src/phonemis/lang/it/num2word.h +30 -18
  113. package/third-party/common/phonemis/src/phonemis/lang/it/patterns.cpp +25 -0
  114. package/third-party/common/phonemis/src/phonemis/lang/it/patterns.h +15 -0
  115. package/third-party/common/phonemis/src/phonemis/lang/it/pipeline.h +3 -3
  116. package/third-party/common/phonemis/src/phonemis/lang/pl/constants.h +346 -77
  117. package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.cpp +631 -246
  118. package/third-party/common/phonemis/src/phonemis/lang/pl/num2word.h +47 -15
  119. package/third-party/common/phonemis/src/phonemis/lang/pl/pipeline.h +6 -6
  120. package/third-party/common/phonemis/src/phonemis/lang/pt/constants.h +201 -0
  121. package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.cpp +365 -0
  122. package/third-party/common/phonemis/src/phonemis/lang/pt/num2word.h +53 -0
  123. package/third-party/common/phonemis/src/phonemis/lang/pt/pipeline.h +4 -2
  124. package/third-party/common/phonemis/src/phonemis/main.cpp +42 -11
  125. package/third-party/common/phonemis/src/phonemis/protophone/meta.h +24 -0
  126. package/third-party/common/phonemis/src/phonemis/protophone/numeric.h +26 -0
  127. package/third-party/common/phonemis/src/phonemis/protophone/protophone.cpp +525 -0
  128. package/third-party/common/phonemis/src/phonemis/protophone/protophone.h +80 -0
  129. package/third-party/common/phonemis/src/phonemis/protophone/tensor.h +76 -0
  130. package/third-party/common/phonemis/src/phonemis/protophone/tensor_utils.h +89 -0
  131. package/third-party/common/phonemis/src/phonemis/protophone/tensor_view.h +125 -0
  132. package/third-party/common/phonemis/src/phonemis/protophone/types.h +43 -0
  133. package/third-party/common/phonemis/src/phonemis/utils/strings.h +20 -14
  134. package/third-party/common/phonemis/src/phonemis/utils/unicode.h +15 -1
  135. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_arithmetic.hpp +267 -0
  136. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_bit.hpp +232 -0
  137. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_cast.hpp +43 -0
  138. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_complex.hpp +112 -0
  139. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_details.hpp +386 -0
  140. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_logical.hpp +240 -0
  141. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_math.hpp +2601 -0
  142. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_memory.hpp +1006 -0
  143. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_rounding.hpp +72 -0
  144. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_swizzle.hpp +260 -0
  145. package/third-party/common/phonemis/src/third-party/xsimd/arch/common/xsimd_common_trigo.hpp +996 -0
  146. package/third-party/common/phonemis/src/third-party/xsimd/arch/utils/shifts.hpp +82 -0
  147. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx.hpp +2111 -0
  148. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2.hpp +1591 -0
  149. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx2_128.hpp +170 -0
  150. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512bw.hpp +724 -0
  151. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512cd.hpp +28 -0
  152. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512dq.hpp +270 -0
  153. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512er.hpp +17 -0
  154. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512f.hpp +2919 -0
  155. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512ifma.hpp +17 -0
  156. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512pf.hpp +17 -0
  157. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi.hpp +76 -0
  158. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vbmi2.hpp +130 -0
  159. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512bw.hpp +17 -0
  160. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx512vnni_avx512vbmi2.hpp +17 -0
  161. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avx_128.hpp +164 -0
  162. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_avxvnni.hpp +17 -0
  163. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common.hpp +26 -0
  164. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_common_fwd.hpp +127 -0
  165. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_constants.hpp +393 -0
  166. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_emulated.hpp +787 -0
  167. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx.hpp +93 -0
  168. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_avx2.hpp +46 -0
  169. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma3_sse.hpp +97 -0
  170. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_fma4.hpp +92 -0
  171. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_i8mm_neon64.hpp +17 -0
  172. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_isa.hpp +148 -0
  173. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon.hpp +3580 -0
  174. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_neon64.hpp +1614 -0
  175. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_rvv.hpp +1515 -0
  176. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_scalar.hpp +1210 -0
  177. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse2.hpp +2333 -0
  178. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse3.hpp +66 -0
  179. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_1.hpp +510 -0
  180. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sse4_2.hpp +44 -0
  181. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_ssse3.hpp +186 -0
  182. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_sve.hpp +1186 -0
  183. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vsx.hpp +947 -0
  184. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_vxe.hpp +787 -0
  185. package/third-party/common/phonemis/src/third-party/xsimd/arch/xsimd_wasm.hpp +1819 -0
  186. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_arch.hpp +242 -0
  187. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_config.hpp +633 -0
  188. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features.hpp +50 -0
  189. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_arm.hpp +132 -0
  190. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_ppc.hpp +54 -0
  191. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_riscv.hpp +95 -0
  192. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_s390x.hpp +56 -0
  193. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpu_features_x86.hpp +1121 -0
  194. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_cpuid.hpp +144 -0
  195. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_getauxval.hpp +159 -0
  196. package/third-party/common/phonemis/src/third-party/xsimd/config/xsimd_macros.hpp +78 -0
  197. package/third-party/common/phonemis/src/third-party/xsimd/math/xsimd_rem_pio2.hpp +707 -0
  198. package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_aligned_allocator.hpp +349 -0
  199. package/third-party/common/phonemis/src/third-party/xsimd/memory/xsimd_alignment.hpp +102 -0
  200. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_all_registers.hpp +57 -0
  201. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_api.hpp +3106 -0
  202. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx2_register.hpp +57 -0
  203. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512bw_register.hpp +51 -0
  204. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512cd_register.hpp +51 -0
  205. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512dq_register.hpp +51 -0
  206. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512er_register.hpp +51 -0
  207. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512f_register.hpp +77 -0
  208. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512ifma_register.hpp +51 -0
  209. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512pf_register.hpp +51 -0
  210. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi2_register.hpp +51 -0
  211. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vbmi_register.hpp +51 -0
  212. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512bw_register.hpp +54 -0
  213. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx512vnni_avx512vbmi2_register.hpp +53 -0
  214. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avx_register.hpp +79 -0
  215. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_avxvnni_register.hpp +44 -0
  216. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch.hpp +1666 -0
  217. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_constant.hpp +572 -0
  218. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_batch_fwd.hpp +41 -0
  219. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_common_arch.hpp +49 -0
  220. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_emulated_register.hpp +80 -0
  221. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx2_register.hpp +50 -0
  222. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_avx_register.hpp +50 -0
  223. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma3_sse_register.hpp +50 -0
  224. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_fma4_register.hpp +50 -0
  225. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_i8mm_neon64_register.hpp +55 -0
  226. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon64_register.hpp +55 -0
  227. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_neon_register.hpp +130 -0
  228. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_register.hpp +96 -0
  229. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_rvv_register.hpp +491 -0
  230. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse2_register.hpp +59 -0
  231. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse3_register.hpp +49 -0
  232. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_1_register.hpp +48 -0
  233. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sse4_2_register.hpp +48 -0
  234. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_ssse3_register.hpp +48 -0
  235. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_sve_register.hpp +216 -0
  236. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_traits.hpp +409 -0
  237. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_utils.hpp +462 -0
  238. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vsx_register.hpp +84 -0
  239. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_vxe_register.hpp +86 -0
  240. package/third-party/common/phonemis/src/third-party/xsimd/types/xsimd_wasm_register.hpp +59 -0
  241. package/third-party/common/phonemis/src/third-party/xsimd/utils/bits.hpp +122 -0
  242. package/third-party/common/phonemis/src/third-party/xsimd/utils/xsimd_type_traits.hpp +145 -0
  243. package/third-party/common/phonemis/src/third-party/xsimd/xsimd.hpp +43 -0
  244. package/third-party/common/phonemis/src/phonemis/base/processor/constants.h +0 -11
  245. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/config.h +0 -16
  246. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.cpp +0 -271
  247. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/layer.h +0 -45
  248. package/third-party/common/phonemis/src/phonemis/base/processor/num2word/types.h +0 -29
  249. package/third-party/common/phonemis/src/phonemis/base/processor/sanitizer_layer.cpp +0 -22
  250. package/third-party/common/phonemis/src/phonemis/base/processor/trim_layer.cpp +0 -40
  251. 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 <phonemis/base/processor/constants.h>
4
- #include <phonemis/utils/conversions.h>
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 <algorithm>
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 phonemis::processor;
10
+ using namespace constants::num2word;
11
+ using namespace processor;
12
+ using namespace processor::num2word;
16
13
  using namespace utils;
17
14
 
18
- std::u32string Num2Word::to_cardinal_int(int32_t value) const {
19
- if (value < 0) {
20
- return U"minus " + to_cardinal_int(std::abs(value));
21
- }
15
+ namespace {
16
+ // Number words
22
17
 
23
- if (num2word::kCardinals.contains(static_cast<int>(value))) {
24
- return num2word::kCardinals.at(static_cast<int>(value));
18
+ std::u32string cardinal(uint64_t n) {
19
+ if (n < 20) {
20
+ return std::u32string(kOnes[n]);
25
21
  }
26
-
27
- if (value < 100) {
28
- int32_t tens = value / 10;
29
- int32_t units = value % 10;
30
- return num2word::kCardinals.at(tens * 10) + U" " + num2word::kCardinals.at(units);
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
- // Handle large numbers by iterating through the large scales map (hundred, thousand, etc.)
34
- // in descending order to find the largest applicable base.
35
- for (auto it = num2word::kLargeCardinals.rbegin(); it != num2word::kLargeCardinals.rend(); ++it) {
36
- int64_t base = it->first;
37
- if (static_cast<int64_t>(value) >= base) {
38
- int32_t high = value / static_cast<int32_t>(base);
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
- std::u32string res = to_cardinal_int(high) + U" " + it->second;
42
- if (low > 0) {
43
- // Use "and" for values below 100 as per English counting convention (e.g., "one hundred and five")
44
- std::u32string sep = (low < 100) ? U" and " : U", ";
45
- res += sep + to_cardinal_int(low);
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
- return res;
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
- // Fallback - return the number without verbalization.
53
- return conversions::utf8_to_u32(std::to_string(value));
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
- std::u32string Num2Word::to_cardinal_float(float value, std::u32string_view repr) const {
57
- if (value < 0.0f) {
58
- return U"minus " + to_cardinal_float(std::abs(value), repr);
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
- // Find dot (brak point) and split the float into 2 parts: integer part and fractional part.
62
- // We will handle both parts separately and concatenate the results.
63
- std::string tmp_str = conversions::u32_to_utf8(repr);
64
- auto rit = std::find_if(tmp_str.rbegin(), tmp_str.rend(),
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
- // Handle cases such as 5. - where float can be represented directly as an integer
69
- if (!value_str.empty() && value_str.back() == '.') {
70
- value_str.pop_back();
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
- size_t dot_pos = value_str.find('.');
74
- if (dot_pos == std::string::npos) {
75
- return to_cardinal_int(std::stoi(value_str));
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
- std::string integer_part_str = value_str.substr(0, dot_pos);
79
- std::string fractional_part_str = value_str.substr(dot_pos + 1);
80
-
81
- // Standard, cardinal verbalization of the integer part
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
- // Digit-by-digit verbalization of the fractional part.
86
- for (char c : fractional_part_str) {
87
- if (isdigit(static_cast<unsigned char>(c))) {
88
- res += U" " + to_cardinal_int(c - '0');
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
- return res;
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
- std::u32string Num2Word::to_ordinal_int(int32_t value, std::u32string_view suffix) const {
96
- // A helper function to create a proper suffix based on verbalized representation.
97
- auto get_ordinal_suffix_word = [](const std::u32string& word) -> std::u32string {
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
- std::u32string card = to_cardinal_int(value);
105
- std::vector<std::u32string> words = strings::split(card, U' ');
106
-
107
- if (words.empty()) {
108
- return card;
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
- std::u32string& last = words.back();
112
- size_t dash_pos = last.find(U'-');
113
- if (dash_pos != std::u32string::npos) {
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
- std::u32string res = words[0];
124
- for (size_t i = 1; i < words.size(); ++i) {
125
- res += U" " + words[i];
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 res;
174
+ return text.size() <= 2 ? cardinal(*n) : pairs(*n);
128
175
  }
129
176
 
130
- std::u32string Num2Word::to_currency(char32_t currency, std::variant<int32_t, float> number) const {
131
- if (!num2word::kCurrencies.contains(currency)) {
132
- return std::u32string(1, currency);
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
- std::u32string result = num2word::kCurrencies.at(currency);
136
-
137
- // Determine if the amount is singular (exactly 1) to decide on pluralization.
138
- // For floats, we use a small epsilon for comparison.
139
- bool is_singular = std::visit([](auto&& arg) -> bool {
140
- using T = std::decay_t<decltype(arg)>;
141
- if constexpr (std::is_same_v<T, int32_t>) {
142
- return arg == 1;
143
- } else {
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
- if (!is_singular) {
149
- result += U"s";
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
- return result;
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::to_month(uint32_t month) const {
156
- if (month >= 1 && month <= 12) {
157
- return num2word::kMonths[month];
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
- return U"";
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::to_year(uint32_t year) const {
164
- int32_t value = static_cast<int32_t>(year);
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
- int32_t high = value / 100;
168
- int32_t low = value % 100;
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
- if (high == 0 || (high % 10 == 0 && low < 10) || high >= 100) {
171
- return to_cardinal_int(value);
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
- std::u32string high_text = to_cardinal_int(high);
175
- std::u32string low_text = low == 0 ? U"hundred" :
176
- low < 10 ? U"oh-" + to_cardinal_int(low) :
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
- return high_text + U" " + low_text;
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
- bool Num2Word::is_ordinal_suffix(std::u32string_view suffix) const {
183
- return suffix == U"st" || suffix == U"nd" || suffix == U"rd" || suffix == U"th";
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::to_fraction(int32_t numerator, int32_t denominator) const {
187
- return to_cardinal_int(numerator) + U" " + to_ordinal_int(denominator);
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::to_day(uint32_t day) const {
191
- return to_ordinal_int(static_cast<int32_t>(day));
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
- class Num2Word : public processor::num2word::Num2WordLayer {
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
- using Num2WordLayer::Num2WordLayer;
13
-
14
- char32_t decimal_separator() const override { return U'.'; }
15
- std::u32string to_cardinal_int(int32_t number) const override;
16
- std::u32string to_cardinal_float(float number, std::u32string_view repr) const override;
17
- std::u32string to_ordinal_int(int32_t number, std::u32string_view suffix = U"") const override;
18
- std::u32string to_currency(char32_t currency, std::variant<int32_t, float> number) const override;
19
- std::u32string to_fraction(int32_t numerator, int32_t denominator) const override;
20
- std::u32string to_day(uint32_t day) const override;
21
- std::u32string to_month(uint32_t month) const override;
22
- std::u32string to_year(uint32_t year) const override;
23
- bool is_ordinal_suffix(std::u32string_view suffix) const override;
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_.add_layer(std::make_unique<processor::TrimLayer>());
31
- preprocessor_.add_layer(std::make_unique<Num2Word>());
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()) {