mirror of
https://github.com/wgh136/nysoure.git
synced 2025-09-27 04:17:23 +00:00
Check stopwords
This commit is contained in:
@@ -101,3 +101,14 @@ func SearchResource(keyword string) ([]uint, error) {
|
||||
|
||||
return results, nil
|
||||
}
|
||||
|
||||
func IsStopWord(word string) bool {
|
||||
mapping := bleve.NewIndexMapping()
|
||||
analyzerName := mapping.DefaultAnalyzer
|
||||
analyzer := mapping.AnalyzerNamed(analyzerName)
|
||||
if analyzer == nil {
|
||||
return false
|
||||
}
|
||||
tokens := analyzer.Analyze([]byte(word))
|
||||
return len(tokens) == 0
|
||||
}
|
||||
|
Reference in New Issue
Block a user