pkg

package
v0.0.0-...-a37a67c Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2024 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alphabet

func Alphabet() [][]rune

Alphabet returns a table of runes representing the entire alphabet.

Returns:

  • [][]rune: the rune table.

func CheckValidity

func CheckValidity(s []*Syllable) error

CheckValidity checks if the sentence is valid.

Parameters:

  • s: the sentence to check.

Returns:

  • error: nil if the sentence is valid, an error otherwise.

Does nothing if the sentence is empty.

func FinalTweaks

func FinalTweaks(s []*Syllable)

FinalTweaks applies changes to the sentence that are not part of the romanization process.

Parameters:

  • s: the sentence to fix.

Does nothing if the sentence is empty.

func SentenceString

func SentenceString(sentence []*Syllable) string

SentenceString returns the romanized sentence.

Parameters:

  • sentence: the sentence to romanize.

Returns:

  • string: the romanized sentence.

Types

type Character

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

Character is a collection of characters.

func NewCharacter

func NewCharacter(description *CharacterDescription, var_idx int) (*Character, error)

NewCharacter creates a new character.

Parameters:

  • description: the description of the character.
  • varIndex: the index of the variant of the character.

Returns:

  • *Character: the new character.
  • error: an error if the description is nil or if the index is out of bounds.

func (Character) GetRomanization

func (c Character) GetRomanization() string

GetRomanization returns the romanization of the character.

Returns:

  • string: the romanization of the character.

func (*Character) GetType

func (c *Character) GetType() CharacterType

GetType returns the type of the character.

Returns:

  • CharacterType: the type of the character.

func (Character) IsNarrow

func (c Character) IsNarrow() bool

IsNarrow checks if the character is narrow.

Returns:

  • bool: true if the character is narrow, false otherwise.

func (Character) IsUpper

func (c Character) IsUpper() bool

IsUpper checks if the character is upper.

Returns:

  • bool: true if the character is upper, false otherwise.

func (*Character) SetVariant

func (c *Character) SetVariant(var_idx int) error

SetVariant sets the variant of the character.

Parameters:

  • var_idx: the index of the variant of the character.

Returns:

  • error: an error if the index is out of bounds.

Does nothing if the receiver is nil.

func (Character) String

func (c Character) String() string

String returns the romanized character.

Returns:

  • string: the romanized character.

type CharacterDescription

type CharacterDescription struct {
	// Romanization is the Romanization of the character.
	Romanization string

	// Type is the type of the character.
	Type CharacterType
	// contains filtered or unexported fields
}

CharacterDescription helds the description of a character.

func DescriptionFromRomanization

func DescriptionFromRomanization(romanization string) (*CharacterDescription, bool)

DescriptionFromRomanization returns the description of a character from its romanization.

Parameters:

  • romanization: the romanization of the character.

Returns:

  • *CharacterDescription: the description of the character.
  • bool: true if the character was found, false otherwise.

func (CharacterDescription) IsNarrow

func (cd CharacterDescription) IsNarrow() bool

IsNarrow checks if the character is narrow.

Returns:

  • bool: true if the character is narrow, false otherwise.

func (CharacterDescription) VariantAt

func (cd CharacterDescription) VariantAt(index int) (rune, bool)

VariantAt returns the variant at the given index.

Parameters:

  • index: the index of the variant to return.

Returns:

  • rune: the variant at the given index.
  • bool: true if the variant exists, false otherwise.

func (CharacterDescription) VariantSize

func (cd CharacterDescription) VariantSize() int

VariantSize returns the number of variants of the character.

Returns:

  • int: the number of variants of the character.

type CharacterNarrowness

type CharacterNarrowness int

CharacterNarrowness represents the narrowness of the character.

const (
	CQ_Narrow CharacterNarrowness = iota
	CQ_Wide
)

type CharacterType

type CharacterType int

CharacterType represents the type of the character.

const (
	CT_Vowel CharacterType = iota
	CT_Consonant
	CT_Coda
	CT_Extra
	CT_Helper
)

type Sentence

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

Sentence is a collection of syllables.

type Syllable

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

Syllable is a collection of characters.

func NewSyllable

func NewSyllable() *Syllable

NewSyllable creates a new syllable.

Returns:

  • *Syllable: the new syllable. Never returns nil.

func Tokenize

func Tokenize(data []byte) ([]*Syllable, error)

Tokenize returns the romanized sentence.

Parameters:

  • data: the data to tokenize.

Returns:

  • *Sentence: the romanized sentence.
  • error: nil if the sentence is valid, an error otherwise.

func (*Syllable) Append

func (s *Syllable) Append(char *Character)

Append adds a character to the syllable.

Parameters:

  • char: the character to add to the syllable.

Does nothing if the receiver or the character are nil.

func (*Syllable) FinalTweaks

func (s *Syllable) FinalTweaks()

func (Syllable) Size

func (s Syllable) Size() int

Size returns the size of the syllable.

Returns:

  • int: the size of the syllable.

func (Syllable) String

func (s Syllable) String() string

String returns the romanized syllable.

Returns:

  • string: the romanized syllable.

type SyllableBuilder

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

func (*SyllableBuilder) Append

func (sb *SyllableBuilder) Append(char *Character)

Append adds a character to the syllable.

Parameters:

  • char: the character to add to the syllable.

Does nothing if the receiver or the character are nil.

func (SyllableBuilder) Build

func (sb SyllableBuilder) Build() *Syllable

func (*SyllableBuilder) Reset

func (sb *SyllableBuilder) Reset()

func (SyllableBuilder) Size

func (sb SyllableBuilder) Size() int

Size returns the size of the syllable.

Returns:

  • int: the size of the syllable.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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