Help us shape the future of Go! Take the 2026 Go Developer Survey

snowball

package module
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 3 Imported by: 81

README

Snowball Stemmer for Go

GoDoc Test

Usage

package snowball_test

import (
	"fmt"

	"github.com/tebeka/snowball"
)

func Example() {
	fmt.Printf("%d languages\n", len(snowball.Languages()))
	stemmer, err := snowball.New("english")
	if err != nil {
		fmt.Println("error", err)
		return
	}
	defer stemmer.Close()
	fmt.Println(stemmer.Stem("running"))
	// Output:
	// 29 languages
	// run
}

For bugs, comments, sources and more - head over to https://github.com/tebeka/snowball.

This project was mostly a learning exercise for me, I don't consider it production quality.


Miki Tebeka miki.tebeka@gmail.com

Documentation

Overview

Package snowball implements a stemmer

Example
package main

import (
	"fmt"

	"github.com/tebeka/snowball"
)

func main() {
	fmt.Printf("%d languages\n", len(snowball.Languages()))
	stemmer, err := snowball.New("english")
	if err != nil {
		fmt.Println("error", err)
		return
	}
	defer stemmer.Close()
	fmt.Println(stemmer.Stem("running"))
}
Output:
29 languages
run

Index

Examples

Constants

View Source
const (
	// Version is the library version
	Version = "0.7.0"
	// SnowballVersion is the underlying snowball library version
	SnowballVersion = "2.2.0"
)

Variables

This section is empty.

Functions

func LangList

func LangList() []string

LangList returns the list of languages supported by snowball DEPRECATED: Use Languages

func Languages added in v0.6.0

func Languages() []string

Languages returns the list of languages supported by snowball

Types

type Stemmer

type Stemmer struct {
	// contains filtered or unexported fields
}

Stemmer structure Warning: Stemmers are not goroutine safe, create a stemmer per gorutine or use a pool (such as sync.Pool) to esnure safty.

func New

func New(lang string) (*Stemmer, error)

New creates a new stemmer for lang

func (*Stemmer) Close added in v0.7.0

func (stmr *Stemmer) Close() error

Close closes the stemmer and frees the underlying C memory

func (*Stemmer) Lang

func (stmr *Stemmer) Lang() string

Lang return the stemmer language

func (*Stemmer) Stem

func (stmr *Stemmer) Stem(word string) string

Stem returns them stem of word (e.g. running -> run)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL