textkit

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2025 License: BSD-3-Clause Imports: 4 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

textkit

A tokeniser written in Go

Documentation

Overview

Package textkit provides a tokeniser and morphological analyser.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LexicalEntry

type LexicalEntry struct {
	// The entry's lemma.
	Lemma string
	// The morphological tag.
	Tag string
}

LexicalEntry is a lexical entry.

type Location

type Location struct {
	File   string
	Line   int
	Column int
}

Location specifies the location of a token.

func (Location) String

func (loc Location) String() string

type MorphologicalLexicon

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

MorphologicalLexicon is a morphological lexicon.

func NewMorphologicalLexicon

func NewMorphologicalLexicon(filename string) (*MorphologicalLexicon, error)

NewMorphologicalLexicon returns a new morphological lexicon.

func (*MorphologicalLexicon) AddEntry

func (lex *MorphologicalLexicon) AddEntry(form, lemma, tag string)

AddEntry adds an entry to the lexicon.

func (*MorphologicalLexicon) Analyse

func (lex *MorphologicalLexicon) Analyse(form string) []*LexicalEntry

Analyse analyses a word form. Returns a list of lexical entries.

type Token

type Token struct {
	// The token's type.
	Type TokenType
	// The form of the token as a slice of runes.
	Form []rune
	// The location where the token is located.
	Loc Location
	// An associated tag.
	Tag string
}

Token is a text token.

func (*Token) String

func (t *Token) String() string

type TokenType

type TokenType int

TokenType is a token type.

const (
	Word TokenType = iota
	Number
	String
	Symbol
	EOL
	EndIndent
	EOF
)

Token types

func (TokenType) String

func (t TokenType) String() string

type Tokeniser

type Tokeniser struct {
	CommentPrefix  string
	StringRune     rune
	IdentChars     string
	KeepEOLs       bool
	KeepEndIndents bool
}

Tokeniser is a tokeniser which takes into account comments and special characters in identifiers.

func (*Tokeniser) Tokenise

func (t *Tokeniser) Tokenise(text, file string) []*Token

Tokenise tokenises a text.

Jump to

Keyboard shortcuts

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