Skip to content

Commit

Permalink
Export the IsStopWord function. Closes #27
Browse files Browse the repository at this point in the history
  • Loading branch information
kljensen committed Nov 14, 2023
1 parent d6b8ab3 commit 18938da
Show file tree
Hide file tree
Showing 20 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion english/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func stemSpecialWord(word string) (stemmed string) {

// Return `true` if the input `word` is an English stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "a", "about", "above", "after", "again", "against", "all", "am", "an",
"and", "any", "are", "as", "at", "be", "because", "been", "before",
Expand Down
4 changes: 2 additions & 2 deletions english/english_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func Test_stopWords(t *testing.T) {
"was",
}
for _, word := range knownTrueStopwords {
if isStopWord(word) == false {
if IsStopWord(word) == false {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand All @@ -39,7 +39,7 @@ func Test_stopWords(t *testing.T) {
"bullschnizzle",
}
for _, word := range knownFalseStopwords {
if isStopWord(word) == true {
if IsStopWord(word) == true {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand Down
2 changes: 1 addition & 1 deletion english/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(word) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
2 changes: 1 addition & 1 deletion french/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

// Return `true` if the input `word` is a French stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "au", "aux", "avec", "ce", "ces", "dans", "de", "des", "du",
"elle", "en", "et", "eux", "il", "je", "la", "le", "leur",
Expand Down
2 changes: 1 addition & 1 deletion french/french_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Test_stopWords(t *testing.T) {
{"eussiez", true},
{"machine", false},
}
romance.RunWordBoolTest(t, isStopWord, testCases)
romance.RunWordBoolTest(t, IsStopWord, testCases)
}

// Test isLowerVowel for things we know should be true
Expand Down
2 changes: 1 addition & 1 deletion french/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(word) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
4 changes: 2 additions & 2 deletions hungarian/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ func isDoubleConsonant(rs []rune) int {
return 2
}

// isStopWord returns true it the word is a stop word.
// IsStopWord returns true it the word is a stop word.
//
// # Hungarian stop word list prepared by Anna Tordai
//
// https://snowballstem.org/algorithms/hungarian/stop.txt
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "a",
"ahogy",
Expand Down
2 changes: 1 addition & 1 deletion hungarian/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (!stemStopwWords && isStopWord(word)) {
if len(word) <= 2 || (!stemStopwWords && IsStopWord(word)) {
return word
}

Expand Down
2 changes: 1 addition & 1 deletion norwegian/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func isLowerVowel(r rune) bool {

// Return `true` if the input `word` is a Norwegian stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "ut", "få", "hadde", "hva", "tilbake", "vil", "han", "meget", "men", "vi", "en", "før",
"samme", "stille", "inn", "er", "kan", "makt", "ved", "forsøke", "hvis", "part", "rett",
Expand Down
4 changes: 2 additions & 2 deletions norwegian/norwegian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_stopWords(t *testing.T) {
"ikke",
}
for _, word := range knownTrueStopwords {
if isStopWord(word) == false {
if IsStopWord(word) == false {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand All @@ -36,7 +36,7 @@ func Test_stopWords(t *testing.T) {
"bullschnizzle",
}
for _, word := range knownFalseStopwords {
if isStopWord(word) == true {
if IsStopWord(word) == true {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand Down
2 changes: 1 addition & 1 deletion norwegian/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(word) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
2 changes: 1 addition & 1 deletion russian/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func isLowerVowel(r rune) bool {

// Return `true` if the input `word` is a French stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "и", "в", "во", "не", "что", "он", "на", "я", "с",
"со", "как", "а", "то", "все", "она", "так", "его",
Expand Down
2 changes: 1 addition & 1 deletion russian/russian_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Test_stopWords(t *testing.T) {
{"химическое", false},
{"машиностроение", false},
}
romance.RunWordBoolTest(t, isStopWord, testCases)
romance.RunWordBoolTest(t, IsStopWord, testCases)
}

func Test_findRegions(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion russian/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Stem(word string, stemStopwWords bool) string {
w := snowballword.New(word)

// Return small words and stop words
if len(w.RS) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(w.RS) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
2 changes: 1 addition & 1 deletion spanish/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func isLowerVowel(r rune) bool {

// Return `true` if the input `word` is a Spanish stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "de", "la", "que", "el", "en", "y", "a", "los", "del", "se", "las",
"por", "un", "para", "con", "no", "una", "su", "al", "lo", "como",
Expand Down
2 changes: 1 addition & 1 deletion spanish/spanish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Test_stopWords(t *testing.T) {
{"el", true},
{"queso", false},
}
romance.RunWordBoolTest(t, isStopWord, testCases)
romance.RunWordBoolTest(t, IsStopWord, testCases)
}

// Test isLowerVowel for things we know should be true
Expand Down
2 changes: 1 addition & 1 deletion spanish/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(word) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
2 changes: 1 addition & 1 deletion swedish/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func isLowerVowel(r rune) bool {

// Return `true` if the input `word` is a Swedish stop word.
//
func isStopWord(word string) bool {
func IsStopWord(word string) bool {
switch word {
case "och", "det", "att", "i", "en", "jag", "hon", "som", "han",
"på", "den", "med", "var", "sig", "för", "så", "till", "är", "men",
Expand Down
2 changes: 1 addition & 1 deletion swedish/stem.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func Stem(word string, stemStopwWords bool) string {
word = strings.ToLower(strings.TrimSpace(word))

// Return small words and stop words
if len(word) <= 2 || (stemStopwWords == false && isStopWord(word)) {
if len(word) <= 2 || (stemStopwWords == false && IsStopWord(word)) {
return word
}

Expand Down
4 changes: 2 additions & 2 deletions swedish/swedish_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func Test_stopWords(t *testing.T) {
"inte",
}
for _, word := range knownTrueStopwords {
if isStopWord(word) == false {
if IsStopWord(word) == false {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand All @@ -36,7 +36,7 @@ func Test_stopWords(t *testing.T) {
"bullschnizzle",
}
for _, word := range knownFalseStopwords {
if isStopWord(word) == true {
if IsStopWord(word) == true {
t.Errorf("Expected %v, to be in stopWords", word)
}
}
Expand Down

0 comments on commit 18938da

Please sign in to comment.