itn

package
v0.1.2-main.20240529-2... Latest Latest
Warning

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

Go to latest
Published: May 29, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UsePTOrdinalsMerger = true

Variables

View Source
var DEBUG = false
View Source
var SegmentBreak = regexp.MustCompile(`\s*[\.,;\(\)…\[\]:!\?]+\s*`)
View Source
var (
	WORDSEP = regexp.MustCompile(`\s*[\.,;\(\)…\[\]:!\?]+\s*|\n`)
)

Functions

func SetDebug

func SetDebug(debug bool)

Types

type Language

type Language struct {
	LangCode                      LanguageCode
	Multipliers                   map[string]int
	Units                         map[string]int
	STens                         map[string]int
	MTens                         map[string]int
	MTensWSTens                   []string
	Hundred                       map[string]int
	MHundreds                     map[string]int
	Numbers                       map[string]int
	Sign                          map[string]string
	Zero                          []string
	DecimalSep                    string
	DecimalSYM                    string
	AndNums                       []string
	And                           string
	NeverIfAlone                  []string
	Relaxed                       map[string]RelaxTuple
	Simplify_check_coef_appliable bool              // Optional
	RadMap                        map[string]string // Optional
	Composites                    map[string]int    // Optional
	PtOrdinals                    map[string]string // Only for Portuguese
	IrrOrd                        map[string]RelaxTuple
}

func NewLanguage

func NewLanguage(LangCode LanguageCode) (*Language, error)

func (Language) Alpha2Digit

func (lg Language) Alpha2Digit(text string, relaxed bool, signed bool, ordinalThreshold int) string

func (*Language) Normalize

func (lg *Language) Normalize(word string) string

func (*Language) NotNumericWord

func (lg *Language) NotNumericWord(word string) bool

func (*Language) NumOrd

func (lg *Language) NumOrd(digits string, originalWord string) string

func (*Language) Ord2Card

func (lg *Language) Ord2Card(word string) string

type LanguageCode

type LanguageCode int
const (
	Spanish LanguageCode = iota
	English
	Portuguese
	French
	Deutsch
	Russian
	Catalan
)

type LookAhead

type LookAhead struct {
	Word  string
	Ahead string
}

type OrdinalsMerger

type OrdinalsMerger struct{}

func NewOrdinalsMerger

func NewOrdinalsMerger() *OrdinalsMerger

func (*OrdinalsMerger) MergeCompoundOrdinalsPT

func (om *OrdinalsMerger) MergeCompoundOrdinalsPT(text string) string

type RelaxTuple

type RelaxTuple struct {
	Zero string
	One  string
}

type SubRegex

type SubRegex struct {
	Pattern     *regexp.Regexp
	Replacement string
}

type WordStreamValueParser

type WordStreamValueParser struct {
	Skip string
	// contains filtered or unexported fields
}

func NewWordStreamValueParser

func NewWordStreamValueParser(lang Language, relaxed bool) *WordStreamValueParser

func (*WordStreamValueParser) GetValue

func (w *WordStreamValueParser) GetValue() int

type WordToDigitParser

type WordToDigitParser struct {
	Lang Language

	IntBuilder  *WordStreamValueParser
	FracBuilder *WordStreamValueParser
	Signed      bool
	InFrac      bool
	Closed      bool
	Open        bool

	OrdinalThreshold int
	// contains filtered or unexported fields
}

func NewWordToDigitParser

func NewWordToDigitParser(lang Language, relaxed bool, signed bool, ordinalThreshold int, precedingWord string) WordToDigitParser

func (*WordToDigitParser) GetValue

func (w *WordToDigitParser) GetValue() string

Jump to

Keyboard shortcuts

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