scriptconv 0.0.4a148__tar.gz → 0.0.4a150__tar.gz

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 (209) hide show
  1. {scriptconv-0.0.4a148/scriptconv.egg-info → scriptconv-0.0.4a150}/PKG-INFO +1 -1
  2. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/pyproject.toml +2 -1
  3. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/frontend.py +2 -2
  4. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_identity_cache.py +5 -6
  5. scriptconv-0.0.4a150/scriptconv/phonemizers/_revision.py +387 -0
  6. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/espeak.py +9 -2
  7. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/base.py +8 -9
  8. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/version.py +1 -1
  9. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150/scriptconv.egg-info}/PKG-INFO +1 -1
  10. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend.py +1 -1
  11. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_identity_cache.py +5 -5
  12. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_openjtalk_engine.py +3 -2
  13. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_dizione.py +1 -1
  14. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_g2pw.py +1 -1
  15. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_identity.py +245 -239
  16. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_kolokwa.py +2 -2
  17. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_leokani.py +2 -2
  18. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_mwl_barranquenho.py +1 -1
  19. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_shami_digit_runs.py +49 -4
  20. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_tugaphone_identity_no_revision.py +1 -1
  21. scriptconv-0.0.4a148/scriptconv/phonemizers/_revision.py +0 -434
  22. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/LICENSE +0 -0
  23. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/README.md +0 -0
  24. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/__init__.py +0 -0
  25. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/__main__.py +0 -0
  26. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/cangjie.py +0 -0
  27. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/conventions.py +0 -0
  28. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/data/LICENSE.cangjie5 +0 -0
  29. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/data/__init__.py +0 -0
  30. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/data/cangjie5_tc.tsv.gz +0 -0
  31. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/diacritics.py +0 -0
  32. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/graph.py +0 -0
  33. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/notation.py +0 -0
  34. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/__init__.py +0 -0
  35. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_moved.py +0 -0
  36. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/LICENSE.f5tts +0 -0
  37. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/LICENSE.hangul_to_ipa +0 -0
  38. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/__init__.py +0 -0
  39. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/bw2ipa.py +0 -0
  40. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/LICENSE +0 -0
  41. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/UPSTREAM.md +0 -0
  42. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/__init__.py +0 -0
  43. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/__main__.py +0 -0
  44. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/align.py +0 -0
  45. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/LICENSE.cmudict +0 -0
  46. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/LICENSE.homograph-data +0 -0
  47. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/align.json +0 -0
  48. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/g2p.json +0 -0
  49. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/g2p.npz +0 -0
  50. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/homographs.json +0 -0
  51. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/lexicon.json +0 -0
  52. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/lexicon.tsv +0 -0
  53. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/built/sources.json +0 -0
  54. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/convert.py +0 -0
  55. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/abbreviations.txt +0 -0
  56. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/chat.txt +0 -0
  57. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/endings.txt +0 -0
  58. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/exceptions.txt +0 -0
  59. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/function_words.txt +0 -0
  60. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/homograph_fixes.txt +0 -0
  61. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/homograph_rules.txt +0 -0
  62. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/letters.txt +0 -0
  63. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/phrases.txt +0 -0
  64. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/data/units.txt +0 -0
  65. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/engine.py +0 -0
  66. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/g2p.py +0 -0
  67. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/homographs.py +0 -0
  68. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/morphology.py +0 -0
  69. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/normalize.py +0 -0
  70. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/sentence.py +0 -0
  71. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/symbols.py +0 -0
  72. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/dizione/tables.py +0 -0
  73. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/f5tts.py +0 -0
  74. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/g2pw/LICENSE +0 -0
  75. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/g2pw/__init__.py +0 -0
  76. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/g2pw/bert-base-chinese_s2t_dict.txt +0 -0
  77. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/g2pw/bopomofo_to_pinyin_wo_tune_dict.json +0 -0
  78. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/g2pw/char_bopomofo_dict.json +0 -0
  79. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/hangul2ipa.py +0 -0
  80. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/aspiration.csv +0 -0
  81. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/assimilation.csv +0 -0
  82. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/double_coda.csv +0 -0
  83. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/hanja.tsv +0 -0
  84. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/ipa.csv +0 -0
  85. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/neutralization.csv +0 -0
  86. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/tensification.csv +0 -0
  87. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/ko_tables/yale.csv +0 -0
  88. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/leokani/LICENSE +0 -0
  89. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/leokani/LICENSE-CC-BY-4.0.txt +0 -0
  90. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/leokani/NOTICE +0 -0
  91. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/leokani/__init__.py +0 -0
  92. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/leokani/leokani_g2p.py +0 -0
  93. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/nakdimon/LICENSE +0 -0
  94. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/nakdimon/__init__.py +0 -0
  95. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/__init__.py +0 -0
  96. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/codeswitch.py +0 -0
  97. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/diacritize.py +0 -0
  98. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/dialectal.py +0 -0
  99. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/english_g2p.py +0 -0
  100. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/frontend.py +0 -0
  101. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/levantine_g2p.py +0 -0
  102. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/normalize.py +0 -0
  103. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/shami/phoneme_inventory.py +0 -0
  104. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/vosk_g2p.py +0 -0
  105. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_thirdparty/zh_num.py +0 -0
  106. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_vendored/__init__.py +0 -0
  107. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_vendored/matoub_kab/LICENSE.md +0 -0
  108. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/_vendored/matoub_kab/__init__.py +0 -0
  109. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/africa.py +0 -0
  110. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ar.py +0 -0
  111. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ber.py +0 -0
  112. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/dizione.py +0 -0
  113. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/en.py +0 -0
  114. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/enums.py +0 -0
  115. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/eu.py +0 -0
  116. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/f5tts.py +0 -0
  117. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/fa.py +0 -0
  118. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/g2pw.py +0 -0
  119. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ghana.py +0 -0
  120. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/gl.py +0 -0
  121. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/he.py +0 -0
  122. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ja.py +0 -0
  123. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ko.py +0 -0
  124. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/leokani.py +0 -0
  125. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/lir.py +0 -0
  126. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/mul.py +0 -0
  127. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/mwl.py +0 -0
  128. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/o2ipa.py +0 -0
  129. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/openjtalk_engine.py +0 -0
  130. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/pt.py +0 -0
  131. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/registry.py +0 -0
  132. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/ru.py +0 -0
  133. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/shami.py +0 -0
  134. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/vi.py +0 -0
  135. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/phonemizers/zh.py +0 -0
  136. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/py.typed +0 -0
  137. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/readings.py +0 -0
  138. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/scripts.py +0 -0
  139. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/testing/__init__.py +0 -0
  140. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/testing/compare.py +0 -0
  141. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv/translit.py +0 -0
  142. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv.egg-info/SOURCES.txt +0 -0
  143. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv.egg-info/dependency_links.txt +0 -0
  144. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv.egg-info/requires.txt +0 -0
  145. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/scriptconv.egg-info/top_level.txt +0 -0
  146. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/setup.cfg +0 -0
  147. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_arabic_diacritics_routing.py +0 -0
  148. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_arpa_stress.py +0 -0
  149. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_backend_table.py +0 -0
  150. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_byt5_lang_prefix.py +0 -0
  151. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_cangjie.py +0 -0
  152. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_charsiu_match_tags.py +0 -0
  153. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_cli.py +0 -0
  154. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_conventions.py +0 -0
  155. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_core_imports.py +0 -0
  156. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_diacritics.py +0 -0
  157. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_diacritics_graph.py +0 -0
  158. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_diacritics_nakdimon.py +0 -0
  159. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_diacritics_nfd_letters.py +0 -0
  160. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_doc_pages.py +0 -0
  161. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_errors_policy.py +0 -0
  162. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_examples.py +0 -0
  163. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_chunks.py +0 -0
  164. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_join.py +0 -0
  165. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_order.py +0 -0
  166. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_phonemizer_lang.py +0 -0
  167. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_say_as.py +0 -0
  168. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_frontend_stage_edges.py +0 -0
  169. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_graph.py +0 -0
  170. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_graph_lossless.py +0 -0
  171. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_gruut_lexicon_cache.py +0 -0
  172. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_he_extra_declares_phonikud.py +0 -0
  173. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_lang_default_region.py +0 -0
  174. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_match_lang_direction.py +0 -0
  175. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_match_lang_preferred_value.py +0 -0
  176. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_notation.py +0 -0
  177. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_notation_sources.py +0 -0
  178. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_notation_strict.py +0 -0
  179. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_base.py +0 -0
  180. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_cjk_ar.py +0 -0
  181. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_copyleft_he_ja_th.py +0 -0
  182. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_dizione_long_tokens.py +0 -0
  183. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_epitran_english.py +0 -0
  184. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_epitran_japanese.py +0 -0
  185. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_epitran_korean.py +0 -0
  186. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_espeak_lt_accent.py +0 -0
  187. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_eu_euskaphone.py +0 -0
  188. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_f5tts.py +0 -0
  189. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_friendly_import_errors.py +0 -0
  190. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_goruut_marks.py +0 -0
  191. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_goruut_server.py +0 -0
  192. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_grapheme_arguments.py +0 -0
  193. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_marks.py +0 -0
  194. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_matoub_kab.py +0 -0
  195. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_o2i_lexicons.py +0 -0
  196. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_phonetisaurus.py +0 -0
  197. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_phonetisaurus_engine.py +0 -0
  198. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_pt_tugaphone.py +0 -0
  199. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_punctuation.py +0 -0
  200. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_ru.py +0 -0
  201. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_phonemizers_shami_inventory.py +0 -0
  202. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_readings_zh.py +0 -0
  203. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_scripts.py +0 -0
  204. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_scripts_stressonnx_compat.py +0 -0
  205. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_sister_packages.py +0 -0
  206. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_stress_marks.py +0 -0
  207. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_testing_compare.py +0 -0
  208. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_translit.py +0 -0
  209. {scriptconv-0.0.4a148 → scriptconv-0.0.4a150}/tests/test_wheel_licences.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv
3
- Version: 0.0.4a148
3
+ Version: 0.0.4a150
4
4
  Summary: The one stop for text conversion: a zero-dependency script & phoneme-notation core — ISO-15924 detection & metadata, IPA↔ARPABET/X-SAMPA/Lexique/Kirshenbaum/Cotovía/RFE, Buckwalter↔Arabic, Hangul→jamo, kana — with phonemizer integrations behind optional extras
5
5
  License-Expression: Apache-2.0 AND MIT AND LicenseRef-CMUdict
6
6
  Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
@@ -99,5 +99,6 @@ scriptconv = ["py.typed"]
99
99
 
100
100
  [tool.pytest.ini_options]
101
101
  testpaths = ["tests"]
102
- # A test that hangs fails after this many seconds. The slowest test took 31.8 s at load average 45 to 67.
102
+ # A test that hangs fails after this many seconds. The slowest test, 40,000 digits through espeak-ng,
103
+ # took 49.7 s at load average 31 to 35.
103
104
  timeout = 150
@@ -687,7 +687,7 @@ class TextFrontend:
687
687
  def identity(self) -> PhonemizerIdentity:
688
688
  """What phonemizes this frontend's language, with :data:`FRONTEND_VERSION`.
689
689
 
690
- ``revision`` is ``sc1:`` and a hash of the backend's revision, of the
690
+ ``revision`` is ``sc2:`` and a hash of the backend's revision, of the
691
691
  code of the scriptconv modules that the frontend loads, of the stage
692
692
  settings and of ``text2spoken.revision`` when the normaliser is
693
693
  :func:`spoken_normalizer`. It is ``None``, so a ``version`` difference
@@ -697,7 +697,7 @@ class TextFrontend:
697
697
 
698
698
  An identity with a ``revision`` is kept on disk, as
699
699
  :mod:`scriptconv.phonemizers._identity_cache` describes, so a later
700
- process reads it back with no probe and no call into the backend.
700
+ process reads it back with no hash and no call into the backend.
701
701
  """
