Datasets:

Modalities:
Audio
Text
Formats:
parquet
Size:
< 1K
ArXiv:
DOI:
Libraries:
Datasets
pandas
jam-alt / tests /test_grammar.py
cifkao's picture
Add tests
70954e8
raw
history blame
1.03 kB
"""
Run through language tool, to get some hints.
"""
import logging
import langid
import language_tool_python
LOG = logging.getLogger(__name__)
def test_report_language_tool_warnings(lyrics):
lyrics_by_language = {}
for lyric, file in lyrics:
lang = langid.classify(lyric)[0]
if lang in {"en", "fr", "es", "de"}:
lyrics_by_language.setdefault(lang, []).append((lyric, file))
else:
LOG.warning(
f'Failed to correctly identify language of {file}. Guessed "{lang}". Skipping.'
)
for lang, lyrics_list in lyrics_by_language.items():
LOG.info(f'Checking lyrics in "{lang}" with language tool.')
tool = language_tool_python.LanguageTool(
lang, config={"disabledRuleIds": "GONNA,OUTTA,WANNA,GOTTA,Y_ALL"}
)
try:
for lyric, file in lyrics_list:
for match in tool.check(lyric):
LOG.warning(f"{file}: {match}")
finally:
tool.close()