scriptconv 0.0.4a147__tar.gz → 0.0.4a149__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.
- {scriptconv-0.0.4a147/scriptconv.egg-info → scriptconv-0.0.4a149}/PKG-INFO +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/frontend.py +2 -2
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_identity_cache.py +5 -6
- scriptconv-0.0.4a149/scriptconv/phonemizers/_revision.py +387 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/espeak.py +4 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/base.py +8 -9
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/version.py +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149/scriptconv.egg-info}/PKG-INFO +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend.py +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_identity_cache.py +5 -5
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_openjtalk_engine.py +3 -2
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_dizione.py +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_g2pw.py +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_identity.py +245 -239
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_kolokwa.py +2 -2
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_leokani.py +2 -2
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_mwl_barranquenho.py +1 -1
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_shami_digit_runs.py +43 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_tugaphone_identity_no_revision.py +1 -1
- scriptconv-0.0.4a147/scriptconv/phonemizers/_revision.py +0 -434
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/LICENSE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/README.md +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/pyproject.toml +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/__main__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/cangjie.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/conventions.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/data/LICENSE.cangjie5 +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/data/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/data/cangjie5_tc.tsv.gz +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/diacritics.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/graph.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/notation.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_moved.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/LICENSE.f5tts +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/LICENSE.hangul_to_ipa +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/bw2ipa.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/LICENSE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/UPSTREAM.md +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/__main__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/align.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/LICENSE.cmudict +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/LICENSE.homograph-data +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/align.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/g2p.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/g2p.npz +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/homographs.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/lexicon.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/lexicon.tsv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/built/sources.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/convert.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/abbreviations.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/chat.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/endings.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/exceptions.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/function_words.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/homograph_fixes.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/homograph_rules.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/letters.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/phrases.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/data/units.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/engine.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/g2p.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/homographs.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/morphology.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/normalize.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/sentence.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/symbols.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/dizione/tables.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/f5tts.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/g2pw/LICENSE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/g2pw/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/g2pw/bert-base-chinese_s2t_dict.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/g2pw/bopomofo_to_pinyin_wo_tune_dict.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/g2pw/char_bopomofo_dict.json +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/hangul2ipa.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/aspiration.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/assimilation.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/double_coda.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/hanja.tsv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/ipa.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/neutralization.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/tensification.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/ko_tables/yale.csv +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/leokani/LICENSE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/leokani/LICENSE-CC-BY-4.0.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/leokani/NOTICE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/leokani/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/leokani/leokani_g2p.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/nakdimon/LICENSE +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/nakdimon/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/codeswitch.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/diacritize.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/dialectal.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/english_g2p.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/frontend.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/levantine_g2p.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/normalize.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/phoneme_inventory.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/vosk_g2p.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/zh_num.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_vendored/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_vendored/matoub_kab/LICENSE.md +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_vendored/matoub_kab/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/africa.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ar.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ber.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/dizione.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/en.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/enums.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/eu.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/f5tts.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/fa.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/g2pw.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ghana.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/gl.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/he.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ja.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ko.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/leokani.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/lir.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/mul.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/mwl.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/o2ipa.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/openjtalk_engine.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/pt.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/registry.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/ru.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/shami.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/vi.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/zh.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/py.typed +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/readings.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/scripts.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/testing/__init__.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/testing/compare.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/translit.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv.egg-info/SOURCES.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv.egg-info/dependency_links.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv.egg-info/requires.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv.egg-info/top_level.txt +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/setup.cfg +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_arabic_diacritics_routing.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_arpa_stress.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_backend_table.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_byt5_lang_prefix.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_cangjie.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_charsiu_match_tags.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_cli.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_conventions.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_core_imports.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_diacritics.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_diacritics_graph.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_diacritics_nakdimon.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_diacritics_nfd_letters.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_doc_pages.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_errors_policy.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_examples.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_chunks.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_join.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_order.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_phonemizer_lang.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_say_as.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_frontend_stage_edges.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_graph.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_graph_lossless.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_gruut_lexicon_cache.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_he_extra_declares_phonikud.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_lang_default_region.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_match_lang_direction.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_match_lang_preferred_value.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_notation.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_notation_sources.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_notation_strict.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_base.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_cjk_ar.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_copyleft_he_ja_th.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_dizione_long_tokens.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_epitran_english.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_epitran_japanese.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_epitran_korean.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_espeak_lt_accent.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_eu_euskaphone.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_f5tts.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_friendly_import_errors.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_goruut_marks.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_goruut_server.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_grapheme_arguments.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_marks.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_matoub_kab.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_o2i_lexicons.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_phonetisaurus.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_phonetisaurus_engine.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_pt_tugaphone.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_punctuation.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_ru.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_phonemizers_shami_inventory.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_readings_zh.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_scripts.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_scripts_stressonnx_compat.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_sister_packages.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_stress_marks.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_testing_compare.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/tests/test_translit.py +0 -0
- {scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/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.
|
|
3
|
+
Version: 0.0.4a149
|
|
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
|
|
@@ -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 ``
|
|
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
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
|
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
|
{scriptconv-0.0.4a147 → scriptconv-0.0.4a149}/scriptconv/phonemizers/_thirdparty/shami/espeak.py
RENAMED
|
@@ -33,8 +33,11 @@ def phonemize(text: str, voice: str = "en-us") -> str:
|
|
|
33
33
|
raise RuntimeError("espeak-ng not found on PATH")
|
|
34
34
|
if not text.strip():
|
|
35
35
|
return ""
|
|
36
|
+
# The text goes on stdin, because Linux refuses one argument longer than
|
|
37
|
+
# 128 KiB. Without the final newline, espeak-ng drops the end of the last word.
|
|
36
38
|
proc = subprocess.run(
|
|
37
|
-
[_ESPEAK, "-v", voice, "--ipa=1", "-q", "--"
|
|
39
|
+
[_ESPEAK, "-v", voice, "--ipa=1", "-q", "--stdin"],
|
|
40
|
+
input=text + "\n",
|
|
38
41
|
capture_output=True,
|
|
39
42
|
text=True,
|
|
40
43
|
encoding="utf-8",
|
|
@@ -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 ``
|
|
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
|
|
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*.
|
|
742
|
+
this backend holds for *lang*.
|
|
744
743
|
:func:`~scriptconv.phonemizers._revision.code_revision` leaves their
|
|
745
|
-
|
|
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
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
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.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scriptconv
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.4a149
|
|
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("
|
|
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", "
|
|
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 ("
|
|
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
|
|
310
|
-
_revision.
|
|
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("
|
|
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
|
|
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("
|
|
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("
|
|
291
|
+
assert identity.revision.startswith("sc2:")
|
|
292
292
|
|
|
293
293
|
|
|
294
294
|
def test_a_missing_package_names_the_extra():
|