Skip to content

Commit

Permalink
better
Browse files Browse the repository at this point in the history
  • Loading branch information
toadharvard committed Apr 5, 2024
1 parent 3974132 commit ffbe704
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion stopwords-iso.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (m *StopwordsMapping) ClearStringByLang(str string, language ISOCode639_1)

filtered := []string{}
for _, word := range words {
if !slices.Contains((*m)[language], strings.ToLower(word)) {
if !m.isStopword(word, language) {
filtered = append(filtered, word)
}
}
Expand All @@ -76,3 +76,9 @@ func (m *StopwordsMapping) ClearString(str string) string {
}
return str
}

// isStopword checks if the given word is a stopword for the specified language.
// It takes a word string and a language ISOCode639_1 as parameters and returns a boolean.
func (m *StopwordsMapping) isStopword(word string, language ISOCode639_1) bool {
return !slices.Contains((*m)[language], strings.ToLower(word))
}

0 comments on commit ffbe704

Please sign in to comment.