702
702
  from scriptconv.phonemizers import _identity_cache
703
703
  stages = self._resolve(None)
@@ -1,9 +1,9 @@
1
1
  """A disk cache for :meth:`~scriptconv.frontend.TextFrontend.identity`.
2
2
 
3
- The first ``identity()`` of a frontend runs the revision probes, which take
4
- seconds. The cache keeps the result in a JSON file under the user cache
5
- directory, so a later process reads it back in a few milliseconds, with no
6
- probe and no call into the backend.
3
+ The first ``identity()`` of a frontend hashes the source of each scriptconv
4
+ module on its path and reads the revision of its engine. The cache keeps the
5
+ result in a JSON file under the user cache directory, so a later process reads
6
+ it back with no hash and no call into the backend.
7
7
 
8
8
  An entry is found by a hash of its key: the interpreter path and version,
9
9
  the ``sys.path`` entries, :data:`unicodedata.unidata_version`, the backend
@@ -23,8 +23,7 @@ computed. A hit needs each of them to be the same:
23
23
  such as a checkout on ``PYTHONPATH`` or the target of a ``.pth`` file, and
24
24
  the project of each editable install. A file counts by its size and
25
25
  modification time, a directory by its names. Each of them is watched,
26
- whether or not this process loads it, because a revision probe can load
27
- what the process that writes the entry does not;
26
+ whether or not this process loads it;
28
27
  - the source file of each class of the backend outside scriptconv.
29
28
 
30
29
  A directory counts by its names and not by its modification time, so the
@@ -0,0 +1,387 @@
1
+ """The ``revision`` of a backend: a hash of the code and data on its path and of the releases under it.
2
+
3
+ The hash covers:
4
+
5
+ - the code tokens of each module of scriptconv, scriptconv-copyleft or
6
+ scriptconv-nonfree that the backend class imports, directly or through
7
+ another such module, and of their parent packages, except a ``version.py``
8
+ at the top of a package. The imports are read from the source, those inside
9
+ functions too, so a module counts whether or not a call reaches it;
10
+ - the bytes of each other file in the directory of such a module, and in each
11
+ directory under it that is not a package, as the tables of a vendored engine.
12
+ A package that loads only as the parent of such a module adds no files;
13
+ - the name and version of each installed distribution that the ``phonemizers``
14
+ extra and the extra of the backend require, with the engine distribution, at
15
+ any depth. The engine counts with its extra named by the language, when it
16
+ has one, as ``gruut[fr]`` for ``fr``. A requirement counts when its PEP 508
17
+ marker holds here, so a requirement under an extra that nobody asks for, or
18
+ for another platform, does not;
19
+ - the name and version of each installed distribution that provides a module
20
+ that the modules above import at module level, in a ``try`` block or not, as
21
+ num2words for the Shami normaliser. The requirements of such a distribution
22
+ do not count. A distribution that these modules import only inside a
23
+ function does not count, unless an extra above requires it. So an optional
24
+ tool that a backend loads inside a function, as the camel-tools diacritizer
25
+ of the Shami backend, is not in the revision;
26
+ - scriptconv and its sister packages count by their files instead of their
27
+ version, and the distributions of
28
+ :meth:`~scriptconv.phonemizers.base.BasePhonemizer._covered_distributions`
29
+ count by the engine revision or version in the settings;
30
+ - the source file of each class in the MRO of the backend outside these packages;
31
+ - the class of the backend, the arguments that build it, the settings that
32
+ change the output besides the code, whether the backend keeps clause
33
+ punctuation, the language and :data:`unicodedata.unidata_version`.
34
+
35
+ With *frontend*, the modules that :mod:`scriptconv.frontend` imports count too.
36
+
37
+ A code token is any token but a comment, a blank line or a string that stands
38
+ as a statement, as a docstring does. So a release that changes code or data on
39
+ the path of the backend changes the revision, and a release that changes only
40
+ docs, ``version.py`` or the modules and data of other backends keeps it. A
41
+ release of a distribution above changes it. A release of any other
42
+ distribution keeps it, also when the backend imports that distribution inside
43
+ a function, or loads it at run time through a name that is not in its source.
44
+
45
+ Nothing of the running process counts: neither the modules it loaded, nor its
46
+ working directory, nor a package that loads at startup. Two machines with the
47
+ same packages give the same revision. An edit of a dependency's files that
48
+ keeps its version, as in an editable install, keeps the revision.
49
+
50
+ A module of these packages that does not load from a file in a directory, as
51
+ from a zip archive, or a scriptconv with no installed metadata, gives no
52
+ revision and one warning per backend, language and error in a process.
53
+ """
54
+ import ast
55
+ import functools
56
+ import hashlib
57
+ import inspect
58
+ import io
59
+ import json
60
+ import logging
61
+ import os
62
+ import platform
63
+ import re
64
+ import sys
65
+ import tokenize
66
+ import unicodedata
67
+ from importlib import metadata
68
+ from importlib.util import find_spec
69
+ from pathlib import Path
70
+ from typing import Collection, Dict, FrozenSet, Iterator, List, Mapping, Optional, Set, Tuple
71
+
72
+ LOG = logging.getLogger(__name__)
73
+
74
+ FORMAT = "sc2"
75
+ """The prefix of a revision. It changes when the inputs or the encoding of the hash change."""
76
+
77
+ _NOT_CODE = frozenset({tokenize.COMMENT, tokenize.NL, tokenize.ENCODING, tokenize.ENDMARKER})
78
+ _LINE = frozenset({"NEWLINE", "INDENT", "DEDENT"})
79
+ #: The packages whose files the hash holds.
80
+ _IN_TREE = frozenset({"scriptconv", "scriptconv_copyleft", "scriptconv_nonfree"})
81
+ _IN_TREE_DISTRIBUTIONS = frozenset({"scriptconv", "scriptconv-copyleft", "scriptconv-nonfree"})
82
+ _REQUIREMENT = re.compile(r"\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*(?:\[([^\]]*)\])?[^;]*(?:;(.*))?")
83
+ _COMPARISON = re.compile(r"""(\w+|"[^"]*"|'[^']*')\s*(===|==|!=|~=|<=|>=|<|>|not\s+in\b|in\b)\s*(\w+|"[^"]*"|'[^']*')""")
84
+ _VERSION = re.compile(r"\d+(?:\.\d+)*")
85
+ #: The values of the PEP 508 marker variables in this interpreter.
86
+ _ENVIRONMENT = {
87
+ "implementation_name": sys.implementation.name,
88
+ "implementation_version": platform.python_version() if sys.implementation.name == "cpython"
89
+ else ".".join(map(str, sys.implementation.version[:3])),
90
+ "os_name": os.name, "platform_machine": platform.machine(), "platform_release": platform.release(),
91
+ "platform_system": platform.system(), "platform_version": platform.version(),
92
+ "platform_python_implementation": platform.python_implementation(),
93
+ "python_full_version": platform.python_version(), "python_version": "%s.%s" % sys.version_info[:2],
94
+ "sys_platform": sys.platform,
95
+ }
96
+
97
+
98
+ class RevisionSourceUnavailable(OSError):
99
+ """A module or package on the path of a backend has no source file in a directory to hash."""
100
+
101
+
102
+ def _source_file(where, what: str) -> Path:
103
+ """*where* as a path, when it is a file in a directory."""
104
+ path = Path(where) if where else None
105
+ if path is None or not path.is_file():
106
+ raise RevisionSourceUnavailable(f"{what} does not load from a file in a directory: {where}")
107
+ return path
108
+
109
+
110
+ def code_revision(backend, lang: str, settings: Mapping, frontend: bool = False) -> Optional[str]:
111
+ """The revision of *backend* for *lang*, or ``None`` when its code cannot be read.
112
+
113
+ *settings* are values besides the code that change the output; they join
114
+ the hash. With *frontend*, the modules of :mod:`scriptconv.frontend` count too.
115
+ """
116
+ in_tree = [cls for cls in type(backend).__mro__ if cls.__module__.partition(".")[0] in _IN_TREE]
117
+ if inspect.isabstract(in_tree[0]):
118
+ # a backend class from elsewhere on BasePhonemizer itself, which says nothing of its path
119
+ return None
120
+ roots = {cls.__module__ for cls in in_tree} | ({"scriptconv.frontend"} if frontend else set())
121
+ try:
122
+ classes = [(cls.__module__, file_digest(_source_file(inspect.getsourcefile(cls), f"the class {cls.__qualname__}")))
123
+ for cls in type(backend).__mro__
124
+ if cls.__module__ not in ("builtins", "abc") and cls not in in_tree]
125
+ files, outside = _path(frozenset(roots))
126
+ extras = {"phonemizers", _extra(type(backend))} - {None}
127
+ roots_of_releases = [("scriptconv", frozenset(extras))]
128
+ imported = {name for top in outside for name in _top_level_distributions().get(top, ())}
129
+ if backend.engine_distribution is not None:
130
+ # an engine extra named by the language, as gruut[fr], holds the data of that language
131
+ language = _canonical(lang)
132
+ roots_of_releases.append((backend.engine_distribution,
133
+ frozenset({language, language.partition("-")[0]})))
134
+ covered = {_canonical(name) for name in backend._covered_distributions(lang)}
135
+ hashed = [FORMAT, "frontend" if frontend else "backend",
136
+ f"{type(backend).__module__}:{type(backend).__qualname__}", lang,
137
+ backend._revision_arguments(), settings, backend._keeps_punctuation(),
138
+ unicodedata.unidata_version, files, classes,
139
+ _releases(roots_of_releases, covered, imported)]
140
+ except (OSError, SyntaxError, ValueError, KeyError, TypeError, metadata.PackageNotFoundError) as exc:
141
+ _warn_once(type(backend).__name__, lang, f"{type(exc).__name__}: {exc}")
142
+ return None
143
+ digest = hashlib.sha256(json.dumps(hashed, sort_keys=True, ensure_ascii=False).encode())
144
+ return f"{FORMAT}:{digest.hexdigest()}"
145
+
146
+
147
+ @functools.lru_cache(maxsize=None)
148
+ def _warn_once(backend: str, lang: str, error: str) -> None:
149
+ """Logs that the identity of *backend* for *lang* has no revision, once per *error* in this process."""
150
+ LOG.warning("the identity of %s for %r has no revision: %s", backend, lang, error)
151
+
152
+
153
+ def _extra(backend_class) -> Optional[str]:
154
+ """The scriptconv extra that installs the first registered class in the MRO of *backend_class*."""
155
+ from scriptconv.phonemizers.registry import PHONEMIZER_REGISTRY
156
+ extras = {cls_name: extra for _, cls_name, extra in PHONEMIZER_REGISTRY.values()}
157
+ return next((extras[cls.__name__] for cls in backend_class.__mro__ if cls.__name__ in extras), None)
158
+
159
+
160
+ def _canonical(name: str) -> str:
161
+ """The normalised name of a distribution or an extra, as PEP 503 and PEP 685 give it."""
162
+ return re.sub(r"[-_.]+", "-", name).lower()
163
+
164
+
165
+ @functools.lru_cache(maxsize=None)
166
+ def _top_level_distributions() -> Mapping[str, List[str]]:
167
+ """The installed distributions that provide each top-level module."""
168
+ return metadata.packages_distributions()
169
+
170
+
171
+ @functools.lru_cache(maxsize=None)
172
+ def _path(roots: FrozenSet[str]) -> Tuple[List[Tuple[str, str]], FrozenSet[str]]:
173
+ """The path and digest of each file of the packages in :data:`_IN_TREE` on the import path of *roots*,
174
+ and the top-level name of each other module that these files import at module level."""
175
+ modules: Dict[str, Path] = {}
176
+ imported = set(roots)
177
+ outside: Set[str] = set()
178
+ pending = list(roots)
179
+ while pending:
180
+ name = pending.pop()
181
+ if name in modules:
182
+ continue
183
+ path = _module_file(name)
184
+ if path is None:
185
+ # a name imported from a module, as GraphemePhonemizer in "from scriptconv.phonemizers import ..."
186
+ continue
187
+ modules[name] = path
188
+ package = name if path.name == "__init__.py" else name.rpartition(".")[0]
189
+ pending.extend(package.rsplit(".", depth)[0] for depth in range(package.count(".") + 1))
190
+ for module, names, module_level in _imported(path, package):
191
+ top = module.partition(".")[0]
192
+ if top not in _IN_TREE:
193
+ # an import inside a function serves another language, or a dependency that an extra declares
194
+ if module_level:
195
+ outside.add(top)
196
+ continue
197
+ submodules = [f"{module}.{name}" for name in names]
198
+ pending.append(module)
199
+ pending.extend(submodules)
200
+ imported.update(submodules)
201
+ # "from package import module" loads the package only as a parent
202
+ if not names or not all(map(_module_file, submodules)):
203
+ imported.add(module)
204
+ sites = {name.partition(".")[0]: path.parents[name.count(".") + (path.name == "__init__.py")]
205
+ for name, path in modules.items()}
206
+ files = {(name.partition(".")[0], path) for name, path in modules.items()}
207
+ # a package that loads only as the parent of an imported module, as _thirdparty, adds no data files
208
+ files |= {(name.partition(".")[0], data) for name, path in modules.items() if name in imported
209
+ for data in _data_files(path.parent)}
210
+ entries = []
211
+ for top, path in files:
212
+ relative = path.relative_to(sites[top]).as_posix()
213
+ if relative != f"{top}/version.py":
214
+ entries.append((relative, file_digest(path)))
215
+ return sorted(entries), frozenset(outside)
216
+
217
+
218
+ def _module_file(name: str) -> Optional[Path]:
219
+ """The source file of the module *name*, or ``None`` when *name* is no installed module."""
220
+ top, _, rest = name.partition(".")
221
+ spec = find_spec(top)
222
+ if spec is None:
223
+ return None
224
+ locations = spec.submodule_search_locations or []
225
+ if not locations or not all(Path(location).is_dir() for location in locations):
226
+ raise RevisionSourceUnavailable(f"the package {top} does not load from a directory: {spec.origin}")
227
+ for location in locations:
228
+ base = Path(location).joinpath(*rest.split(".")) if rest else Path(location)
229
+ for path in (base / "__init__.py", base.with_name(base.name + ".py")):
230
+ if path.is_file():
231
+ return path
232
+ return None
233
+
234
+
235
+ def _imported(path: Path, package: str) -> Iterator[Tuple[str, Tuple[str, ...], bool]]:
236
+ """Each module that the source at *path*, a module of *package*, may import, with the names it imports from it,
237
+ and whether the import runs at module level, that is outside any function."""
238
+ pending: List[Tuple[ast.AST, bool]] = [(ast.parse(path.read_bytes()), True)]
239
+ while pending:
240
+ node, module_level = pending.pop()
241
+ if isinstance(node, ast.Import):
242
+ yield from ((alias.name, (), module_level) for alias in node.names)
243
+ elif isinstance(node, ast.ImportFrom):
244
+ module = node.module or ""
245
+ if node.level:
246
+ parent = package.rsplit(".", node.level - 1)[0]
247
+ module = f"{parent}.{module}" if module else parent
248
+ yield module, tuple(alias.name for alias in node.names), module_level
249
+ else:
250
+ inner = module_level and not isinstance(node, (ast.FunctionDef, ast.AsyncFunctionDef))
251
+ # an import is a statement, so the walk skips expressions
252
+ pending.extend((child, inner) for child in ast.iter_child_nodes(node)
253
+ if isinstance(child, (ast.stmt, ast.excepthandler, ast.match_case)))
254
+
255
+
256
+ def _data_files(directory: Path) -> Iterator[Path]:
257
+ """The files of *directory* that are not Python, and each file under it outside a package."""
258
+ for path in directory.iterdir():
259
+ if path.is_file() and path.suffix not in (".py", ".pyc"):
260
+ yield path
261
+ elif path.is_dir() and path.name != "__pycache__" and not (path / "__init__.py").exists():
262
+ yield from (child for child in path.rglob("*")
263
+ if child.is_file() and "__pycache__" not in child.parts and child.suffix != ".pyc")
264
+
265
+
266
+ def _releases(roots: List[Tuple[str, FrozenSet[str]]], covered: Collection[str],
267
+ imported: Collection[str] = ()) -> List[str]:
268
+ """``name==version`` of each installed distribution that *roots*, as (distribution, extras), require at any depth,
269
+ and of each distribution in *imported*, without its requirements.
270
+
271
+ A distribution that is not installed, as an optional engine or a binary,
272
+ adds nothing. The distributions of :data:`_IN_TREE_DISTRIBUTIONS` and
273
+ *covered* stay out, and their requirements count.
274
+ """
275
+ found: Dict[str, str] = {}
276
+ for name in imported:
277
+ try:
278
+ found[_canonical(name)] = metadata.distribution(name).version
279
+ except metadata.PackageNotFoundError:
280
+ continue
281
+ seen: Set[Tuple[str, str]] = set()
282
+ pending = [(name, extra) for name, extras in roots for extra in ("", *extras)]
283
+ while pending:
284
+ name, extra = pending.pop()
285
+ key = (_canonical(name), _canonical(extra))
286
+ if key in seen:
287
+ continue
288
+ seen.add(key)
289
+ try:
290
+ distribution = metadata.distribution(name)
291
+ except metadata.PackageNotFoundError:
292
+ if key[0] == "scriptconv":
293
+ raise
294
+ continue
295
+ found[key[0]] = distribution.version
296
+ for requirement in distribution.requires or ():
297
+ required, extras, marker = _REQUIREMENT.match(requirement).groups()
298
+ if marker is None or _marker_holds(marker, key[1]):
299
+ pending.extend((required, extra) for extra in ("", *(extras or "").replace(" ", "").split(",")))
300
+ return sorted(f"{name}=={version}" for name, version in found.items()
301
+ if name not in _IN_TREE_DISTRIBUTIONS and name not in covered)
302
+
303
+
304
+ def _marker_holds(marker: str, extra: str) -> bool:
305
+ """Whether the PEP 508 environment *marker* holds in this interpreter, with *extra* asked for."""
306
+ environment = {**_ENVIRONMENT, "extra": extra}
307
+
308
+ def compare(match: re.Match) -> str:
309
+ left, right = (side[1:-1] if side[0] in "\"'" else environment[side] for side in (match[1], match[3]))
310
+ operator = " ".join(match[2].split())
311
+ if "extra" in (match[1], match[3]):
312
+ left, right = _canonical(left), _canonical(right)
313
+ if operator in ("in", "not in"):
314
+ return str((left in right) == (operator == "in"))
315
+ if operator != "===" and _VERSION.fullmatch(left) and _VERSION.fullmatch(right):
316
+ given = [int(part) for part in right.split(".")]
317
+ width = max(left.count("."), right.count(".")) + 1
318
+ left, right = ([*map(int, value.split(".")), *[0] * width][:width] for value in (left, right))
319
+ if operator == "~=":
320
+ return str(left >= right and left[:len(given) - 1] == given[:-1])
321
+ return str({"===": left == right, "==": left == right, "!=": left != right, "<": left < right,
322
+ "<=": left <= right, ">": left > right, ">=": left >= right, "~=": left >= right}[operator])
323
+
324
+ expression = _COMPARISON.sub(compare, marker)
325
+ if not re.fullmatch(r"(?:\s|\(|\)|True|False|and|or)*", expression):
326
+ raise ValueError(f"a requirement marker that PEP 508 does not allow: {marker}")
327
+ return eval(expression, {"__builtins__": {}})
328
+
329
+
330
+ @functools.lru_cache(maxsize=None)
331
+ def file_digest(path: Path) -> str:
332
+ """The sha256 of the code tokens of a Python module, or of the bytes of any other file."""
333
+ data = path.read_bytes()
334
+ if path.suffix == ".py":
335
+ try:
336
+ data = json.dumps(code_tokens(data), ensure_ascii=False).encode()
337
+ except (SyntaxError, tokenize.TokenError, UnicodeDecodeError):
338
+ pass
339
+ return hashlib.sha256(data).hexdigest()
340
+
341
+
342
+ def code_tokens(source: bytes) -> List[Tuple[str, str]]:
343
+ """The tokens of a module that can change what it does.
344
+
345
+ Comments, blank lines and strings that stand as statements, as docstrings
346
+ do, are left out. NEWLINE, INDENT and DEDENT count with an empty string, so
347
+ the width of an indent does not count. An f-string is one token with its
348
+ source text, so the tokens are the same on each Python version.
349
+ """
350
+ encoding, _ = tokenize.detect_encoding(io.BytesIO(source).readline)
351
+ lines = io.StringIO(source.decode(encoding), newline="\n").readlines()
352
+ tokens: List[Tuple[str, str]] = []
353
+ depth, start = 0, (0, 0)
354
+ for token in tokenize.tokenize(io.BytesIO(source).readline):
355
+ kind = tokenize.tok_name[token.type]
356
+ if kind in ("FSTRING_START", "TSTRING_START"):
357
+ depth, start = depth + 1, start if depth else token.start
358
+ elif kind in ("FSTRING_END", "TSTRING_END"):
359
+ depth -= 1
360
+ if not depth:
361
+ tokens.append(("STRING", _source_text(lines, start, token.end)))
362
+ elif not depth and token.type not in _NOT_CODE:
363
+ tokens.append((kind, "" if kind in _LINE else token.string))
364
+ return _without_string_statements(tokens)
365
+
366
+
367
+ def _source_text(lines: List[str], start: Tuple[int, int], end: Tuple[int, int]) -> str:
368
+ (first, first_column), (last, last_column) = start, end
369
+ if first == last:
370
+ return lines[first - 1][first_column:last_column]
371
+ return lines[first - 1][first_column:] + "".join(lines[first:last - 1]) + lines[last - 1][:last_column]
372
+
373
+
374
+ def _without_string_statements(tokens: List[Tuple[str, str]]) -> List[Tuple[str, str]]:
375
+ kept: List[Tuple[str, str]] = []
376
+ at = 0
377
+ while at < len(tokens):
378
+ end = at
379
+ while end < len(tokens) and tokens[end][0] == "STRING":
380
+ end += 1
381
+ starts_line = not kept or kept[-1][0] in _LINE
382
+ if end > at and starts_line and (end == len(tokens) or tokens[end][0] == "NEWLINE"):
383
+ at = end + 1
384
+ continue
385
+ kept.extend(tokens[at:max(end, at + 1)])
386
+ at = max(end, at + 1)
387
+ return kept
@@ -17,6 +17,12 @@ _ESPEAK = shutil.which("espeak-ng") or shutil.which("espeak")
17
17
  _PAREN = re.compile(r"\([^)]*\)")
