wikipron 2.0.0__tar.gz → 2.2.0__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 (34) hide show
  1. {wikipron-2.0.0 → wikipron-2.2.0}/PKG-INFO +3 -15
  2. {wikipron-2.0.0 → wikipron-2.2.0}/README.md +2 -4
  3. {wikipron-2.0.0 → wikipron-2.2.0}/pyproject.toml +2 -3
  4. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/config.py +16 -3
  5. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/default.py +5 -1
  6. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/eng.py +5 -1
  7. wikipron-2.2.0/src/wikipron/extract/tha.py +33 -0
  8. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/vie.py +2 -2
  9. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/languagecodes.py +7 -0
  10. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/PKG-INFO +3 -15
  11. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/requires.txt +0 -11
  12. wikipron-2.0.0/src/wikipron/extract/tha.py +0 -20
  13. {wikipron-2.0.0 → wikipron-2.2.0}/LICENSE.txt +0 -0
  14. {wikipron-2.0.0 → wikipron-2.2.0}/setup.cfg +0 -0
  15. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/__init__.py +0 -0
  16. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/cli.py +0 -0
  17. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/__init__.py +0 -0
  18. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/blt.py +0 -0
  19. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/core.py +0 -0
  20. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/jpn.py +0 -0
  21. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/khb.py +0 -0
  22. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/khm.py +0 -0
  23. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/lat.py +0 -0
  24. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/shn.py +0 -0
  25. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/extract/zho.py +0 -0
  26. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/html_utils.py +0 -0
  27. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/py.typed +0 -0
  28. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/scrape.py +0 -0
  29. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron/typing.py +0 -0
  30. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/SOURCES.txt +0 -0
  31. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/dependency_links.txt +0 -0
  32. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/entry_points.txt +0 -0
  33. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/not-zip-safe +0 -0
  34. {wikipron-2.0.0 → wikipron-2.2.0}/src/wikipron.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wikipron
3
- Version: 2.0.0
3
+ Version: 2.2.0
4
4
  Summary: Scraping grapheme-to-phoneme data from Wiktionary
5
5
  Author-email: WikiPron authors <kylebgorman@gmail.com>
6
6
  License: Apache 2.0
@@ -30,16 +30,6 @@ Requires-Dist: regex>=2019.12.9
30
30
  Requires-Dist: requests>=2.32.3
31
31
  Requires-Dist: segments<3,>=2.2.0
32
32
  Requires-Dist: unicodedataplus>=15.0.0
33
- Provides-Extra: dev
34
- Requires-Dist: black; extra == "dev"
35
- Requires-Dist: build; extra == "dev"
36
- Requires-Dist: flake8; extra == "dev"
37
- Requires-Dist: mypy; extra == "dev"
38
- Requires-Dist: pytest; extra == "dev"
39
- Requires-Dist: setuptools; extra == "dev"
40
- Requires-Dist: twine; extra == "dev"
41
- Requires-Dist: types-lxml; extra == "dev"
42
- Requires-Dist: types-requests; extra == "dev"
43
33
  Dynamic: license-file
44
34
 
45
35
  # WikiPron
@@ -58,7 +48,7 @@ dictionaries mined using this tool.
58
48
 
