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

fix #572: [FR] Tweak handling of the 'composé de' template #617

Merged
merged 1 commit into from
Jan 19, 2021

Conversation

lasconic
Copy link
Collaborator

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Jan 17, 2021

Sourcery Code Quality Report

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

Quality metrics Before After Change
Complexity 17.31 🙂 16.43 🙂 -0.88 👍
Method Length 80.38 🙂 81.28 🙂 0.90 👎
Working memory 9.97 😞 9.73 🙂 -0.24 👍
Quality 56.27% 🙂 56.54% 🙂 0.27% 👍
Other metrics Before After Change
Lines 616 650 34
Changed files Quality Before Quality After Quality Change
wikidict/lang/fr/template_handlers.py 56.27% 🙂 56.54% 🙂 0.27% 👍

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

File Function Complexity Length Working Memory Quality Recommendation
wikidict/lang/fr/template_handlers.py render_compose_de 51 ⛔ 490 ⛔ 15 😞 12.05% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/fr/template_handlers.py render_etyl 17 🙂 161 😞 10 😞 46.13% 😞 Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/fr/template_handlers.py render_mot_valise 13 🙂 126 😞 10 😞 53.27% 🙂 Try splitting into smaller methods. Extract out complex expressions
wikidict/lang/fr/template_handlers.py render_cit_ref 10 🙂 169 😞 8 🙂 55.58% 🙂 Try splitting into smaller methods
wikidict/lang/fr/template_handlers.py render_agglutination 12 🙂 102 🙂 10 😞 57.22% 🙂 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!

Let us know what you think of it by mentioning @sourcery-ai in a comment.

b = b1 + b2 + b3 + b4
is_derived = b == "1000" or b == "0100" or b == "1020"

def word_tr_sens(w: str, tr: str, sens: str) -> str:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could be out of the render_compose_de function and be reused in other templates such as etyl.
However, it's a hack regarding the italic handling. The right way to do it it's to check if each char of the words are "Latin", "Common" or "Inherited" in the script ranges from https://fr.wiktionary.org/wiki/Module:donn%C3%A9es_Unicode/data/script_ranges

I tried another way in render_etyl but it's not working for d’ (not the apostrophe...)

@BoboTiG WDYT ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could move the function and handle unicode chars correctly, yes. It could be done in another PR to keep this one as-is (already quite complex).

Copy link
Owner

@BoboTiG BoboTiG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What an horrible template to handle :)

@lasconic
Copy link
Collaborator Author

Yes... it could be made more "python" I guess, but I also see some value in being close to the wikicode...

@BoboTiG
Copy link
Owner

BoboTiG commented Jan 18, 2021

I was not talking about the code ;)
But the model is doing so much stuff that handling it is quite ugly.

Anyway, good work 👍 :)

@BoboTiG BoboTiG merged commit 6f710a8 into BoboTiG:master Jan 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Tweak handling of the 'composé de' template
2 participants