Categorygithub.com/fwew/fwew-lib/v5
modulepackage
5.23.4
Repository: https://github.com/fwew/fwew-lib.git
Documentation: pkg.go.dev

# README

fwew Library

License: GPL v2

The Best Na'vi Dictionary library

Development

This option is mostly for Contributors and Developers. Or people who like to compile stuff themselves. You will need the GO Programming Language and Git installed.

Setup

We are using go modules so no GOPATH setup is needed.

To compile and run tests:

cd ~/wherever/you/want
git clone https://github.com/fwew/fwew-lib
cd fwew-lib
go test ./...

Now make changes to the code and have fun. Please also add tests for the new code, so we get a high code coverage.

Usage

We have already three programs, that are using this library:

Translate

Translating is possible from Na'vi or any other supported language. As result, you will get an array of the Word struct, that can be used to create the output you desire.

require (
    fwew "github.com/fwew/fwew-lib"
)

// Translate from a native language
navi = fwew.TranslateToNavi("search", "de")
fmt.Println(word.ToOutputLine(0, true, false, false, false, false, false))

// Translate a Na'vi word into the native language
navi = fwew.TranslateFromNavi("mllte")
fmt.Println(word.ToOutputLine(0, true, false, false, false, false, false, "de"))

Numbers

Numbers also can be translated in both directions. The Na'vi number system is base 8 (Oktal) and therefore the Integers are base 8. Number have to be in the range, that Na'vi is possible of saying 0o0 to 0o77777.

require (
    fwew "github.com/fwew/fwew-lib"
)

// Translate an octal number to the Na'vi word
navi, err := fwew.NumberToNavi(0o56)
if err != nil {
    panic(err)
}
fmt.Println(navi)

// Translate the Na'vi word into the octal integer
number, err := fwew.NaviToNumber("mrrvomrr")
if err != nil {
    panic(err)
}
fmt.Println(number)

List

List() is a powerful search feature of fwew that allows you to list all the words that satisfy a set of given conditions. Every word has to be in the string array given to List(). Simply explode the given string at the space.

The syntax is as follows (cond is short for condition, spec is short for specification):

what cond spec [and what cond spec...]

what can be any one of the following:

pos          part of speech of na'vi word
word         na'vi word
syllables    number of syllables in the na'vi word
words        selection of na'vi words
stress       number representing which syllable is stressed in the na'vi word

cond depends on the what. Here are the conditions that apply to each what: pos:

has    part of speech has the following character sequence anywhere
is     part of speech is exactly the following character sequence
like   part of speech is like (matches) the following wildcard pattern

word:

starts    word starts with the following character sequence
ends      word ends with the following character sequence
has       word has the following character sequence anywhere
like      word is like (matches) the following wildcard pattern

syllables and stress:

<     less than the following number
<=    less than or equal to the following number
=     exactly equal to the following number
>=    greater than or equal to the following number
>     greater than the following number

words:

first    the first consecutive words in the datafile (chronologically oldest words)
last     the last consecutive words in the datafile (chronologically newest words)

spec depends on the cond. Here are the specifications that apply to each cond:

has, is, starts, and ends all expect a character sequence to come next.

<, <=, =, >=, >, first, and last all expect a number to come next.

like expects a character sequence, usually containing at least one wildcard asterisk, to come next.

Examples of List()

List all modal verbs:

fwew.List([]string{"pos", "has", "v", "and", "pos", "has", "m.",})

List all stative verbs:

fwew.List([]string{"pos", "has", "svin.",})

List all nouns that start with tì:

fwew.List([]string{"word", "starts", "tì", "and", "pos", "is", "n.",})

List all 3 syllable transitive verbs:

fwew.List([]string{"syllables", "=", "3", "and", "pos", "has", "vtr.",})

List the newest 25 words in the language:

fwew.List([]string{"words", "last", "25",})

Random

Random() is a random entry generator that generates the given number (or random number!) of random entries. It also features optional clause in which the what cond spec syntax from List() is supported to narrow down what kinds of random entries you get.

