Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def synonyms(self):
"""
Return the structure with word synonyms
"""
try:
section = self.soup.find('div', id='synonyme')
section = copy.copy(section)
if section.header:
section.header.extract()
return recursively_extract(section, maxdepth=2,
exfun=lambda x: x.text.strip())
except AttributeError:
return None
# 1. remove examples
for dl_node in section.find_all('dl', class_='note'):
if True or dl_node.dt.text == 'Beispiele':
dl_node.extract()
# 2. remove grammar parts
for dl_node in section.find_all('dl', class_='tuple'):
if dl_node.dt.text in ['Grammatik', 'Gebrauch']:
dl_node.extract()
# 3. remove pictures
for node in section.find_all('figure'):
node.extract()
return recursively_extract(
section, maxdepth=2, exfun=lambda x: x.text.strip())