59
49
  - [Command-line tool](#command-line-tool)
60
50
  - [Python API](#python-api)
61
- - [Data](#data)
51
+ - [Data](#data) of over 5 million word pronunciation pairs from 348 languages
62
52
  - [Models](#models)
63
53
  - [Development](#development)
64
54
 
@@ -174,9 +164,7 @@ for word, pron in wikipron.scrape(config):
174
164
 
175
165
  ## Data
176
166
 
177
- We also make available [a database of over 3 million word/pronunciation
178
- pairs](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using
179
- WikiPron.
167
+ We also make available [a database](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using WikiPron.
180
168
 
181
169
  ## Models
182
170
 
@@ -14,7 +14,7 @@ dictionaries mined using this tool.
14
14
 
15
15
  - [Command-line tool](#command-line-tool)
16
16
  - [Python API](#python-api)
17
- - [Data](#data)
17
+ - [Data](#data) of over 5 million word pronunciation pairs from 348 languages
18
18
  - [Models](#models)
19
19
  - [Development](#development)
20
20
 
@@ -130,9 +130,7 @@ for word, pron in wikipron.scrape(config):
130
130
 
131
131
  ## Data
132
132
 
133
- We also make available [a database of over 3 million word/pronunciation
134
- pairs](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using
135
- WikiPron.
133
+ We also make available [a database](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using WikiPron.
136
134
 
137
135
  ## Models
138
136
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wikipron"
7
- version = "2.0.0"
7
+ version = "2.2.0"
8
8
  description = "Scraping grapheme-to-phoneme data from Wiktionary"
9
9
  readme = "README.md"
10
10
  requires-python = ">= 3.11"
@@ -45,10 +45,9 @@ classifiers = [
45
45
  "Topic :: Text Processing :: Linguistic",
46
46
  ]
47
47
 
48
- [project.optional-dependencies]
48
+ [dependency-groups]
49
49
  dev = [
50
50
  'black',
51
- 'build',
52
51
  'flake8',
53
52
  'mypy',
54
53
  'pytest',
@@ -30,11 +30,24 @@ _PRON_XPATH_SELECTOR_TEMPLATE = """
30
30
  {dialect_selector}
31
31
  ]
32
32
  """
33
+ # A pronunciation <li>/<p> is kept for a dialect if a matching accent label
34
+ # (an <a> link, e.g. "US" -> American English) sits on the line itself or on an
35
+ # enclosing <li> (Wiktionary nests accent-specific prons under an accent
36
+ # header), or -- the "no accent" fallback -- if the line carries no linked
37
+ # accent label of its own (ignoring labels inside nested <li> sub-variants) and
38
+ # none on any ancestor <li>. That fallback keeps general prons whose only
39
+ # labels are non-accent qualifiers ("strong form", "weak form", "colloquial"),
40
+ # which are plain text rather than links. See GH-591 for the descendant-axis
41
+ # (.//) requirement.
33
42
  _DIALECT_XPATH_SELECTOR_TEMPLATE = (
34
43
  "and\n"
35
- ' (span[contains(@class, "ib-content")]//a[{dialects_text}]\n'
36
- ' or span[contains(@class, "ib-content") and ({dialects_text})]\n'
37
- ' or count(span[contains(@class, "ib-content")]) = 0)'
44
+ ' (.//span[contains(@class, "ib-content")]//a[{dialects_text}]\n'
45
+ ' or .//span[contains(@class, "ib-content") and ({dialects_text})]\n'
46
+ ' or ancestor::li//span[contains(@class, "ib-content")]//a[{dialects_text}]\n' # noqa: E501
47
+ ' or ancestor::li//span[contains(@class, "ib-content") and ({dialects_text})]\n' # noqa: E501
48
+ ' or (count(.//span[contains(@class, "ib-content")][.//a])\n'
49
+ ' - count(.//li//span[contains(@class, "ib-content")][.//a]) = 0\n'
50
+ ' and count(ancestor::li//span[contains(@class, "ib-content")][.//a]) = 0))' # noqa: E501
38
51
  )
39
52
  _PHONEMES_REGEX = r"/(.+?)/"
40
53
  _PHONES_REGEX = r"\[(.+?)\]"
@@ -12,7 +12,11 @@ if typing.TYPE_CHECKING:
12
12
  from wikipron.typing import Iterator, WordPronPair
13
13
 
14
14
 
15
- IPA_XPATH_SELECTOR = './/span[contains(@class, "IPA")]'
15
+ # Direct-child (not descendant) so a general-outer <li> does not also scoop the
16
+ # IPA of accent variants nested in sub-<li>s; each variant is matched on its
17
+ # own line. Matches the base selector, which likewise keys on a direct-child
18
+ # IPA.
19
+ IPA_XPATH_SELECTOR = 'span[contains(@class, "IPA")]'
16
20
 
17
21
 
18
22
  def _yield_phn(request: HTMLResponse, config: "Config") -> "Iterator[str]":
@@ -14,7 +14,11 @@ if typing.TYPE_CHECKING:
14
14
  from wikipron.typing import Iterator, WordPronPair
15
15
 
16
16
 
17
- IPA_XPATH_SELECTOR = './/span[contains(@class, "IPA")]'
17
+ # Direct-child (not descendant) so a general-outer <li> does not also scoop the
18
+ # IPA of accent variants nested in sub-<li>s; each variant is matched on its
19
+ # own line. Matches the base selector, which likewise keys on a direct-child
20
+ # IPA.
21
+ IPA_XPATH_SELECTOR = 'span[contains(@class, "IPA")]'
18
22
 
19
23
 
20
24
  def yield_eng_pron(request: HTMLResponse, config: "Config") -> "Iterator[str]":
@@ -0,0 +1,33 @@
1
+ """Word and pron extraction for Thai."""
2
+
3
+ import itertools
4
+ import typing
5
+
6
+ from wikipron.html_utils import HTMLResponse
7
+
8
+ from wikipron.extract.default import yield_pron
9
+
10
+ if typing.TYPE_CHECKING:
11
+ from wikipron.config import Config
12
+ from wikipron.typing import Iterator, WordPronPair
13
+
14
+
15
+ # Thai pronunciations now render inside a <table>: the IPA <span> lives in a
16
+ # <td> whose row's <th> carries the pronunciation-appendix/phonology anchor.
17
+ # Restrict to those rows so we scrape Thai only (other languages render
18
+ # Thai-script IPA on the same page).
19
+ _THAI_IPA_XPATH_SELECTOR = (
20
+ "//tr[.//sup/a["
21
+ '@title = "Appendix:Thai pronunciation" or '
22
+ '@title = "wikipedia:Thai phonology" or '
23
+ '@title = "w:Thai language"]]'
24
+ '//span[contains(@class, "IPA")]'
25
+ )
26
+
27
+
28
+ def extract_word_pron_thai(
29
+ word: str, request: HTMLResponse, config: "Config"
30
+ ) -> "Iterator[WordPronPair]":
31
+ words = itertools.repeat(word)
32
+ prons = yield_pron(request.html, _THAI_IPA_XPATH_SELECTOR, config)
33
+ yield from zip(words, prons)
@@ -22,8 +22,8 @@ _PRON_XPATH_SELECTOR_TEMPLATE = """
22
22
 
23
23
  _DIALECT_XPATH_SELECTOR_TEMPLATE = (
24
24
  "and\n"
25
- ' (span[contains(@class, "ib-content")]//a[{dialects_text}]\n'
26
- ' or count(span[contains(@class, "ib-content")]) = 0)'
25
+ ' (.//span[contains(@class, "ib-content")]//a[{dialects_text}]\n'
26
+ ' or count(.//span[contains(@class, "ib-content")]) = 0)'
27
27
  )
28
28
 
29
29
  if typing.TYPE_CHECKING:
@@ -326,6 +326,10 @@ LANGUAGE_CODES = {
326
326
  "bjb": "Barngarla",
327
327
  "barngarla": "Barngarla",
328
328
  "banggarla": "Barngarla",
329
+ # Blackfoot. Would be "Siksika" in ISO 639-3.
330
+ "bla": "Blackfoot",
331
+ "blackfoot": "Blackfoot",
332
+ "siksika": "Blackfoot",
329
333
  # Carpathian Rusyn. Would be "Rusyn" in ISO 639-3.
330
334
  "rue": "Carpathian Rusyn",
331
335
  "rusyn": "Carpathian Rusyn",
@@ -497,6 +501,9 @@ LANGUAGE_CODES = {
497
501
  "shi": "Tashelhit",
498
502
  "tashelhit": "Tashelhit",
499
503
  "tachelhit": "Tashelhit",
504
+ # Tewa. Would be "Tewa (USA)" in ISO 639-3.
505
+ "tew": "Tewa",
506
+ "tewa": "Tewa",
500
507
  # Tokelauan. Would be "Tokelau" in ISO 639-3.
501
508
  "tkl": "Tokelauan",
502
509
  "tokelauan": "Tokelauan",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: wikipron
3
- Version: 2.0.0
3
+ Version: 2.2.0
4
4
  Summary: Scraping grapheme-to-phoneme data from Wiktionary
5
5
  Author-email: WikiPron authors <kylebgorman@gmail.com>
6
6
  License: Apache 2.0
@@ -30,16 +30,6 @@ Requires-Dist: regex>=2019.12.9
30
30
  Requires-Dist: requests>=2.32.3
31
31
  Requires-Dist: segments<3,>=2.2.0
32
32
  Requires-Dist: unicodedataplus>=15.0.0
33
- Provides-Extra: dev
34
- Requires-Dist: black; extra == "dev"
35
- Requires-Dist: build; extra == "dev"
36
- Requires-Dist: flake8; extra == "dev"
37
- Requires-Dist: mypy; extra == "dev"
38
- Requires-Dist: pytest; extra == "dev"
39
- Requires-Dist: setuptools; extra == "dev"
40
- Requires-Dist: twine; extra == "dev"
41
- Requires-Dist: types-lxml; extra == "dev"
42
- Requires-Dist: types-requests; extra == "dev"
43
33
  Dynamic: license-file
44
34
 
45
35
  # WikiPron
@@ -58,7 +48,7 @@ dictionaries mined using this tool.
58
48
 
59
49
  - [Command-line tool](#command-line-tool)
60
50
  - [Python API](#python-api)
61
- - [Data](#data)
51
+ - [Data](#data) of over 5 million word pronunciation pairs from 348 languages
62
52
  - [Models](#models)
63
53
  - [Development](#development)
64
54
 
@@ -174,9 +164,7 @@ for word, pron in wikipron.scrape(config):
174
164
 
175
165
  ## Data
176
166
 
177
- We also make available [a database of over 3 million word/pronunciation
178
- pairs](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using
179
- WikiPron.
167
+ We also make available [a database](https://github.com/CUNY-CL/wikipron/tree/master/data) mined using WikiPron.
180
168
 
181
169
  ## Models
182
170
 
@@ -10,14 +10,3 @@ unicodedataplus>=15.0.0
10
10
 
11
11
  [:sys_platform == "linux"]
12
12
  pynini>=2.1.0
13
-
14
- [dev]
15
- black
16
- build
17
- flake8
18
- mypy
19
- pytest
20
- setuptools
21
- twine
22
- types-lxml
23
- types-requests
@@ -1,20 +0,0 @@
1
- """Word and pron extraction for Thai."""
2
-
3
- import itertools
4
- import typing
5
-
6
- from wikipron.html_utils import HTMLResponse
7
-
8
- from wikipron.extract.default import yield_pron, IPA_XPATH_SELECTOR
9
-
10
- if typing.TYPE_CHECKING:
11
- from wikipron.config import Config
12
- from wikipron.typing import Iterator, WordPronPair
13
-
14
-
15
- def extract_word_pron_thai(
16
- word: str, request: HTMLResponse, config: "Config"
17
- ) -> "Iterator[WordPronPair]":
18
- words = itertools.repeat(word)
19
- prons = yield_pron(request.html, IPA_XPATH_SELECTOR, config)
20
- yield from zip(words, prons)
File without changes
File without changes
File without changes
File without changes