Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pronunciations refactoring #1377

Merged
merged 2 commits into from
Sep 3, 2022
Merged

Pronunciations refactoring #1377

merged 2 commits into from
Sep 3, 2022

Conversation

BoboTiG
Copy link
Owner

@BoboTiG BoboTiG commented Sep 2, 2022

Fixes #1174.

I reviewed completely how pronunciations were retrieved in order to tackle that task, including changing where pronunciations were looked for: before we were using the whole word wikicode, now we only use head_sections wikicode (faster, and more efficient).

It has the following nice side-effects (on top the having local-specific formatting like \...\ for French, [...] for German, etc.):

  • EN, FR: now supports multiple cross-sections pronunciations (like ones from Middle English combined to ones from Old English sections, for instance on English data)
  • FR: pronunciations outside the French section are no more taken into account (like using values from Gaulois or other locale sections, that was incorrect)
  • PT: a lot more pronunciations are correctly found now
  • SV: multiple pronunciations are now supported
  • RU: it will be way easier to tackle [RU] Decode pronunciations #1376 then

I reviewed completely how pronunciations were retrieved in order
to tackle that task, including changing where pronunciations were
looked for: before we were using the whole word wikicode, now we
only use `head_sections` wikicode (faster, and more efficient).

It has the following nice side-effects (on top the having
local-specific formatting like `\...\` for French, `[...]` for German, etc.):

- `EN`, `FR`: now supports multiple cross-sections pronunciations
  (like ones from Middle English combined to ones from Old English
  sections, for instance on English data)
- `FR`: pronunciations outside the French section are no more taken
  into account (like using values from Gaulois or other locale sections,
  that was incorrect)
- `PT`: a lot more pronunciations are correctly found now
- `SV`: multiple pronunciations are now supported
- `RU`: it will be way easier to tackle #1376 then
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Sep 2, 2022

Sourcery Code Quality Report

✅  Merging this PR will increase code quality in the affected files by 0.72%.

Quality metrics Before After Change
Complexity 23.45 😞 22.85 😞 -0.60 👍
Method Length 132.36 😞 123.98 😞 -8.38 👍
Working memory 10.61 😞 10.57 😞 -0.04 👍
Quality 46.72% 😞 47.44% 😞 0.72% 👍
Other metrics Before After Change
Lines 6190 6401 211
Changed files Quality Before Quality After Quality Change
tests/test_2_render.py 89.42% ⭐ 89.84% ⭐ 0.42% 👍
tests/test_ca.py 61.41% 🙂 66.47% 🙂 5.06% 👍
tests/test_de.py 71.80% 🙂 74.87% 🙂 3.07% 👍
tests/test_el.py 74.94% 🙂 77.55% ⭐ 2.61% 👍
tests/test_en.py 62.91% 🙂 67.56% 🙂 4.65% 👍
tests/test_es.py 61.46% 🙂 66.72% 🙂 5.26% 👍
tests/test_fr.py 53.21% 🙂 59.42% 🙂 6.21% 👍
tests/test_it.py 75.58% ⭐ 78.42% ⭐ 2.84% 👍
tests/test_pt.py 64.69% 🙂 69.22% 🙂 4.53% 👍
tests/test_ru.py 70.04% 🙂 73.68% 🙂 3.64% 👍
tests/test_sv.py 78.53% ⭐ 81.28% ⭐ 2.75% 👍
wikidict/find_templates.py 50.33% 🙂 51.18% 🙂 0.85% 👍
wikidict/render.py 38.63% 😞 37.74% 😞 -0.89% 👎
wikidict/stubs.py 75.97% ⭐ 75.24% ⭐ -0.73% 👎
wikidict/utils.py 66.93% 🙂 66.95% 🙂 0.02% 👍
wikidict/lang/init.py 79.35% ⭐ 79.80% ⭐ 0.45% 👍
wikidict/lang/defaults.py 65.47% 🙂 64.99% 🙂 -0.48% 👎
wikidict/lang/ca/init.py 18.85% ⛔ 19.26% ⛔ 0.41% 👍
wikidict/lang/de/init.py 66.24% 🙂 64.95% 🙂 -1.29% 👎
wikidict/lang/el/init.py 74.98% 🙂 73.01% 🙂 -1.97% 👎
wikidict/lang/en/init.py 19.38% ⛔ 23.96% ⛔ 4.58% 👍
wikidict/lang/es/init.py 26.51% 😞 26.44% 😞 -0.07% 👎
wikidict/lang/fr/init.py 17.00% ⛔ 20.62% ⛔ 3.62% 👍
wikidict/lang/it/init.py 85.80% ⭐ 83.75% ⭐ -2.05% 👎
wikidict/lang/no/init.py 94.23% ⭐ 96.18% ⭐ 1.95% 👍
wikidict/lang/pt/init.py 18.75% ⛔ 19.01% ⛔ 0.26% 👍
wikidict/lang/ru/init.py 89.37% ⭐ 87.49% ⭐ -1.88% 👎
wikidict/lang/sv/init.py 48.99% 😞 48.90% 😞 -0.09% 👎

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
wikidict/lang/en/init.py last_template_handler 63 ⛔ 397 ⛔ 25 ⛔ 4.77% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/ca/init.py last_template_handler 53 ⛔ 479 ⛔ 4.90% ⛔ Refactor to reduce nesting. Try splitting into smaller methods
wikidict/lang/pt/init.py last_template_handler 58 ⛔ 528 ⛔ 22 ⛔ 5.41% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/fr/init.py last_template_handler 64 ⛔ 573 ⛔ 18 ⛔ 7.19% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/es/init.py last_template_handler 37 ⛔ 294 ⛔ 25 ⛔ 12.13% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

  • ⭐ excellent
  • 🙂 good
  • 😞 poor
  • ⛔ very poor

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

@BoboTiG BoboTiG merged commit b9d3031 into master Sep 3, 2022
@BoboTiG BoboTiG deleted the fix-1174 branch September 3, 2022 05:57
@BoboTiG BoboTiG mentioned this pull request Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pronunciation output: "colon space" before, "\" and other issues.
2 participants