Documentation ¶
Overview ¶
Package gmtrn implements http client library for multitran.com
Usage:
result, err := gmtrn.Query("Query string", gmtrn.Languages["english"], // source language (from) gmtrn.Languages["russian"]) // target language (to)
How multitran works ¶
Requested query is splitted into multiple parts depending on found translations. Results page contains corresponding part of the query, list of words and links to other pages with other parts of query (if exist). For example, query "first second third" may be splitted by multitran to pages with "first second" and "third".
How this library works ¶
Library makes request to the site and extracts first page. If this page contains links to other pages with separate word translations, they are requested next. Every requested page is splitted into Words that have multiple Meanings, and combined into WordList. For example, for query "translation library" there would be two WordList objects, one for "translation", other for "library". First one would contain multiple words ("translation" (verb, noun), "translations" etc), and every Word would have list of Meanings. Word also may contain optional pre- and post-parts that provide some context, and also optional phonetic spelling. Every object also contains a link to corresponding page that may be used by library user. Description of types in site terms: Meaning - one line with multiple definitions in specific topic. eng. | chain; complex; structure; type; integer (essence); ^ topic ^ MeaningWord MeaningWord - word from Meaning line. integer (essence) ^ word ^ add (additional info) Word - list of Meanings for word. общее число [...] π сущ. // Word.Pre, Word.Word, Word.Post, Word.Spelling, Word.Part (part of speech) genet. number; date; figure; numeric; // Meaning autom. digit // Meaning WordList - part of initial query with corresponding words. числа // WordList.Query число, ... // Words How it looks on site: Word topic meaning, meaning, meaning topic meaning, meaning, meaning ... Word topic meaning, meaning, meaning topic meaning, meaning, meaning ...
Known issues ¶
Site has autodetection algorithm, so sometimes even uses different source/target languages, depending on query. It mostly ok though.
Only default site interface language is implemented.
Thesaurus is parsed as simple translation table.
There is no tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Languages = map[string]int{
"english": 1,
"russian": 2,
"german": 3,
"french": 4,
"spanish": 5,
"croatian": 8,
"arabic": 10,
"portuguese": 11,
"lithuanian": 12,
"romanian": 13,
"polish": 14,
"bulgarian": 15,
"czech": 16,
"chinese": 17,
"danish": 22,
"italian": 23,
"dutch": 24,
"latvian": 27,
"estonian": 26,
"japanese": 28,
"swedish": 29,
"norwegian": 30,
"afrikaans": 31,
"turkish": 32,
"ukrainian": 33,
"esperanto": 34,
"kalmyk": 35,
"finnish": 36,
"latin": 37,
"greek": 38,
"korean": 39,
"hungarian": 42,
"irish": 49,
"slovak": 60,
"slovene": 67,
"maltese": 78,
}
Available languages
Functions ¶
This section is empty.
Types ¶
type Meaning ¶
type Meaning struct { Words []MeaningWord Topic, Link, Title string }
Meaning of some word by topic. Optional Title extracted from link tooltip.
type MeaningWord ¶
type MeaningWord struct { Word, Link, Add, Translator, TranslatorLink, TranslatorTitle string }
Single part of definition that contains a single word, link to the word page and additional information. Link often couldn't be opened without multitran.com referer for access. If translation was provided by some user, information is extracted into Translator (username), TranslatorLink (link to profile) and TranslatorTitle (link title, contains date of translation)
func (MeaningWord) String ¶
func (w MeaningWord) String() string
type Word ¶
Word with list of meanings. Pre, Post and Spelling are optional parts. Pre is displayed before and Post after the word to provide translation context. Spelling is written in phonetic alphabet. Part describes part of speech.
func (*Word) AddMeaning ¶ added in v0.3.0
type WordList ¶
List of words at page
func Query ¶
Run HTTP query to multitran.com and return parsed results or error. Function may return error if translation isn't found or something wrong happens.
- query - query string
- langFrom - integer from Languages map, source language
- langTo - integer from Languages map, target language