ftrans

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 5 Imported by: 0

README

README

ftrans is a go implementation of failure transducers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

A Builder builds failure transducers.

func NewBuilder

func NewBuilder() *Builder

NewBuilder creates a new Builder

func (*Builder) Add

func (b *Builder) Add(key, val string) *Builder

Add adds a new rewrite rule to the resulting failure transducer.

func (*Builder) Build

func (b *Builder) Build() Transducer

Build creates a failure transducer.

func (*Builder) Reset

func (b *Builder) Reset()

Reset resets the builder.

type Link struct {
	Source, Target *state
	Transition     transition
}

Link is a triple that represents a transition in the transducer. It contains the source and target states and the transition between them.

func (Link) IsInitial

func (l Link) IsInitial() bool

IsInitial returns true iff the Link represents the initial state of the transducer.

type SerState

type SerState struct {
	Foutput     string
	Id, Ftarget uint64
	Ts          []SerTransition
}

type SerTransducer

type SerTransducer map[uint64]SerState

type SerTransition

type SerTransition struct {
	Target uint64
	Output string
	Char   rune
}

type Transducer

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

Transducer with failure links. It holds an initial state. An empty Transducer simply copies the input to the ouptput.

func NewTransducerFromSerialization

func NewTransducerFromSerialization(ser SerTransducer) Transducer

NewTransducerFromSerialization creates a new transducer from a SerTransducer.

func (Transducer) Down

func (ft Transducer) Down(s *state, out io.Writer) error

Down follows the failure links down to the initial state of the Transducer.

func (Transducer) GetSerialization

func (ft Transducer) GetSerialization() SerTransducer

GetSerialization returns a SerTransducer that can be serialized.

func (Transducer) Initial

func (ft Transducer) Initial() *state

Initial returns the initial state of a Transducer.

func (Transducer) Rewrite

func (ft Transducer) Rewrite(s *state, str string, out io.Writer) (*state, error)

Rewrite rewrites a string with a transducer.

func (Transducer) RewriteAll

func (ft Transducer) RewriteAll(in io.Reader, out io.Writer, delim byte) error

RewriteAll reads input from a reader and rewrites it to a writer. It uses delim to as separator for read chunks.

func (Transducer) Walk

func (ft Transducer) Walk(f func(link Link) bool)

Walk iterates over the transducer in depth first order.

Jump to

Keyboard shortcuts

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