normalize

package module
v0.0.0-...-3179d15 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2020 License: MIT Imports: 8 Imported by: 0

README

normalize GitHub Actions Status codecov GoDoc

Simlpe normalize chain

Example:

package main
import n "github.com/rekki/go-query-normalize"

func main() {
  normalize := []n.Normalizer{
    n.NewUnaccent(),
    n.NewLowerCase(),
    n.NewSpaceBetweenDigits(),
    n.NewCleanup(n.BASIC_NON_ALPHANUMERIC),
    n.NewTrim(" "),
  }
  normal := n.Normalize("Hęllö wÖrld. べぺ Ł2ł  ", normalize...)

  fmt.Printf("%s", normal) // hello world へへ l 2 l
}

Documentation

Overview

Package normalize provides simlpe normalizer chain

Index

Constants

This section is empty.

Variables

View Source
var BASIC_NON_ALPHANUMERIC = regexp.MustCompile(`[^\pL\pN]+`)

Functions

func Normalize

func Normalize(s string, normalizers ...Normalizer) string

Types

type Cleanup

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

func NewCleanup

func NewCleanup(re *regexp.Regexp) *Cleanup

func (*Cleanup) Apply

func (l *Cleanup) Apply(s string) string

type Custom

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

func NewCustom

func NewCustom(f func(string) string) *Custom

func (*Custom) Apply

func (l *Custom) Apply(s string) string

type LowerCase

type LowerCase struct{}

func NewLowerCase

func NewLowerCase() *LowerCase

func (*LowerCase) Apply

func (l *LowerCase) Apply(s string) string

type Noop

type Noop struct{}

func NewNoop

func NewNoop() *Noop

func (*Noop) Apply

func (w *Noop) Apply(current string) string

type Normalizer

type Normalizer interface {
	Apply(string) string
}

type PorterStemmer

type PorterStemmer struct {
}

func NewPorterStemmer

func NewPorterStemmer() *PorterStemmer

func (*PorterStemmer) Apply

func (p *PorterStemmer) Apply(s string) string

type RemoveNonAlphanumeric

type RemoveNonAlphanumeric struct{}

func NewRemoveNonAlphanumeric

func NewRemoveNonAlphanumeric() *RemoveNonAlphanumeric

func (*RemoveNonAlphanumeric) Apply

func (l *RemoveNonAlphanumeric) Apply(s string) string

type SpaceBetweenDigits

type SpaceBetweenDigits struct{}

func NewSpaceBetweenDigits

func NewSpaceBetweenDigits() *SpaceBetweenDigits

func (*SpaceBetweenDigits) Apply

func (l *SpaceBetweenDigits) Apply(s string) string

type Trim

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

func NewTrim

func NewTrim(cutset string) *Trim

func (*Trim) Apply

func (l *Trim) Apply(s string) string

type Unaccent

type Unaccent struct{}

func NewUnaccent

func NewUnaccent() *Unaccent

func (*Unaccent) Apply

func (l *Unaccent) Apply(s string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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