jvozba

package module
v0.0.0-...-f0ebe31 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 2 Imported by: 1

README

jvozba

An O(n) implementation of the lujvo-making algorithm to save the world.

What's the big deal with O(n), anyway?

All the jvozba I've seen over the years are of exponential complexity (O(c^n), where 1 ≤ c ≤ 4), because the ‘algorithm’ they implement is basically collecting all possible combinations of rafsi in an array, mapping the array with a score function, and sorting. This means that prefixing an input tanru with just one bloti will quadruple the time and memory it takes for the lujvo to compute. To put this into perspective: in order to find the lujvo for bloti bloti bloti bloti bloti bloti bloti bloti bloti bloti, the algorithm will have to call the score function a million times. Double the input length and your 32-bit machine will explode. (Or wake up the OOM killer.)

This jvozba, on the other hand, is linear in complexity, which means it can compute even a million-bloti lujvo in about a second. ‘How does it achieve that?’, I hear you ask. Simply put, it goes through each tanru unit, keeping track of the best lujvo ‘so far’ alongside its score, with a separate tally for tosmabru words for soundness. There's a bunch more performance tweaks in the code – I encourage you to perhaps read it.

Usage

main.go should give you an idea of how to use the (extremely simple) basic API. If you want to customise stuff, dig into the code and you should find the right procedures to call.

Documentation

Index

Constants

View Source
const (
	Hyphen tarmi = iota
	CVCCV
	CVCC
	CCVCV
	CCVC
	CVC
	CVhV
	CCV
	CVV
)
View Source
const (
	Unvoiced zunsna = iota
	Voiced
	Liquid
)

Variables

View Source
var Rafsi = map[string][]string{}/* 1196 elements not displayed */

Functions

func Cmejvozba

func Cmejvozba(tanru string) (string, error)

func Jvozba

func Jvozba(tanru string) (string, error)

func Lujvo

func Lujvo(selci [][]string) (string, error)

func Score

func Score(lujvo string) int

func Zbasu

func Zbasu(tanru string, rafste map[string][]string, isCmene bool) (string, error)

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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