gt

package
v0.0.0-...-2c36af7 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var SourceLangs = map[string]bool{}

Functions

func GetCognates

func GetCognates(graph *cayley.Handle, lang string, word string) map[string]*Cognate

func GetGraph

func GetGraph(path string) (*cayley.Handle, error)

GetGraph returns graph either from path or compressed path.

func GetGraphNquads

func GetGraphNquads(path string) (*cayley.Handle, error)

GetGraphNquads returns graph from nquads file

func GetIndex

func GetIndex(path string) (*radix.Tree, error)

GetIndex returns radix tree either from path or compressed path.

func GetSplitFiles

func GetSplitFiles(pathTemplate string) (files []*os.File, err error)

func GetWords

func GetWords(path string) (map[string]*Word, error)

GetWords returns words either from path or compressed path.

func NewLexer

func NewLexer(input string) *lexer

NewLexer creates a new scanner for the input string.

func NewLexer2

func NewLexer2(input string, debug bool) *lexer

NewLexer creates a new scanner for the input string.

func Normalize

func Normalize(w string) string

Filter out diacritics for search.

func ParseXMLPage

func ParseXMLPage(r io.ReadCloser, title string, page chan<- Page, errors chan<- Error, done chan<- io.ReadCloser)

ParseXMLPage returns page for cmd/gtpage.

func ParseXMLPages

func ParseXMLPages(r io.ReadCloser, pages chan<- Page, errors chan<- Error, done chan<- io.ReadCloser)

ParseXMLPages returns pages for cmd/gtsplit.

func ParseXMLWords

func ParseXMLWords(r io.ReadCloser, words chan<- Word, descendants chan<- Descendants, errors chan<- Error, done chan<- io.ReadCloser)

ParseXMLWords returns words and descendants for cmd/gtparse.

func QueryGraph

func QueryGraph(g *cayley.Handle, p *path.Path) (rs []string, ts []string, err error)

QueryGraph queries graph.

func ReadGob

func ReadGob(path string, data interface{}) error

ReadGob reads gob either from path or compressed path.

func ShouldIndex

func ShouldIndex(word *Word) bool

func WriteGob

func WriteGob(p string, data interface{}, verbose bool, shouldBackup bool) error

WriteGob writes and compresses gob.

Types

type Cognate

type Cognate struct {
	Word string `json:"word" firestore:"word"`
	From string `json:"from" firestore:"from"`
}

type Definition

type Definition struct {
	Text string    `json:"text" firestore:"text"`
	Root *RootWord `json:"root,omitempty" firestore:"root,omitempty"`
}

type Definitions

type Definitions struct {
	Nouns         []Definition `json:"nouns,omitempty" firestore:"nouns,omitempty"`
	Adjectives    []Definition `json:"adjectives,omitempty" firestore:"adjectives,omitempty"`
	Verbs         []Definition `json:"verbs,omitempty" firestore:"verbs,omitempty"`
	Adverbs       []Definition `json:"adverbs,omitempty" firestore:"adverbs,omitempty"`
	Articles      []Definition `json:"articles,omitempty" firestore:"articles,omitempty"`
	Prepositions  []Definition `json:"prepositions,omitempty" firestore:"prepositions,omitempty"`
	Pronouns      []Definition `json:"pronouns,omitempty" firestore:"pronouns,omitempty"`
	Conjunctions  []Definition `json:"conjunctions,omitempty" firestore:"conjunctions,omitempty"`
	Interjections []Definition `json:"interjections,omitempty" firestore:"interjections,omitempty"`
	Numerals      []Definition `json:"numerals,omitempty" firestore:"numerals,omitempty"`
	Numbers       []Definition `json:"numbers,omitempty" firestore:"numbers,omitempty"`
	Particles     []Definition `json:"particles,omitempty" firestore:"particles,omitempty"`
	Determiners   []Definition `json:"determiners,omitempty" firestore:"determiners,omitempty"`
}

type Descendants

type Descendants struct {
	Word        string
	Links       []tpl.Link
	Descendants []tpl.Descendant
}

