選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

README.md 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. # snowballstem
  2. This repository contains the Go stemmers generated by the [Snowball](https://github.com/snowballstem/snowball) project. They are maintained outside of the core bleve package so that they may be more easily be reused in other contexts.
  3. ## Usage
  4. All these stemmers export a single `Stem()` method which operates on a snowball `Env` structure. The `Env` structure maintains all state for the stemmer. A new `Env` is created to point at an initial string. After stemming, the results of the `Stem()` operation can be retrieved using the `Current()` method. The `Env` structure can be reused for subsequent calls by using the `SetCurrent()` method.
  5. ## Example
  6. ```
  7. package main
  8. import (
  9. "fmt"
  10. "github.com/blevesearch/snowballstem"
  11. "github.com/blevesearch/snowballstem/english"
  12. )
  13. func main() {
  14. // words to stem
  15. words := []string{
  16. "running",
  17. "jumping",
  18. }
  19. // build new environment
  20. env := snowballstem.NewEnv("")
  21. for _, word := range words {
  22. // set up environment for word
  23. env.SetCurrent(word)
  24. // invoke stemmer
  25. english.Stem(env)
  26. // print results
  27. fmt.Printf("%s stemmed to %s\n", word, env.Current())
  28. }
  29. }
  30. ```
  31. Produces Output:
  32. ```
  33. $ ./snowtest
  34. running stemmed to run
  35. jumping stemmed to jump
  36. ```
  37. ## Testing
  38. The test harness for these stemmers is hosted in the main [Snowball](https://github.com/snowballstem/snowball) repository. There are functional tests built around the separate [snowballstem-data](https://github.com/snowballstem/snowball-data) repository, and there is support for fuzz-testing the stemmers there as well.
  39. ## Generating the Stemmers
  40. ```
  41. $ export SNOWBALL=/path/to/github.com/snowballstem/snowball/after/snowball/built
  42. $ go generate
  43. ```
  44. ## Updated the Go Generate Commands
  45. A simple tool is provided to automate these from the snowball algorithms directory:
  46. ```
  47. $ go run gengen.go /path/to/github.com/snowballstem/snowball/algorithms
  48. ```