Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions spacy/lang/yo/stop_words.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# stop words as whitespace-separated list.
# Source: https://raw.githubusercontent.com/dohliam/more-stoplists/master/yo/yo.txt
# Single-character fragments (bare combining marks, isolated consonants and
# vowels that do not occur as standalone words) were removed. See #14036.

STOP_WORDS = set(
"a an b bá bí bẹ̀rẹ̀ d e f fún fẹ́ g gbogbo i inú j jù jẹ jẹ́ k kan kì kí kò "
"l láti lè lọ m mi mo máa mọ̀ n ni náà ní nígbà nítorí nǹkan o p padà pé "
"púpọ̀ pẹ̀lú r rẹ̀ s sì sí sínú t ti tí u w wà wá wọn wọ́n y yìí à àti àwọn á "
"è é ì í ò òun ó ù ú ń ńlá ǹ ̀ ́ ̣ ṣ ṣe ṣé ṣùgbọ́n ẹ ẹmọ́ ọ ọjọ́ ọ̀pọ̀lọpọ̀".split()
)
"a an bá bí bẹ̀rẹ̀ fún fẹ́ gbogbo inú jù jẹ jẹ́ kan kì kí kò láti lè lọ m mi mo "
"máa mọ̀ n ni náà ní nígbà nítorí nǹkan o padà pé púpọ̀ pẹ̀lú rẹ̀ sì sí sínú ti "
"tí wà wá wọn wọ́n yìí àti àwọn á é í ò òun ó ú ń ńlá ǹ ṣe ṣé ṣùgbọ́n ẹ ẹmọ́ ọ "
"ọjọ́ ọ̀pọ̀lọpọ̀".split()
)
61 changes: 61 additions & 0 deletions spacy/tests/lang/yo/test_stop_words.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import unicodedata

import pytest

from spacy.lang.yo.stop_words import STOP_WORDS

# Fragments that are not standalone Yoruba words. See #14036.
FRAGMENTS = [
"b",
"d",
"f",
"g",
"j",
"k",
"l",
"p",
"r",
"s",
"t",
"w",
"y",
"\u1e63", # s with dot below
"e",
"i",
"u",
"\u00e0", # a with grave
"\u00e8", # e with grave
"\u00ec", # i with grave
"\u00f9", # u with grave
"\u0300", # bare combining grave
"\u0301", # bare combining acute
"\u0323", # bare combining dot below
]

# Single-character entries that are real Yoruba words.
SINGLE_CHAR_WORDS = [
"\u00f3", # he/she/it
"\u0144", # progressive marker
"\u00f2", # negation
"\u00ed", # object pronoun
]


def test_yo_stop_words_are_nfc():
for word in STOP_WORDS:
assert unicodedata.is_normalized("NFC", word), ascii(word)


def test_yo_stop_words_do_not_start_with_combining_mark():
for word in STOP_WORDS:
assert not unicodedata.combining(word[0]), ascii(word)


@pytest.mark.parametrize("fragment", FRAGMENTS)
def test_yo_stop_words_exclude_fragments(fragment):
assert fragment not in STOP_WORDS


@pytest.mark.parametrize("word", SINGLE_CHAR_WORDS)
def test_yo_stop_words_keep_single_char_words(word):
assert word in STOP_WORDS