Examples of Random

List 10 random entries

fwew.Random(10, nil)

List 5 random transitive verbs

fwew.Random(5, []string{"pos", "has", "vtr",})

List a random number of random words

fwew.Random(0, nil)

List a random number of nouns

fwew.Random(0, []string{"pos", "is", "n.",})

Update dictionary

fwew.Update() will update the dictionary file to the newest version, downloaded from https://tirea.learnnavi.org/dictionarydata/dictionary.txt.
It will NOT update this library. To update the library you need to adjust the go mod of your project.

Assure dictionary

If you don't want to setup the dictionary manually, this will assure it is found of by the program. By default, it is saved next to the executable. If you want to download it to a different directory, you have to handle that yourself. For this purpose DownloadDict() and FindDictionaryFile() are exposed.

Word-struct

In most cases (all except number translation) the result is a Word struct. This word-struct has every information about a word in it. All public definitions are in the word.go file.

ToOutputLine() generates a basic lines, that our projects directly use as output. This Line has options to adjust what is printed.

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
Helper for TranslateFromNaviHashHelper.
ArrCount returns the number of occurrences of q in s.
Helper function for CacheDictHash2.
AssureDict will assure, that the dictionary exists.
Translate some text.
No description provided by the author
No description provided by the author
Natural languages to Na'vi.
No description provided by the author
This will cache the whole dictionary (Na'vi to natural language).
Contains returns true if anything in q is also in s.
ContainsStr returns true if q is in s.
No description provided by the author
DeleteElement "deletes" all occurrences of q in s actually returns a new string slice containing the original minus all q.
DeleteEmpty "deletes" all empty string entries in s actually returns a new string slice containing all non-empty strings in s.
DownloadDict downloads the latest released version of the dictionary file and saves it to the given filepath.
If a definition is not available in a certain language, default to English.
the dictionary file can be places into: - <workingDir>/dictionary.txt - <workingDir>/.fwew/dictionary.txt - <homeDir>/.fwew/dictionary.txt.
No description provided by the author
Return a complete sentence.
Just a number.
No description provided by the author
Get all words with multiple definitions.
No description provided by the author
Get all words with multiple definitions.
Get all words with spaces.
Get all words with non-standard phonotactics.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Glob will test a string pattern, potentially containing globs, against a subject string.
ContainsStrArr returns true if anything in q is in s.
Index return the index of q in s.
IndexStr return the index of q in s.
IsLetter returns true if s is an alphabet character or apostrophe.
No description provided by the author
See if a word is phonotactically valid in Na'vi.
Helper for TranslateFromNaviHashHelper.
List filters the dictionary based on the args.
No description provided by the author
No description provided by the author
Translate a Na'vi number word to the actual integer.
Turns things like maw-ey into ma-wey, so the checker knows mawll is valid as ma-wll and not mistaken for maw-ll (invalid).
Helper to find empty definitions.
Translate an octal-integer into the Na'vi number word.
Called on startup to feed and compile dictionary information into the name generator.
Get random words out of the dictionary.
No description provided by the author
Reverse returns the reversed version of s.
Helper function to get phonetic transcriptions of secondary pronunciations Only multiple IPA words will call this function.
This will run the function `f` inside the cache or the file directly.
No description provided by the author
Turn a definition into its searchable terms.
SHA1Hash gets hash of dictionary file.
* Name generators */.
Helper function for name-alu.
No description provided by the author
StripChars strips all the characters in chr out of str.
No description provided by the author
Text function is the accessor for []string texts.
Translate some navi text.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Update the dictionary.txt.

# Constants

cache.
GLOB https://github.com/ryanuber/go-glob The character which is treated like a glob.
list.
numbers.
Errors raised by package x.
Errors raised by package x.
Errors raised by package x.

# Variables

Version is a printable version struct containing program version information.

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
Word is a struct that contains all the data about a given word.

# Type aliases

No description provided by the author