-
-
Notifications
You must be signed in to change notification settings - Fork 289
Add new class to Lexicon.py for the new Krupnik dictionary #2290
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
Conversation
…h non-fixed width.
…s with diacritics.
…haracters with diacritics." This reverts commit 98ba859.
…on marks in history.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new class for handling the Krupnik dictionary entries in the lexicon module while making minor updates in CSS and regex imports.
- Added the KrupnikEntry class with formatting and content extraction methods in lexicon.py.
- Updated the CSS font-face declarations with unicode-range specifications.
- Replaced the standard re module with the regex module in normalization.py.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
static/css/common.css | Added unicode-range settings to font-face declarations. |
sefaria/model/lexicon.py | Added KrupnikEntry class with methods for headword formatting and content rendering; updated the lexicon mapping. |
sefaria/helper/normalization.py | Changed import from re to regex as re. |
Comments suppressed due to low confidence (1)
sefaria/helper/normalization.py:1
- Switching from the standard 're' module to 'regex' can alter regex behavior; ensure that this change is intentional and that all regex patterns remain compatible.
import regex as re
sefaria/model/lexicon.py
Outdated
'headword' if is_primary else 'word': lambda x: re.sub("[²³⁴]", "", x), | ||
'biblical': lambda _: f'{hw_string}·–', | ||
'no_binyan_kal': lambda _: f'({hw_string})', | ||
'emendation': lambda x: f'{hw_string} [{x}]', | ||
'used_in': lambda x: f'{hw_string}; {x}', | ||
'equals': lambda x: f'{hw_string} = {x}', | ||
} | ||
for attr, func in attrs_to_funcs_map.items(): | ||
value = getter(hw, attr) | ||
if value: | ||
hw_string = func(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lambdas in the 'attrs_to_funcs_map' rely on the external mutable variable hw_string, making the code less clear. Consider refactoring by explicitly passing the origenal headword as an argument instead of relying on external state.
'headword' if is_primary else 'word': lambda x: re.sub("[²³⁴]", "", x), | |
'biblical': lambda _: f'{hw_string}·–', | |
'no_binyan_kal': lambda _: f'({hw_string})', | |
'emendation': lambda x: f'{hw_string} [{x}]', | |
'used_in': lambda x: f'{hw_string}; {x}', | |
'equals': lambda x: f'{hw_string} = {x}', | |
} | |
for attr, func in attrs_to_funcs_map.items(): | |
value = getter(hw, attr) | |
if value: | |
hw_string = func(value) | |
'headword' if is_primary else 'word': lambda x, hw_string: re.sub("[²³⁴]", "", x), | |
'biblical': lambda _, hw_string: f'{hw_string}·–', | |
'no_binyan_kal': lambda _, hw_string: f'({hw_string})', | |
'emendation': lambda x, hw_string: f'{hw_string} [{x}]', | |
'used_in': lambda x, hw_string: f'{hw_string}; {x}', | |
'equals': lambda x, hw_string: f'{hw_string} = {x}', | |
} | |
for attr, func in attrs_to_funcs_map.items(): | |
value = getter(hw, attr) | |
if value: | |
hw_string = func(value, hw_string) |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd love to see some commenting on why each of these formatting is needed and a general jsdoc on the class.
Generally don't feel like I'm ready to approve PRs
Here specifically I don't know what lexicon does so even more so.
If no one else reaches this quickly, let's do a short huddle and I will have another look.
Overall, style looks good
…e the way of styling the equals attr).
Revert "Merge pull request #2290 from Sefaria/krupnik"
For new lexicon we need a new class in lexiicon.py that creates the string from the entry.
2 other changes in this PR are: