lex

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2017 License: GPL-3.0 Imports: 3 Imported by: 13

Documentation

Overview

Package lex is used for general 'container' classes such as entry, transcription, lemma, etc.

Index

Constants

This section is empty.

Variables

View Source
var SourceDelimiter = " : "

SourceDelimiter is used to split a string of sevaral sources into a slice

Functions

This section is empty.

Types

type DBRef

type DBRef string

DBRef a database reference string (i.e., the database filename without extension)

type Entry

type Entry struct {
	ID               int64             `json:"id"`
	LexRef           LexRef            `json:"lexRef"`
	Strn             string            `json:"strn"`
	Language         string            `json:"language"`
	PartOfSpeech     string            `json:"partOfSpeech"`
	Morphology       string            `json:"morphology"`
	WordParts        string            `json:"wordParts"`
	Lemma            Lemma             `json:"lemma"`
	Transcriptions   []Transcription   `json:"transcriptions"`
	EntryStatus      EntryStatus       `json:"status"` // TODO Probably should be a slice of statuses?
	EntryValidations []EntryValidation `json:"entryValidations"`

	// Preferred flag: 1=true, 0=false; schema triggers only one preferred per orthographic word
	//Preferred        int64             `json:"preferred"`
	Preferred bool `json:"preferred"`
}

Entry defines a lexical entry. It does not correspond one-to-one to the entry db table, since it contains data also from associated tables (Lemma, Transcription)

type EntryFileWriter

type EntryFileWriter struct {
	Writer io.Writer
	// contains filtered or unexported fields
}

EntryFileWriter outputs formated entries to an io.Writer. Example usage:

bf := bufio.NewWriter(f)
defer bf.Flush()
bfx := lex.EntriesFileWriter{bf}
dbapi.LookUp(db, q, bfx)

func (*EntryFileWriter) Size

func (w *EntryFileWriter) Size() int

Size returns the size of the EntryFileWriter content

func (*EntryFileWriter) Write

func (w *EntryFileWriter) Write(e Entry) error

Write is used to write one lex.Entry at a time to a file

type EntrySliceWriter

type EntrySliceWriter struct {
	Entries []Entry
}

EntrySliceWriter is a container for returning Entries from a LookUp call to the db Example usage:

var q := dbapi.Query{ ... }
var esw lex.EntrySliceWriter
err := dbapi.LookUp(db, q, &esw)
[...] esw.Entries // process Entries

func (*EntrySliceWriter) Size

func (w *EntrySliceWriter) Size() int

Size returns the size of the EntryFileWriter content

func (*EntrySliceWriter) Write

func (w *EntrySliceWriter) Write(e Entry) error

Write is used to write one lex.Entry at a time to a file

type EntryStatus

type EntryStatus struct {
	ID     int64  `json:"id"`
	Name   string `json:"name"`
	Source string `json:"source"`
	//EntryID int64  `json:"entryId"`
	//Timestamp int64  `json:"timestamp"`
	Timestamp string `json:"timestamp"`
	Current   bool   `json:"current"`
}

EntryStatus associates a status to an Entry. The status has a name (such as 'ok') and a source (a string identifying who or what generated the status)

type EntryValidation

type EntryValidation struct {
	ID int64 `json:"id"`

	// Lower case name of level of severity
	Level     string `json:"level"`
	RuleName  string `json:"ruleName"`
	Message   string `json:"Message"`
	Timestamp string `json:"timestamp"`
}

EntryValidation associates a validation result to an Entry

func (EntryValidation) String

func (ev EntryValidation) String() string

type EntryWriter

type EntryWriter interface {
	Write(Entry) error
	Size() int
}

EntryWriter is an interface defining things to which one can write an Entry. See EntrySliceWriter, for returning a slice of Entry, and EntryFileWriter, for writing Entries to file.

type Lemma

type Lemma struct {
	ID       int64  `json:"id"`
	Strn     string `json:"strn"`
	Reading  string `json:"reading"`
	Paradigm string `json:"paradigm"`
}

Lemma corresponds to a row of the lemma db table

type LexName

type LexName string

LexName a lexicon name

type LexRef

type LexRef struct {
	DBRef   DBRef
	LexName LexName
}

LexRef a lexicon reference specified by DBRef and LexName

func NewLexRef

func NewLexRef(lexDB string, lexName string) LexRef

NewLexRef creates a lexicon reference from input strings

func ParseLexRef

func ParseLexRef(fullLexName string) (LexRef, error)

ParseLexRef is used to parse a lexicon reference string into a LexRef struct

var fullLexName  = "pronlex:sv-se-nst"
var lexRef, _    = ParseLexRef(fullLexName)
// lexRef.DBRef  = pronlex
// lexRef.LexName = sv-se-nst

*

func (LexRef) String

func (lr LexRef) String() string

type LexRefWithInfo

type LexRefWithInfo struct {
	LexRef        LexRef
	SymbolSetName string
}

LexRefWithInfo is a lexicon reference (LexRef) with additional info (SymbolSetName)

type Transcription

type Transcription struct {
	ID       int64    `json:"id"`
	EntryID  int64    `json:"entryId"`
	Strn     string   `json:"strn"`
	Language string   `json:"language"`
	Sources  []string `json:"sources"`
}

Transcription corresponds to the transcription db table

func (*Transcription) AddSource

func (t *Transcription) AddSource(s string) error

AddSource ... adds a source string at the beginning of the Transcription.Sources slice. If the source is already present, AddSource silently ignores to add the already existing source. AddSource returns an error when the input string contains the SourceDelimiter string.

func (Transcription) SourcesString

func (t Transcription) SourcesString() string

SourcesString returns the []string items of Transcription.Sources as a string, where the items are delimited by SourceDelimiter

type TranscriptionSlice

type TranscriptionSlice []Transcription

TranscriptionSlice is used for soring according to ascending id

func (TranscriptionSlice) Len

func (a TranscriptionSlice) Len() int

func (TranscriptionSlice) Less

func (a TranscriptionSlice) Less(i, j int) bool

func (TranscriptionSlice) Swap

func (a TranscriptionSlice) Swap(i, j int)

Jump to

Keyboard shortcuts

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