internal

package
v0.0.40 Latest Latest
Warning

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

Go to latest
Published: May 28, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const PStep = "recognition/post-correction"
View Source
const Version = "v0.0.40"

Version defines the version of apoco.

Variables

This section is empty.

Functions

func ConnectProfile added in v0.0.37

func ConnectProfile(c *Config, suffix string) apoco.StreamFunc

ConnectProfile generates the profile by running the profiler or reads the profile from the cache and connects the profile with the tokens.

func E added in v0.0.21

func E(str string) string

func IDFromFilePath

func IDFromFilePath(path, fg string) string

IDFromFilePath generates an id based on the file group and the file path.

Types

type Config added in v0.0.29

type Config struct {
	Model          string           `json:"model,omitempty"`
	Ngrams         string           `json:"ngrams"`
	ProfilerBin    string           `json:"profilerBin"`
	ProfilerConfig string           `json:"profilerConfig"`
	RR             TrainingSettings `json:"rr"`
	DM             DMSettings       `json:"dm"`
	Nocr           int              `json:"nocr"`
	Cache          bool             `json:"cache"`
	GT             bool             `json:"gt"`
}

Config defines the command's configuration.

func ReadConfig added in v0.0.29

func ReadConfig(name string) (*Config, error)

ReadConfig reads the config from a json or toml file. If the name is empty, an empty configuration file is returned. If name has the prefix '{' and the suffix '}' the name is interpreted as a json string and parsed accordingly (OCR-D compability).

func (*Config) Overwrite added in v0.0.29

func (c *Config) Overwrite(model string, nocr int, cautious, cache, gt bool)

Overwrite overwrites the appropriate variables in the config file with the given values. Values only overwrite the variables if they are not go's default zero value.

type DMSettings added in v0.0.37

type DMSettings struct {
	TrainingSettings
	Cautious bool
}

DMSettings encloses settings for dm training.

type Piper added in v0.0.17

type Piper struct {
	IFGS, Exts, Dirs []string
	METS             string
}

func (Piper) Pipe added in v0.0.17

func (p Piper) Pipe(ctx context.Context, fns ...apoco.StreamFunc) error

type Stok added in v0.0.21

type Stok struct {
	OCR, Sug, GT, ID         string
	Conf                     float64
	Rank                     int
	Skipped, Short, Lex, Cor bool
}

Stok represents a stats token. Stat tokens explain correction decisions of apoco.

func MakeStok added in v0.0.21

func MakeStok(line string) (Stok, error)

MakeStok creates a new stats token from a according formatted line.

func (Stok) Cause added in v0.0.27

func (s Stok) Cause(limit int) StokCause

Cause returns the cause of a correction error. There are 3 possibilities. Either the correction candidate was missing, the correct correction candidate was not selected by the reranker or the correct correction canidate would have been available but could not be selected because of the imposed limit of the number of correction candidates. If the limit smaller or equal to 0, no limit is imposed.

func (Stok) ErrAfter added in v0.0.38

func (s Stok) ErrAfter() bool

func (Stok) ErrBefore added in v0.0.38

func (s Stok) ErrBefore() bool

func (Stok) Merge added in v0.0.29

func (s Stok) Merge() bool

Merge returns true if the token contains merged OCR-tokens.

func (Stok) Split added in v0.0.29

func (s Stok) Split(before Stok) bool

func (Stok) String added in v0.0.21

func (s Stok) String() string

func (Stok) Type added in v0.0.27

func (s Stok) Type() StokType

Type returns the correction type of the stok.

type StokCause added in v0.0.27

type StokCause int

StokCause gives the cause of errors.

const (
	BadRank          StokCause = iota // Bad correction because of a bad rank.
	BadLimit                          // Bad correction because of a bad limit for the correction candidates.
	MissingCandidate                  // Bad correction because of a missing correct correction candidate.
)

func (StokCause) String added in v0.0.27

func (i StokCause) String() string

type StokType added in v0.0.27

type StokType int

StokType gives the type of stoks.

const (
	SkippedShort                       StokType = iota // Skipped short token.
	SkippedShortErr                                    // Error in short token.
	SkippedNoCand                                      // Skipped no canidate token.
	SkippedNoCandErr                                   // Error in skipped no candidate token.
	SkippedLex                                         // Skipped lexical token.
	FalseFriend                                        // Error in skipped lexical token (false friend).
	RedundantCorrection                                // Redundant correction.
	InfelicitousCorrection                             // Infelicitous correction.
	SuccessfulCorrection                               // Successful correction.
	DoNotCareCorrection                                // Do not care correction.
	SuspiciousNotReplacedCorrect                       // Accept OCR.
	DodgedBullet                                       // Dogded bullet.
	MissedOpportunity                                  // Missed opportunity.
	SuspiciousNotReplacedNotCorrectErr                 // Skipped do not care.
)

func (StokType) Err added in v0.0.27

func (s StokType) Err() bool

Err returns true if the stok type marks an Error.

func (StokType) Skipped added in v0.0.27

func (s StokType) Skipped() bool

IsSkipped returns true if the stok type marks a skipped tokens.

func (StokType) String added in v0.0.27

func (i StokType) String() string

type TrainingSettings added in v0.0.37

type TrainingSettings struct {
	Features     []string `json:"features"`
	LearningRate float64  `json:"learningRate"`
	Ntrain       int      `json:"ntrain"`
}

TrainingSettings encloses different training settings.

Jump to

Keyboard shortcuts

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