Add some more synonyms and ignore case when replacing synonyms

This commit is contained in:
Marco Castelluccio 2019-01-02 16:47:54 +01:00
Родитель 9fdf09d231
Коммит b4dd6acb75
2 изменённых файлов: 11 добавлений и 2 удалений

Просмотреть файл

@ -182,10 +182,15 @@ def cleanup_fileref(text):
def cleanup_synonyms(text):
synonyms = [('safemode', ['safe mode', 'safemode'])]
synonyms = [
('safemode', ['safemode', 'safe mode']),
('str', ['str', 'steps to reproduce', 'repro steps']),
('uaf', ['uaf', 'use after free', 'use-after-free']),
('asan', ['asan', 'address sanitizer']),
]
for synonym_group, synonym_list in synonyms:
text = re.sub('|'.join(synonym_list), synonym_group, text)
text = re.sub('|'.join(synonym_list), synonym_group, text, flags=re.IGNORECASE)
return text

Просмотреть файл

@ -28,6 +28,10 @@ def test_cleanup_fileref():
def test_cleanup_synonyms():
tests = [
('I was in safemode, but the problem occurred in safe mode too', 'I was in safemode, but the problem occurred in safemode too'),
('SAFE MODE or SAFEMODE?', 'safemode or safemode?'),
('are there str? steps to reproduce? repro steps?', 'are there str? str? str?'),
('this is a use-after-free, also called uaf, also called use after free', 'this is a uaf, also called uaf, also called uaf'),
('found via address sanitizer or asan', 'found via asan or asan'),
]
for orig_text, cleaned_text in tests:
assert bug_features.cleanup_synonyms(orig_text) == cleaned_text