func ParseEtymTree

func ParseEtymTree(p Page, langMap map[string]bool) (*Descendants, error)

Parses a given etymology tree (e.g. https://en.wiktionary.org/wiki/Template:etymtree/la/germanus)

type Error

type Error struct {
	Message string
	Fatal   bool
}

type Etymology

type Etymology struct {
	Cognates  []tpl.Cognate   `json:"cognates,omitempty" firestore:"cognates,omitempty"`
	Mentions  []tpl.Mention   `json:"mentions,omitempty" firestore:"mentions,omitempty"`
	Borrows   []tpl.Borrow    `json:"borrows,omitempty" firestore:"borrows,omitempty"`
	Derived   []tpl.Derived   `json:"derived,omitempty" firestore:"derived,omitempty"`
	Inherited []tpl.Inherited `json:"inherited,omitempty" firestore:"inherited,omitempty"`
	Prefixes  []tpl.Prefix    `json:"prefixes,omitempty" firestore:"prefixes,omitempty"`
	Suffixes  []tpl.Suffix    `json:"suffixes,omitempty" firestore:"suffixes,omitempty"`
	Links     []tpl.Link      `json:"links,omitempty" firestore:"links,omitempty"`
}

type FormTemplate

type FormTemplate struct {
	Language   string
	Tags       []string
	Shortcuts  []string
	Text       string
	Inflection bool
}

type FormTemplateType

type FormTemplateType string

type Language

type Language struct {
	Code        string       `firestore:"code"`
	Definitions *Definitions `json:"definitions,omitempty" firestore:"definitions,omitempty"`
	Etymology   *Etymology   `json:"etymology,omitempty" firestore:"etymology,omitempty"`
	// TODO: Clean up Links / represent as descendants?
	// Partly used by legacy etymtree templates. Links are only used for descendants.
	Links       []tpl.Link       `json:"links,omitempty" firestore:"links,omitempty"`
	Descendants []tpl.Descendant `json:"descendants,omitempty" firestore:"descendants,omitempty"`
	// TODO: Rename EtymTrees. May need to re-write DB.
	DescendantTrees []tpl.EtymTree `json:"descendantTrees,omitempty" firestore:"descendantTrees,omitempty"`
	DescTrees       []tpl.DescTree `json:"descTrees,omitempty" firestore:"descTrees,omitempty"`
	Cognates        []*Cognate     `json:"cognates,omitempty" firestore:"cognates,omitempty"`
	// contains filtered or unexported fields
}

func (*Language) AllDefinitions

func (l *Language) AllDefinitions() [][]Definition

func (*Language) IsEmpty

func (l *Language) IsEmpty() bool

type LinkBuffer

type LinkBuffer struct {
	Link string
	Name *string
}

type ListItem

type ListItem struct {
	Prefix string
	Links  []string
}
func (li *ListItem) TplLinks(langMap map[string]bool, parent string) (ls []tpl.Link)

type Page

type Page struct {
	XMLName xml.Name
	Title   string   `xml:"title"`
	Redir   Redirect `xml:"redirect"`
	Text    string   `xml:"revision>text"`
}

type Pos

type Pos int

Pos represents a byte position in the original input text from which this template was parsed.

type Redirect

type Redirect struct {
	Title string `xml:"title,attr"`
}

type RootWord

type RootWord struct {
	Lang string `json:"lang" firestore:"lang"`
	Name string `json:"name" firestore:"name"`
}

type TextBuffer

type TextBuffer []string

type Word

type Word struct {
	Name      string               `json:"name"`
	Languages map[string]*Language `json:"languages"`
	Indexed   *time.Time           `json:"indexed,omitempty"`
}

func ParseWord

func ParseWord(p Page, langMap map[string]bool) (Word, error)

Parses a given word (e.g. https://en.wiktionary.org/wiki/hombre).

func (*Word) IsEmpty

func (w *Word) IsEmpty() bool

Jump to

Keyboard shortcuts

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