Skip to content

Commit

Permalink
add exception for i in multi-lang check
Browse files Browse the repository at this point in the history
  • Loading branch information
umputun committed Jun 23, 2024
1 parent 71637ab commit 2c0b0ae
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/tgspam/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,8 @@ func (d *Detector) isMultiLang(msg string) spamcheck.Response {
scripts := make(map[string]bool)
for _, r := range word {
switch {
case r == 'i': // skip 'i' because it's used in many languages
continue
case unicode.Is(unicode.Latin, r):
scripts["Latin"] = true
case unicode.Is(unicode.Cyrillic, r):
Expand Down
1 change: 1 addition & 0 deletions lib/tgspam/detector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,7 @@ func TestDetector_CheckMultiLang(t *testing.T) {
{"WithCyrillic real example 1", "Ищем заинтeрeсoвaнных в зaрaбoткe нa кpиптoвaлютe. Всeгдa хотeли пoпpoбовать сeбя в этом, нo нe знали с чeго нaчaть? Тогдa вaм кo мнe 3aнимаемся aрбuтражeм, зaрабaтывaeм на paзницe курсов с минимaльныmи pискaми 💲Рынok oчень волатильный и нам это выгoднo, пo этoмe пишиte @vitalgoescra и зapaбaтывaйтe сo мнoй ", 31, true},
{"WithCyrillic real example 2", "В поuске паpтнеров, заuнтересованных в пассuвном дoходе с затpатой мuнuмум лuчного временu. Все деталu в лс", 10, true},
{"WithCyrillic real example 3", "Всем привет, есть простая шабашка, подойдет любому. Даю 15 тысяч. Накину на проезд, сигареты, обед. ", 0, false},
{"WithCyrillic and i", "Привет мiр", 0, false},
}

for _, tt := range tests {
Expand Down

0 comments on commit 2c0b0ae

Please sign in to comment.