StemmerRu

package module
v0.0.0-...-5c7748b Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 2 Imported by: 1

README

Стеммер Портера для русского языка

Build Status codecov

Стемминг - процесс получения основы слова из любой его формы. Иными словами, отсекает лишние суффиксы и окончания.

Самое очевидное применение - в полнотекстовом поиске, где нужно, чтобы слово находилось, даже если у него другое окончание.

Этот пакет - реализация стеммера Портера для русского языка на Go.

Интерфейс совместим со стеммером https://github.com/caneroj1/stemmer

Использование

основа := StemmerRu.Stem("слово")

Преобразует слово на входе в его основу на выходе

Так же, из библиотеки https://github.com/caneroj1/stemmer взяты следющие методы:

 // stem a list of words
  stems := StemmerRu.StemMultiple(strings)

  // stem a list of words in place, modifying the original slice
  StemmerRu.StemMultipleMutate(strings)
  
  // stem a list of words concurrently. this also stems in place, modifying
  // the original slice.
  // NOTE: the order of the strings is not guaranteed to be the same.
  StemmerRu.StemConcurrent(strings)

Пример

package main

import (
	"fmt"
	"github.com/neonxp/StemmerRu"
)

func main() {
	fmt.Println(StemmerRu.StemWord("безмолвны") // выведет: безмолвн
	fmt.Println(StemmerRu.StemWord("безмолвные") // выведет: безмолвн
	fmt.Println(StemmerRu.StemWord("безмолвный") // выведет: безмолвн
	fmt.Println(StemmerRu.StemWord("безмолвным") // выведет: безмолвн
	fmt.Println(StemmerRu.StemWord("безмолвных") // выведет: безмолвн
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Stem

func Stem(word string) string

func StemConcurrent

func StemConcurrent(words *[]string)

StemConcurrent accepts a pointer to a slice of strings and stems them in place. It tries to offload the work into multiple threads. It makes no guarantees about the order of the stems in the modified slice.

func StemMultiple

func StemMultiple(words []string) (output []string)

StemMultiple accepts a slice of strings and stems each of them.

func StemMultipleMutate

func StemMultipleMutate(words *[]string)

StemMultipleMutate accepts a pointer to a slice of strings and stems them in place. It modifies the original slice.

Types

This section is empty.

Jump to

Keyboard shortcuts

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