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

Add "alternative_spellings" property + minor bug fix for words with alternative spellings in title #147

Merged
merged 17 commits into from
Oct 11, 2021

Conversation

VIEWVIEWVIEW
Copy link
Contributor

@VIEWVIEWVIEW VIEWVIEWVIEW commented Oct 7, 2021

#146

  • Fixed crash on "name" property
  • Fixed crash on "article" property
  • Added alternative spelling property
  • Add test for word "Meme"
  • Update rest of tests with alternative_spelling property

@radomirbosak
Copy link
Owner

radomirbosak commented Oct 10, 2021

Thank you again for your pull request! Sorry for the late reply. Let me quickly review the code.

Copy link
Owner

@radomirbosak radomirbosak left a comment

Choose a reason for hiding this comment

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

Please try running make check and looking at the issues reported.
autopep8 and flake8 reports some issues:

$ make check
...
flake8 --builtins="_" --max-line-length 99 duden/ tests/
duden/word.py:61:72: W291 trailing whitespace
duden/word.py:62:1: W293 blank line contains whitespace
duden/word.py:103:74: W291 trailing whitespace
duden/word.py:111:43: E203 whitespace before ','
duden/display.py:157:89: W292 no newline at end of file

Makefile Outdated
./run_duden.py --export Keyboard > tests/test_data/Keyboard.yaml
./run_duden.py --export Meme > tests/test_data/Meme.yaml

Copy link
Owner

Choose a reason for hiding this comment

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

This is a triviality, there's an extra tab at the end of the file. Ideally, the file would end with a single newline.

duden/display.py Outdated
@@ -152,3 +152,6 @@ def describe_word(word):
for part_of_speech, words in word.compounds.items():
print(blue(' - {}:'.format(part_of_speech.capitalize())),
', '.join(words))

if word.alternative_spellings:
print(white(_('Alternative_spellings:'), bold=True), word.alternative_spellings)
Copy link
Owner

Choose a reason for hiding this comment

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

This is supposed to be human-readable string, so 'Alternative spellings:' without underscore should be better. Also could you add a newline at the end of the file?

duden/word.py Outdated Show resolved Hide resolved
duden/word.py Outdated
article_element = self.soup.find('span', {"class": "lemma__determiner"})
if article_element is not None:
# remove soft hyphens "\xad" and return
return article_element.get_text().replace('\xad', '').strip()
Copy link
Owner

Choose a reason for hiding this comment

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

Reusing the clear_text function from common.py would reduce code duplication.

Suggested change
return article_element.get_text().replace('\xad', '').strip()
return clear_text(article_element.get_text())

duden/word.py Outdated Show resolved Hide resolved
@VIEWVIEWVIEW
Copy link
Contributor Author

I apologize for the many small mistakes, it's my first time working with python and initially I didn't get the linter to work (on windows). Thank you for staying kind :)

I think, this is it. If you want anything else changed, let me know!

Copy link
Owner

@radomirbosak radomirbosak left a comment

Choose a reason for hiding this comment

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

That's perfect! Thank you for making these changes.

I apologize for the many small mistakes, it's my first time working with python and initially I didn't get the linter to work (on windows). Thank you for staying kind :)

No worries. I'm not exactly sure if the linters work on Windows or not since I have no way of testing it.

I added one more comment.

duden/word.py Outdated
article_element = self.soup.find('span', {"class": "lemma__determiner"})
if article_element is not None:
# remove soft hyphens "\xad" and return
return article_element.get_text().replace('\xad', '').strip()
Copy link
Owner

Choose a reason for hiding this comment

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

clear_text can be used here as well

Copy link
Owner

@radomirbosak radomirbosak left a comment

Choose a reason for hiding this comment

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

Looks good! Thank you :)

@radomirbosak radomirbosak merged commit a85055e into radomirbosak:master Oct 11, 2021
@radomirbosak
Copy link
Owner

radomirbosak commented Oct 11, 2021

duden 0.16.0 is out and available on pypi supporting alternative_spellings 🎉

to upgrade:

pip3 install --user --upgrade duden

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.

2 participants