18
18
  _ZW = dict.fromkeys(map(ord, "‍‌​"), None)
19
19
 
20
+ # espeak-ng time grows with the text: about 150 microseconds per UTF-8 byte at
21
+ # load 35 on an 8-core laptop. The allowance is four times that rate, for a box
22
+ # at load 50 and above. The base bounds a binary that hangs on a short text.
23
+ _TIMEOUT_BASE = 30
24
+ _TIMEOUT_PER_BYTE = 4 * 150e-6
25
+
20
26
 
21
27
  def available() -> bool:
22
28
  return _ESPEAK is not None
@@ -35,14 +41,15 @@ def phonemize(text: str, voice: str = "en-us") -> str:
35
41
  return ""
36
42
  # The text goes on stdin, because Linux refuses one argument longer than
37
43
  # 128 KiB. Without the final newline, espeak-ng drops the end of the last word.
44
+ data = text + "\n"
38
45
  proc = subprocess.run(
39
46
  [_ESPEAK, "-v", voice, "--ipa=1", "-q", "--stdin"],
40
- input=text + "\n",
47
+ input=data,
41
48
  capture_output=True,
42
49
  text=True,
43
50
  encoding="utf-8",
44
51
  errors="replace",
45
- timeout=30,
52
+ timeout=_TIMEOUT_BASE + _TIMEOUT_PER_BYTE * len(data.encode("utf-8", "replace")),
46
53
  )
47
54
  raw = proc.stdout or ""
48
55
  raw = _PAREN.sub(" ", raw).translate(_ZW)
@@ -236,7 +236,7 @@ class PhonemizerIdentity:
236
236
 
237
237
  Its meaning depends on :attr:`frontend`. With ``frontend`` ``None``, a
238
238
  backend called directly, it is the backend's own revision. With
239
- ``frontend`` set, it is the frontend revision with the ``sc1:`` prefix.
239
+ ``frontend`` set, it is the frontend revision with the ``sc2:`` prefix.
240
240
  That revision covers the backend revision plus the frontend stage modules
241
241
  and output settings, and text2spoken's revision when the normaliser is
242
242
  :func:`~scriptconv.frontend.spoken_normalizer`. It is ``None`` when the
@@ -728,8 +728,7 @@ class BasePhonemizer(metaclass=abc.ABCMeta):
728
728
  return "scriptconv", VERSION_STR
729
729
 
730
730
  def _revision_arguments(self) -> Dict[str, object]:
731
- """The constructor arguments, as JSON values, that rebuild this backend
732
- in the probe of :func:`~scriptconv.phonemizers._revision.code_revision`."""
731
+ """The constructor arguments, as JSON values, that change the output. They join the revision."""
733
732
  return {}
734
733
 
