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

Handle words without grammar information #120

Merged
merged 1 commit into from
Jan 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion duden/word.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def grammar_raw(self):
"""
section = self.soup.find('div', id='grammatik')
if not section:
return None
return []

table_nodes = self.soup.find_all('div', class_='wrap-table') \
+ self.soup.find_all('table', class_='mere-table')
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/Qat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ word_separation:
meaning_overview: null
origin: null
compounds: null
grammar_raw: null
grammar_raw: []
synonyms: null
words_before:
- q, Q
Expand Down
2 changes: 1 addition & 1 deletion tests/test_data/einfach.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ compounds:
- passen
- stimmen
- werden
grammar_raw: null
grammar_raw: []
synonyms:
- einmal, nicht doppelt, nicht mehrfachbequem
words_before:
Expand Down
5 changes: 5 additions & 0 deletions tests/test_online_attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,8 @@ def test_word_grammar(parsed_word, expected_dict):
for tags, string in expected_grammar]

assert parsed_word.grammar_raw == expected_grammar

def test_empty_grammar():
word = get("Wahlbeobachter")
assert word.grammar_raw == []
assert word.grammar() == []