Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var MaxIter = 100
Functions ¶
Types ¶
type Cutter ¶ added in v0.1.81
type Cutter struct {
Sep string
}
Cutter splits the input by the given separator and keeps only the part before it.
type Processor ¶
type Processor interface {
// Describe returns a short description of this processor.
Describe() string
// Once reports whether this processor should run only once.
Once() bool
// Process performs the actual text transformation.
Process(string) (string, error)
}
Processor defines a generic interface for text processors. Each processor can optionally be executed only once (Once == true) and provides a human-readable description for debugging or logging.
func CutSpace ¶ added in v0.1.81
func CutSpace() Processor
CutSpace returns a processor that extracts the first word in the input string.
func NewMultiProcessor ¶ added in v0.1.81
NewMultiProcessor creates a new MultiProcessor.
desc - human-readable name once - whether this processor should execute only once procs - list of sub-processors
func NewProcessor ¶
NewProcessor creates a new Processor from a function.
desc - short description for debugging once - whether this processor should be executed only once fn - transformation function taking a string and returning a string/error
func RemoveParentheses ¶ added in v0.1.81
func RemoveParentheses() Processor
RemoveParentheses returns a processor that remove both western and full-width parentheses.
type RegexpRemover ¶ added in v0.1.81
RegexpRemover removes substrings that match the given regular expression.
func (RegexpRemover) Describe ¶ added in v0.1.81
func (p RegexpRemover) Describe() string
Describe returns a string representation of the RegexpRemover.
func (RegexpRemover) Once ¶ added in v0.1.81
func (RegexpRemover) Once() bool
Once always returns false, meaning this processor can be applied repeatedly.
type Tasks ¶
type Tasks struct {
// contains filtered or unexported fields
}
Tasks represents an ordered list of text processors. Each processor in the list will be executed sequentially, and repeated until the text no longer changes.
func (*Tasks) Append ¶
Append adds one or more processors to the task list and returns the updated instance.
type Trimmer ¶ added in v0.1.81
type Trimmer struct {
Cutset string
}
Trimmer removes all leading and trailing characters from the given cutset.