735
734
  def _identity_settings(self) -> Dict[str, object]:
@@ -740,9 +739,9 @@ class BasePhonemizer(metaclass=abc.ABCMeta):
740
739
 
741
740
  def _covered_distributions(self, lang: str) -> FrozenSet[str]:
742
741
  """The distributions whose own revision, or version, the identity of
743
- this backend holds for *lang*. The probe of
742
+ this backend holds for *lang*.
744
743
  :func:`~scriptconv.phonemizers._revision.code_revision` leaves their
745
- files out of the hash. For an engine outside scriptconv it is the
744
+ versions out of the hash. For an engine outside scriptconv it is the
746
745
  engine's distribution, whose version :meth:`identity` puts in the settings."""
747
746
  if self.engine_distribution is None:
748
747
  return frozenset()
@@ -755,10 +754,10 @@ class BasePhonemizer(metaclass=abc.ABCMeta):
755
754
  backend, as :func:`~scriptconv.phonemizers._revision.code_revision`
756
755
  gives it, with :meth:`_identity_settings` in the settings. For an
757
756
  engine outside scriptconv, the settings also hold the engine's
758
- distribution and version, and the files of that distribution leave
759
- the hash. So a change of the scriptconv code on the path, as
760
- ``base.py``, ``diacritics.py`` or the sentence splitter, changes the
761
- revision, and so does an engine release.
757
+ distribution and version. So a change of the scriptconv code on the
758
+ path, as ``base.py`` or ``diacritics.py``, changes the revision, and
759
+ so does a release of the engine or of a distribution under it, as the
760
+ sentence splitter.
762
761
 
