Skip to content

Error with definitions #20

@lrosique

Description

@lrosique

Hello,

for 373 words the parser is crashing in the "get_definitions" method : on row 235 it's written "while text.tag != 'ol'" but for these words text is None in the loop.

The bug :

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
d:\workspaces\peg_words\v2\check_dataframes.py in <module>
      113 page = wiktp.from_source("longouse")
----> 114 page = page.get_word_data["partOfSpeech"]

D:\dev\Python\Python387\lib\site-packages\wiktionnaireparser\parser.py in get_word_data(self)
     57             'title'       : self.get_title(),
     58             'etymologies' : self.get_etymology(),
---> 59             'partOfSpeech': self.get_parts_of_speech(),
     60         }
     61 

D:\dev\Python\Python387\lib\site-packages\wiktionnaireparser\parser.py in get_parts_of_speech(self)
    121         for section_name in sections:
    122             nice_section_name = self._real_section_name(section_name)
--> 123             parts_of_speech[nice_section_name] = self.get_definitions(section_name)
    124             # Translations ?
    125             if self._language == 'Français':

D:\dev\Python\Python387\lib\site-packages\wiktionnaireparser\parser.py in get_definitions(self, part_of_speech)
    233         text = self._query.find(part_of_speech)[0]
    234         text = text.getparent()
--> 235         while text.tag != 'ol':
    236             # ligne de forme
    237             if text.tag == 'p' or text.tag == 'span':

AttributeError: 'NoneType' object has no attribute 'tag'

Solution :

while text is not None and text.tag != 'ol':
...
if text is not None:
  for i, definition_bloc in enumerate(text.getchildren()):
...

Example with words not working :

  • longouse
  • lundi
  • maçonnes
  • légèrement
  • pauvrement
  • passaient
  • octaveur

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions