Exit loop if found

main
Bob Mottram 2022-07-05 17:24:47 +01:00
parent 8101835c05
commit 2048670417
1 changed files with 2 additions and 0 deletions

View File

@ -1023,6 +1023,7 @@ def _get_simplified_content(content: str) -> str:
def detect_dogwhistles(content: str, dogwhistles: {}) -> {}: def detect_dogwhistles(content: str, dogwhistles: {}) -> {}:
"""Returns a dict containing any detected dogwhistle words """Returns a dict containing any detected dogwhistle words
""" """
content = remove_html(content)
result = {} result = {}
words = _get_simplified_content(content).split(' ') words = _get_simplified_content(content).split(' ')
for whistle, category in dogwhistles.items(): for whistle, category in dogwhistles.items():
@ -1078,6 +1079,7 @@ def detect_dogwhistles(content: str, dogwhistles: {}) -> {}:
} }
else: else:
result[whistle]['count'] += 1 result[whistle]['count'] += 1
break
return result return result