763
762
  Raises:
764
763
  ImportError: If the engine is not installed.
@@ -2,7 +2,7 @@
2
2
  VERSION_MAJOR = 0
3
3
  VERSION_MINOR = 0
4
4
  VERSION_BUILD = 4
5
- VERSION_ALPHA = 148
5
+ VERSION_ALPHA = 150
6
6
  # END_VERSION_BLOCK
7
7
 
8
8
  VERSION_STR = f"{VERSION_MAJOR}.{VERSION_MINOR}.{VERSION_BUILD}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: scriptconv
3
- Version: 0.0.4a148
3
+ Version: 0.0.4a150
4
4
  Summary: The one stop for text conversion: a zero-dependency script & phoneme-notation core — ISO-15924 detection & metadata, IPA↔ARPABET/X-SAMPA/Lexique/Kirshenbaum/Cotovía/RFE, Buckwalter↔Arabic, Hangul→jamo, kana — with phonemizer integrations behind optional extras
5
5
  License-Expression: Apache-2.0 AND MIT AND LicenseRef-CMUdict
6
6
  Project-URL: Homepage, https://github.com/TigreGotico/scriptconv
@@ -1045,7 +1045,7 @@ class TestBackends:
1045
1045
  def test_identity_names_the_backend_and_the_language(self):
1046
1046
  frontend = TextFrontend(FrontendConfig("pt-PT", Phonemizer.UNICODE))
1047
1047
  identity = frontend.identity()
1048
- assert identity.revision.startswith("sc1:")
1048
+ assert identity.revision.startswith("sc2:")
1049
1049
  assert identity.revision != UnicodeCodepointPhonemizer().identity("pt-PT").revision
1050
1050
  assert identity == PhonemizerIdentity(
1051
1051
  "unicode", "scriptconv", VERSION_STR, "pt-PT", identity.revision, frontend_module.FRONTEND_VERSION)
@@ -272,7 +272,7 @@ class TestEntries:
272
272
  import sys
273
273
  from scriptconv.phonemizers import GraphemePhonemizer, PhonemizerIdentity, _identity_cache
274
274
  key = {"writer": "test"}
275
- identity = PhonemizerIdentity("graphemes", "scriptconv", "1", "pt-PT", "sc1:" + sys.argv[1] * 64, 2)
275
+ identity = PhonemizerIdentity("graphemes", "scriptconv", "1", "pt-PT", "sc2:" + sys.argv[1] * 64, 2)
276
276
  state = _identity_cache.snapshot(GraphemePhonemizer())
277
277
  for _ in range(40):
278
278
  _identity_cache.store(key, identity, state)
@@ -293,7 +293,7 @@ class TestEntries:
293
293
  entries = list(_identity_cache.cache_dir().iterdir())
294
294
  assert len(entries) == 1 and entries[0].suffix == ".json"
295
295
  entry = json.loads(entries[0].read_text())
296
- assert entry["identity"]["revision"] in ("sc1:" + "1" * 64, "sc1:" + "2" * 64)
296
+ assert entry["identity"]["revision"] in ("sc2:" + "1" * 64, "sc2:" + "2" * 64)
297
297
  assert _identity_cache.load({"writer": "test"}) == PhonemizerIdentity(**entry["identity"])
298
298
 
299
299
 
@@ -306,8 +306,8 @@ if sys.argv[1] == "hit":
306
306
  import text2spoken
307
307
  from scriptconv.phonemizers import _revision
308
308
  def refuse(*args, **kwargs):
309
- raise AssertionError("a hit runs no probe and does not call the backend")
310
- _revision._run_probe = text2spoken.revision = TugaphonePhonemizer.identity = refuse
309
+ raise AssertionError("a hit computes no revision and does not call the backend")
310
+ _revision.code_revision = text2spoken.revision = TugaphonePhonemizer.identity = refuse
311
311
  started = time.perf_counter()
312
312
  identity = frontend.identity()
313
313
  print(json.dumps({"revision": identity.revision, "seconds": time.perf_counter() - started}))
@@ -325,6 +325,6 @@ def test_a_hit_for_a_tugaphone_frontend_with_the_text2spoken_hook_costs_under_50
325
325
  miss = run("miss")
326
326
  hits = [run("hit") for _ in range(3)]
327
327
  print("miss", miss["seconds"], "hits", [hit["seconds"] for hit in hits])
328
- assert miss["revision"] is not None and miss["revision"].startswith("sc1:")
328
+ assert miss["revision"] is not None and miss["revision"].startswith("sc2:")
329
329
  assert all(hit["revision"] == miss["revision"] for hit in hits)
330
330
  assert min(hit["seconds"] for hit in hits) < 0.05
@@ -55,12 +55,13 @@ def both_installed(tmp_path, monkeypatch):
55
55
  def install(owner: str, order: list[str]):
56
56
  module_file.write_bytes(contents[owner])
57
57
  dists = {name: SimpleNamespace(files=[SimpleNamespace(hash=_record_hash(contents[name]),
58
- locate=lambda: module_file)])
58
+ locate=lambda: module_file)],
59
+ version=VERSIONS[name], requires=None)
59
60
  for name in VERSIONS}
60
61
  monkeypatch.setattr(pyopenjtalk, "__file__", str(module_file))
61
62
  monkeypatch.setattr(pyopenjtalk, "OPEN_JTALK_DICT_DIR", str(module_file.parent / "dictionary").encode())
62
63
  monkeypatch.setattr(metadata, "packages_distributions", lambda: {"pyopenjtalk": order})
63
- # Other names reach the real metadata: the identity probe reads the versions of every module it loads.
64
+ # Other names reach the real metadata: the revision reads the version of each distribution under the backend.
64
65
  real_distribution, real_version = metadata.distribution, metadata.version
65
66
  monkeypatch.setattr(metadata, "distribution", lambda name: dists[name] if name in dists else real_distribution(name))
66
67
  monkeypatch.setattr(metadata, "version", lambda name: VERSIONS[name] if name in VERSIONS else real_version(name))
@@ -264,7 +264,7 @@ class TestIdentity:
264
264
  assert (identity.backend, identity.lang) == ("dizione", "en-US")
265
265
  assert dizione.identity(data_dir)["fingerprint"] == \
266
266
  "f41b6f9dac16c0b3ac492e255fcbebf6b73f737b20a62dfba7576ceb208f9190"
267
- assert identity.revision.startswith("sc1:")
267
+ assert identity.revision.startswith("sc2:")
268
268
  other = DizionePhonemizer(data_dir=data_dir)
269
269
  other.__dict__["fingerprint"] = "another build"
270
270
  assert other.identity("en-US").revision != identity.revision
@@ -288,7 +288,7 @@ def test_another_language_is_refused(g2pw):
288
288
  def test_the_identity_names_scriptconv(g2pw):
289
289
  identity = g2pw.identity("zh-CN")
290
290
  assert identity == PhonemizerIdentity("g2pw", "scriptconv", VERSION_STR, "zh", revision=identity.revision)
291
- assert identity.revision.startswith("sc1:")
291
+ assert identity.revision.startswith("sc2:")
292
292
 
293
293
 
294
294
  def test_a_missing_package_names_the_extra():