aligner

package
v0.0.0-...-9fe405e Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2021 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdditionalData map[string]interface{}

AdditionalData store information useful when computing features

Functions

func EditType

func EditType(e Edit, data map[string]interface{}) float64

EditType compute the score using the edit type

func EqEquivTermDistance

func EqEquivTermDistance(e Edit, data map[string]interface{}) float64

EqEquivTermDistance computes the distance based on greek equivalent terms

func GetWordID

func GetWordID(source, id string) string

GetWordID gets an id from source and word id

func LemmaDistance

func LemmaDistance(e Edit, data map[string]interface{}) float64

LemmaDistance computes the distance based on the word lemma

func LexicalSimilarity

func LexicalSimilarity(e Edit, data map[string]interface{}) float64

LexicalSimilarity computes the distance based on the word text

func LoadScholie

func LoadScholie(path string) (*trie.Trie, error)

LoadScholie gets the data from the available scholies

func LoadScholieDict

func LoadScholieDict(path string) (map[string][]string, error)

LoadScholieDict gets the data from the available scholies

func LoadVoc

func LoadVoc(path string, dictName string) (map[string][]string, error)

LoadVoc loads the vocabulary data

func MaxDistance

func MaxDistance(e Edit, data map[string]interface{}) float64

MaxDistance combines the distances of the other features

func NewGreekAligner

func NewGreekAligner() *greekAligner

NewGreekAligner creates a greek aligner

func Phi

func Phi(a *Alignment, fs []Feature, data map[string]interface{}) vectors.Vector

Phi TODO

func RemovePunctuation

func RemovePunctuation(s string) string

RemovePunctuation from a string

func ResetCache

func ResetCache()

ResetCache clear the cache

func ScholieDistance

func ScholieDistance(e Edit, sch map[string]interface{}) float64

ScholieDistance computes the distance based onscholie

func ScholieDistanceExact

func ScholieDistanceExact(e Edit, sch map[string]interface{}) float64

ScholieDistanceExact computes the distance based onscholie

func ScoreAccuracy

func ScoreAccuracy(a, b *Alignment, fs []Feature, w []float64, data map[string]interface{}) float64

ScoreAccuracy checks the ratio of edits considering their score

func TagDistance

func TagDistance(e Edit, data map[string]interface{}) float64

TagDistance computes the distance based on the word tag

func TextualDistance

func TextualDistance(e Edit, data map[string]interface{}) float64

TextualDistance is the max between LE=exical and Lemma similarity

func VocDistance

func VocDistance(e Edit, data map[string]interface{}) float64

VocDistance computes the distance based on vocabulary data

Types

type Aligner

type Aligner interface {
	// contains filtered or unexported methods
}

Aligner is the interface that computes the next step of an alignment

type Alignment

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

Alignment represents a words alignment

func MergeAlignments

func MergeAlignments(a, b *Alignment) *Alignment

func NewFromEdits

func NewFromEdits(es ...Edit) *Alignment

NewFromEdits creates an aligment from edits

func NewFromWordBags

func NewFromWordBags(from, to WordsBag) *Alignment

NewFromWordBags creates an aligment from two word bags

func (*Alignment) Add

func (a *Alignment) Add(es ...Edit)

Add inserts the edit in the alignment

func (*Alignment) Align

func (a *Alignment) Align(ar Aligner, fs []Feature, ws []float64, subseqLen int, data map[string]interface{}) (*Alignment, error)

Align computes the alignement using an aligner

func (*Alignment) EditsAccuracy

func (a *Alignment) EditsAccuracy(std *Alignment) float64

EditsAccuracy checks the ratio of edits in a that are also in std (the "correct" version)

func (*Alignment) Score

func (a *Alignment) Score(fs []Feature, ws []float64, data map[string]interface{}) float64

Score the aligment

func (*Alignment) String

func (a *Alignment) String() string

func (*Alignment) ToJSONEdits

func (a *Alignment) ToJSONEdits() (map[string]JSONEdit, map[string]JSONEdit)

type DB

type DB = map[string]Word

DB is the database of words

func LoadDB

func LoadDB(paths []string) (DB, error)

LoadDB retrieves all the words from the parameter paths

type Del

type Del struct {
	W Word
}

Del is the delition edit

func (*Del) GetProblemID

func (e *Del) GetProblemID() string

GetProblemID of the edit

func (*Del) Score

func (e *Del) Score(fs []Feature, ws []float64, data map[string]interface{}) float64

Score the edit

func (*Del) String

func (e *Del) String() string

func (*Del) ToJSONEdit

func (e *Del) ToJSONEdit() JSONEdit

type Edit

type Edit interface {
	fmt.Stringer
	Score(fs []Feature, ws []float64, data map[string]interface{}) float64
	GetProblemID() string
}

Edit is the edits interface

type Eq

type Eq struct {
	From Word
	To   Word
}

Eq is the equality edit

func (*Eq) GetProblemID

func (e *Eq) GetProblemID() string

GetProblemID of the edit

func (*Eq) Score

func (e *Eq) Score(fs []Feature, ws []float64, data map[string]interface{}) float64

Score the edit

func (*Eq) String

func (e *Eq) String() string

func (*Eq) ToJSONEdit

func (e *Eq) ToJSONEdit() JSONEdit

type Feature

type Feature func(Edit, map[string]interface{}) float64 // func(sw, tw []word) float64

Feature represents a computable feature for the alignment

type Ins

type Ins struct {
	W Word
}

Ins is the insertion edit

func (*Ins) GetProblemID

func (e *Ins) GetProblemID() string

GetProblemID of the edit

func (*Ins) Score

func (e *Ins) Score(fs []Feature, ws []float64, data map[string]interface{}) float64

Score the edit

func (*Ins) String

func (e *Ins) String() string

func (*Ins) ToJSONEdit

func (e *Ins) ToJSONEdit() JSONEdit

type JSONEdit

type JSONEdit struct {
	Type   string   `json:"type"`
	Source []string `json:"source,omitempty"`
	Target []string `json:"target,omitempty"`
}

JSONEdit represents the JSON format of an edit

func (JSONEdit) Explode

func (e JSONEdit) Explode() (map[string]JSONEdit, map[string]JSONEdit)

Explode creates new JSONEdits from the given one addressing them by contained IDS

type JSONEditer

type JSONEditer interface {
	ToJSONEdit() JSONEdit
}

JSONEditer TODO

type Problem

type Problem struct {
	From, To WordsBag
}

Problem describes an alignment problem

func (Problem) String

func (p Problem) String() string

type Scholie

type Scholie map[string]map[string][]string

Scholie data

type Sub

type Sub struct {
	From []Word
	To   []Word
}

Sub is the substitution edit

func (*Sub) GetProblemID

func (e *Sub) GetProblemID() string

GetProblemID of the edit

func (*Sub) Score

func (e *Sub) Score(fs []Feature, ws []float64, data map[string]interface{}) float64

Score the edit

func (*Sub) String

func (e *Sub) String() string

func (*Sub) ToJSONEdit

func (e *Sub) ToJSONEdit() JSONEdit

type Word

type Word struct {
	ID     string
	Text   string
	Lemma  string
	Tag    string
	Verse  string
	Chant  string
	Source string
}

Word contains the information about words

type WordsBag

type WordsBag = map[string]Word

WordsBag represents a set of words

Jump to

Keyboard shortcuts

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