dag

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrIndex = errors.New("index")

ErrIndex identifies index-related errors.

View Source
var (
	// Error indicates grammar-related errors.
	Error = errors.New("grammar")
)

Functions

func ResolveFilePath

func ResolveFilePath(filePath string) (dirname, filename, ext string, err error)

Types

type ID

type ID storage.ID32

ID represents node ID.

type IDList

type IDList []ID

IDList provides simple list of items.

type IdMap

type IdMap map[rune]ID

IdMap provides mapping of runes to ID's.

func (IdMap) String

func (idMap IdMap) String() string

String returns NodeMap string representation.

type Idx

type Idx []Tag

Idx implements Tag index routines.

func NewIndex

func NewIndex(knownTags ...Tag) Idx

NewIndex creates new Idx.

func (*Idx) BinaryReadFrom

func (tagsIndex *Idx) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads Idx data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (Idx) BinaryWriteTo

func (tagsIndex Idx) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes Idx data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (Idx) Find

func (tagsIndex Idx) Find(name TagName) (id TagID, found bool)

Find returns indexed ID by known name and parent. Returns false found indicator if no such indexed found.

func (Idx) Get

func (tagsIndex Idx) Get(requiredIdx TagID) (foundItem Tag, found bool)

Get returns indexed from index using its indexed ID. Returns found indexed or found indicator will false.

func (*Idx) Index

func (tagsIndex *Idx) Index(name TagName, parent TagName) (id TagID)

Index returns indexed ID. Adds indexed to index if not indexed before.

func (Idx) Len

func (tagsIndex Idx) Len() int

Len returns index length.

type Index

type Index interface {
	// AddRunes adds runes sequence into index.
	// Returns final node filled with node data or error if add caused error.
	AddRunes([]rune) (Node, error)

	// AddString adds string word into index.
	// Returns final node or error if add caused error.
	AddString(word string) (node Node, err error)

	// FetchRunes lookups runes sequence in container.
	// If found returns final node or error if not found.
	FetchRunes([]rune) (Node, error)

	// FetchString lookups string in container.
	// If found returns final node or error if not found.
	FetchString(word string) (Node, error)

	// TagID returns index of grammeme specified by name and parent name.
	TagID(name TagName, parent TagName) TagID
}

Index defines main dictionary interface.

type Node

type Node interface {
	fmt.Stringer

	// TagSets returns node TagSet.
	TagSets() []TagSet

	// AddTagSet adds a new TagSet to node data.
	AddTagSet(newTagSet ...TagName) error

	// Word returns sequence of characters from root upto current node wrapped into string.
	Word() string
}

Node implements container methods as well as node specific rune fetcher and parent resolver.

type NodeMap

type NodeMap map[rune]Node

NodeMap provides mapping of runes to Node's.

func (NodeMap) BinaryWriteTo

func (n NodeMap) BinaryWriteTo(writer *binutils.BinaryWriter) error

func (NodeMap) String

func (n NodeMap) String() string

String returns NodeMap string representation.

type Tag

type Tag struct {
	Parent TagName // Parent TagName name.
	Name   TagName // Tag name.
}

Tag implements storage for structured TagName's.

func NewTag

func NewTag(parent TagName, name TagName) *Tag

NewTag makes new tag with required parent, name, alias and description.

func (*Tag) BinaryReadFrom

func (g *Tag) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

BinaryReadFrom reads Tag data using specified binutils.BinaryReader instance. Returns error if happens or nil. Implements binutils.BinaryReaderFrom.

func (Tag) BinaryWriteTo

func (g Tag) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes Tag data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (Tag) String

func (g Tag) String() string

String returns string representation of tag. Implements Stringer.

type TagID

type TagID storage.ID8

TagID represents Tag id in storage array.

func (TagID) Uint8

func (t TagID) Uint8() uint8

Uint8 returns uint8 value of TagID.

type TagName

type TagName string

TagName represents name of grammatical category. It uses exactly 4 ASCII characters to name categories. If TagName is shorter than 4 character is filled upto 4 with spaces.

const (
	// EmptyTagName defines constant tag name to replace empty strings and distinct unfilled and empty cases.
	EmptyTagName TagName = "----"
)

func (*TagName) BinaryReadFrom

func (g *TagName) BinaryReadFrom(reader *binutils.BinaryReader) (err error)

func (TagName) BinaryWriteTo

func (g TagName) BinaryWriteTo(writer *binutils.BinaryWriter) (err error)

BinaryWriteTo writes TagName data using specified binutils.BinaryWriter instance. Returns error if happens or nil. Implements binutils.BinaryWriterTo.

func (TagName) MarshalBinary

func (g TagName) MarshalBinary() (data []byte, err error)

MarshalBinary makes name bytes string representation. Always produces 4 bytes. EmptyTagName TagName name represents as 4 spaces.

func (TagName) String

func (g TagName) String() string

String returns TagName name as string type. Implements fmt.Stringer.

func (*TagName) UnmarshalBinary

func (g *TagName) UnmarshalBinary(tagNameBytes []byte) error

type TagSet

type TagSet []Tag

TagSet represents a list of tags attached to words.

func (TagSet) String

func (tagSet TagSet) String() string

String returns string representation of TagSet. Implements fmt.Stringer.

Jump to

Keyboard shortcuts

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