Documentation
¶
Overview ¶
Package main contains all the things. affixes.go handles affix parsing of input.
Package main contains all the things ¶
Package main contains all the things. lib.go handles common functions.
Package fwew_lib contains all the things. numbers.go contains all the stuff for the number parsing
Package main contains all the things. txt.go handles program strings.
Package main contains all the things. version.go handles program version.
Package main contains all the things. word.go is home to the Word struct.
Index ¶
- Constants
- Variables
- func ArrCount(s []string, q string) int
- func AssureDict() error
- func CacheDict() error
- func Contains(s []string, q []string) bool
- func ContainsStr(s []string, q string) bool
- func DeleteElement(s []string, q string) []string
- func DeleteEmpty(s []string) []string
- func DownloadDict(filepath string) error
- func FindDictionaryFile() string
- func GetDictSize() (amount int, err error)
- func GetLenitionTable() [][2]string
- func GetOtherThats() [][3]string
- func GetShortLenitionTable() [][2]string
- func GetThatTable() [][5]string
- func Glob(pattern, subj string) bool
- func HasPrefixStrArr(s string, q []string) bool
- func Index(s []string, q string) int
- func IndexStr(s string, q rune) int
- func IsLetter(s string) bool
- func NaviToNumber(input string) (int, error)
- func NumberToNavi(input int) (string, error)
- func Reverse(s string) string
- func RunOnDict(f func(word Word) error) (err error)
- func SHA1Hash(filename string) string
- func StripChars(str, chr string) string
- func Text(s string) string
- func UncacheDict()
- func UpdateDict() error
- type Word
- func GetFullDict() (allWords []Word, err error)
- func List(args []string) (results []Word, err error)
- func Random(amount int, args []string) (results []Word, err error)
- func TranslateFromNavi(searchNaviWord string) (results []Word, err error)
- func TranslateToNavi(searchWord string, langCode string) (results []Word)
Constants ¶
const ( // cache DictionaryNotFound = constError("no dictionary found") // numbers NegativeNumber = constError("negative numbers not allowed") NumberTooBig = constError("number too big") NoTranslationFound = constError("no translation found") // list InvalidNumber = constError("invalidNumericError") NoResults = constError("noResultsError") )
Errors raised by package x.
const GLOB = "%"
GLOB https://github.com/ryanuber/go-glob The character which is treated like a glob
Variables ¶
var Version = version{
6, 0, 0,
"next",
"Nawma Nalutsa",
"",
}
Version is a printable version struct containing program version information
Functions ¶
func AssureDict ¶
func AssureDict() error
AssureDict will assure, that the dictionary exists. If no dictionary is found, it will be downloaded next of the executable.
func CacheDict ¶
func CacheDict() error
This will cache the whole dictionary. Please call this, if you want to translate multiple words or running infinitely (e.g. CLI-go-prompt, discord-bot)
func ContainsStr ¶
ContainsStr returns true if q is in s
func DeleteElement ¶
DeleteElement "deletes" all occurrences of q in s actually returns a new string slice containing the original minus all q
func DeleteEmpty ¶
DeleteEmpty "deletes" all empty string entries in s actually returns a new string slice containing all non-empty strings in s
func DownloadDict ¶
DownloadDict downloads the latest released version of the dictionary file and saves it to the given filepath. You can give an empty string as filepath param, to update the found dictionary file.
func FindDictionaryFile ¶
func FindDictionaryFile() string
the dictionary file can be places into: - <workingDir>/dictionary.txt - <workingDir>/.fwew/dictionary.txt - <homeDir>/.fwew/dictionary.txt
func GetDictSize ¶
func GetLenitionTable ¶
func GetLenitionTable() [][2]string
func GetOtherThats ¶
func GetOtherThats() [][3]string
func GetShortLenitionTable ¶
func GetShortLenitionTable() [][2]string
func GetThatTable ¶
func GetThatTable() [][5]string
func Glob ¶
Glob will test a string pattern, potentially containing globs, against a subject string. The result is a simple true/false, determining whether or not the glob pattern matched the subject text.
func HasPrefixStrArr ¶
ContainsStrArr returns true if anything in q is in s
func NaviToNumber ¶
Translate a Na'vi number word to the actual integer. Na'vi numbers are octal values, so the integer is defined as octal number, and can easily be displayed as decimal number. If no translation is found, `NoTranslationFound` is returned as error!
func NumberToNavi ¶
Translate an octal-integer into the Na'vi number word.
func RunOnDict ¶
This will run the function `f` inside the cache or the file directly. Use this to get words out of the dictionary function `f` is called on every single line in the dictionary!
func StripChars ¶
StripChars strips all the characters in chr out of str
func UncacheDict ¶
func UncacheDict()
func UpdateDict ¶
func UpdateDict() error
Update the dictionary.txt. Be careful to not do anything with the dict-file, while update is in progress
Types ¶
type Word ¶
type Word struct { ID string IPA string InfixLocations string PartOfSpeech string Source string Stressed string Syllables string InfixDots string DE string EN string ET string FR string HU string NL string PL string RU string SV string TR string Affixes affix }
Word is a struct that contains all the data about a given word
func GetFullDict ¶
func List ¶
Filter the dictionary based on the args. args can be empty, if so, the whole Dict will be returned (This also happens if < 3 args are given) It will try to always get 3 args and an `and` in between. If less than 3 exist, than it will wil return the previous results.
func Random ¶
Get random words out of the dictionary. If args are applied, the dict will be filtered for args before random words are chosen. args will be put into the `List()` algorithm.
func TranslateFromNavi ¶
Translate some navi text. !! Only one word is allowed, if spaces are found, they will be treated like part of the word !! This will return an array of Words, that fit the input text One Navi-Word can have multiple meanings and words (e.g. synonyms)
func TranslateToNavi ¶
func (*Word) CloneWordStruct ¶
CloneWordStruct is basically a copy constructor for Word struct Basically not needed, cause go copies things by itself. Only string arrays in Affixes are pointers and therefore need manual copy.