Documentation
¶
Overview ¶
Package en provides Go structures to serialize / deserialize English-language version of extracted Wiktionary raw data.
The reference for the structs can be seen at <https://github.com/tatuylonen/wiktextract/raw/refs/heads/master/src/wiktextract/extractor/en/type_utils.py> and is copied below.
Index ¶
- type AltOf
- type AttestationData
- type DeprecatedHyphenation
- type DescendantData
- type EtymologyExample
- type ExampleData
- type ExtraTemplateData
- type FormData
- type FormOf
- type Hyphenation
- type LinkData
- type LinkageData
- type ReferenceData
- type SenseData
- type SoundData
- type TemplateArgs
- type TemplateData
- type TranslationData
- type WordData
- type WordDataDetails
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AltOf ¶
AltOf represents an alternative form or inflected form reference. `Word` contains the linked word, and `Extra` contains optional additional text.
type AttestationData ¶
type AttestationData struct {
Date string `json:"date"`
References []ReferenceData `json:"references,omitempty"`
}
type DeprecatedHyphenation ¶ added in v0.2.0
func (*DeprecatedHyphenation) MarshalJSONTo ¶ added in v0.2.0
func (h *DeprecatedHyphenation) MarshalJSONTo(enc *jsontext.Encoder) error
func (*DeprecatedHyphenation) UnmarshalJSONFrom ¶ added in v0.2.0
func (h *DeprecatedHyphenation) UnmarshalJSONFrom(dec *jsontext.Decoder) error
type DescendantData ¶
type DescendantData struct {
// Wiktionary language code
LangCode string `json:"lang_code"`
// Language name
Lang string `json:"lang"`
Word string `json:"word"`
Roman *string `json:"roman"`
Tags []string `json:"tags,omitempty"`
RawTags []string `json:"raw_tags,omitempty"`
Descendants []DescendantData `json:"descendants,omitempty"`
// Japanese Kanji and furigana
Ruby [][]string `json:"ruby,omitempty"`
Sense *string `json:"sense,omitempty"`
}
type EtymologyExample ¶
type EtymologyExample struct {
English *string `json:"english,omitempty"` // DEPRECATED in favour of `translation`
Translation string `json:"translation,omitempty"`
RawTags []string `json:"raw_tags,omitempty"`
Ref *string `json:"ref,omitempty"`
Roman *string `json:"roman,omitempty"`
Tags []string `json:"tags,omitempty"`
Text string `json:"text,omitempty"`
Type *string `json:"type,omitempty"`
}
type ExampleData ¶
type ExampleData struct {
Alt *string `json:"alt,omitempty"`
English *string `json:"english,omitempty"` // DEPRECATED in favour of "translation"
// English translation of the example sentence
Translation *string `json:"translation,omitempty"`
BoldTranslationOffsets [][2]int `json:"bold_translation_offsets,omitempty"`
// English-language parenthesized note from the beginning of a non-English example
Note *string `json:"note,omitempty"`
// source reference
Ref *string `json:"ref,omitempty"`
// romanization of the example sentence (for some languages written in non-Latin scripts)
Roman *string `json:"roman,omitempty"`
BoldRomanOffsets [][2]int `json:"bold_roman_offsets,omitempty"`
// Japanese Kanji and furigana
Ruby [][]string `json:"ruby,omitempty"`
// the example text
Text string `json:"text"`
BoldTextOffsets [][2]int `json:"bold_text_offsets,omitempty"`
Tags []string `json:"tags,omitempty"`
RawTags []string `json:"raw_tags,omitempty"`
}
ExampleData represents a usage example for a word sense.
type ExtraTemplateData ¶
type FormData ¶
type FormData struct {
Form string `json:"form"`
HeadNr *int `json:"head_nr"`
Ipa *string `json:"ipa,omitempty"`
Roman *string `json:"roman,omitempty"`
// Japanese Kanji and furigana
Ruby [][]string `json:"ruby,omitempty"`
Source *string `json:"source,omitempty"`
Tags []string `json:"tags,omitempty"`
RawTags []string `json:"raw_tags,omitempty"`
Topics []string `json:"topics,omitempty"`
Links []LinkData `json:"links,omitempty"`
}
FormData represents an inflected or alternative form of the word.
type FormOf ¶
type FormOf struct {
Word string `json:"word" db:"INDEX"`
Extra *string `json:"extra,omitempty"`
Roman *string `json:"roman,omitempty"`
}
FormOf represents a word that this sense is an inflected form of. `Word` contains the linked word, and `Extra` contains optional additional text.
type Hyphenation ¶
type LinkData ¶
type LinkData [2]string
A link tuple, typically `["target", "gloss"]`.
Used in sense-level `links` to record wiki-internal links found in example sentences or glosses.
type LinkageData ¶
type LinkageData struct {
// optional alternative form of the target (e.g., in a different script)
Alt *string `json:"alt,omitempty"`
// optional English text associated with the sense, usually identifying the
// linked target sense
English *string `json:"english,omitempty"` // DEPRECATED in favour of "translation"
Translation string `json:"translation"`
Extra *string `json:"extra,omitempty"`
Qualifier *string `json:"qualifier,omitempty"`
RawTags []string `json:"raw_tags,omitempty"`
// optional romanization of a linked word in a non-Latin script
Roman *string `json:"roman,omitempty"`
// Japanese Kanji and furigana
Ruby [][]string `json:"ruby,omitempty"`
// text identifying the word sense or context (e.g., "to rain very heavily")
Sense *string `json:"sense,omitempty"`
Source *string
// qualifiers specified for the sense (e.g., field of study, region, dialect, style)
Tags []string `json:"tags,omitempty"`
// optional taxonomic name associated with the linkage
Taxonomic *string `json:"taxonomic,omitempty"`
// list of topic descriptors for the linkage (e.g., "military")
Topics []string `json:"topics,omitempty"`
Urls []string `json:"urls,omitempty"`
// the word this links to
Word string `json:"word" db:"INDEX"`
}
LinkageData represents a linkage between words (synonyms, antonyms, hypernyms, derived words, holonyms, meronyms, related, coordinate_terms, etc.).
See: https://github.com/tatuylonen/wiktextract#linkages-to-other-words
type ReferenceData ¶
type SenseData ¶
type SenseData struct {
// list of words that this sense is an alternative form of
AltOf []AltOf `json:"alt_of,omitempty"`
// sense-disambiguated antonym linkages for the word
Antonyms []LinkageData `json:"antonyms,omitempty"`
// list of sense-disambiguated category names extracted from (a subset)
// of the Category links on the page
Categories []string `json:"categories,omitempty"`
CompoundOf []AltOf `json:"compound_of,omitempty"`
// sense-disambiguated coordinate term linkages for the word
CoordinateTerms []LinkageData `json:"coordinate_terms,omitempty"`
// list of usage examples, each with `text`, optional `ref` (source
// reference), optional `english` (English translation), optional `type`
// (example type, e.g., "example" or "quotation"), optional `roman`
// (romanization), and optional `note` (parenthesized note)
Examples []ExampleData `json:"examples,omitempty"`
// list of words that this sense is an inflected form of
FormOf []FormOf `json:"form_of,omitempty"`
// list of gloss strings for the word sense (usually only one). This has
// been cleaned, and should be straightforward text with no tagging.
Glosses []string `json:"glosses,omitempty"`
HeadNr *int `json:"head_nr"`
// sense-disambiguated linkages indicating being part of something
// (not systematically encoded)
Holonyms []LinkageData `json:"holonyms,omitempty"`
// sense-disambiguated hypernym linkages for the word
Hypernyms []LinkageData `json:"hypernyms,omitempty"`
// sense-disambiguated hyponym linkages for the word
Hyponyms []LinkageData `json:"hyponyms,omitempty"`
Instances []LinkageData `json:"instances,omitempty"`
Links []LinkData `json:"links,omitempty"`
// sense-disambiguated linkages indicating having a part (fairly rare)
Meronyms []LinkageData `json:"meronyms,omitempty"`
// if the word sense has a qualifier that could not be parsed, that
// qualifier is put in this field (rare). Most qualifiers are parsed
// into `tags` and/or `topics`.
Qualifier *string `json:"qualifier,omitempty"`
// list of gloss strings with less cleaning than `glosses`; parenthesized
// parts that have been parsed into `tags` and `topics` are still present
RawGlosses []string `json:"raw_glosses,omitempty"`
// sense-disambiguated related word linkages for the word
Related []LinkageData `json:"related,omitempty"`
// list of textual identifiers collected for the sense. If there is a
// QID for the entry (e.g., Q123), those are stored in the `wikidata` field.
Senseid []string `json:"senseid,omitempty"`
// sense-disambiguated synonym linkages for the word
Synonyms []LinkageData `json:"synonyms,omitempty"`
// list of qualifiers and tags for the gloss, e.g., "archaic",
// "colloquial", "present", "participle", "plural", "feminine"
Tags []string `json:"tags,omitempty"`
Taxonomic *string `json:"taxonomic,omitempty"`
// list of sense-disambiguated topic names (kind of similar to
// categories but determined differently)
Topics []string `json:"topics,omitempty"`
// list of QIDs (e.g., Q123) for the sense
Wikidata []string `json:"wikidata,omitempty"`
// list of Wikipedia page titles (with optional language code prefix)
Wikipedia []string `json:"wikipedia,omitempty"`
Attestations []AttestationData `json:"attestations,omitempty"`
}
SenseData represents a single word sense (gloss).
type SoundData ¶
type SoundData struct {
// name of a sound file in WikiMedia Commons
Audio *string `json:"audio,omitempty"`
// IPA string associated with the audio file, generally giving IPA
// transcription of what is in the sound file
AudioIpa *string `json:"audio-ipa,omitempty"`
// pronunciation in English pronunciation respelling (enPR)
Enpr *string `json:"enpr,omitempty"`
Form *string `json:"form,omitempty"`
Hangeul *string `json:"hangeul,omitempty"`
// list of homophones for the word
Homophone *string `json:"homophone,omitempty"`
// list of hyphenations
Hyphenation *string `json:"hyphenation,omitempty"`
// International Phonetic Alphabet pronunciation, /.../ or [...]
Ipa *string `json:"ipa,omitempty"`
// URL for an MP3 format sound file
Mp3Url *string `json:"mp3_url,omitempty"`
Note *string `json:"note,omitempty"`
// URL for an OGG Vorbis format sound file
OggUrl *string `json:"ogg_url,omitempty"`
Other *string `json:"other,omitempty"`
Rhymes *string `json:"rhymes,omitempty"`
// other labels or context information attached to the pronunciation
// entry (e.g., might indicate regional variant or dialect)
Tags []string `json:"tags,omitempty"`
// text associated with an audio file (often not very useful)
Text *string `json:"text,omitempty"`
Topics []string `json:"topics,omitempty"`
// Chinese word pronunciation
ZhPron *string `json:"zh-pron,omitempty"`
}
SoundData represents pronunciation, hyphenation, rhyming, and related information. Each entry may have a `tags` key containing tags that clarify what kind of form that entry is. Different types of information are stored in different fields: `ipa` is IPA pronunciation, `enpr` is enPR pronunciation, `audio` is name of sound file in Wikimedia commons.
type TemplateArgs ¶
type TemplateArgs map[json_types.StringOrInt]string
type TemplateData ¶
type TemplateData struct {
// dictionary mapping argument names to their cleaned values;
// positional arguments have keys that are numeric strings, starting with "1"
Args TemplateArgs `json:"args"`
// the (cleaned) text the template expands to
Explansion string `json:"explansion"`
// name of the template
Name string `json:"name"`
ExtraData *ExtraTemplateData `json:"extra_data,omitempty"`
}
TemplateData represents a wiki template and its expansion.
type TranslationData ¶
type TranslationData struct {
// optional alternative form of the translation (e.g., in a different script)
Alt *string `json:"alt,omitempty"`
// Wiktionary's 2 or 3-letter language code for the language the
// translation is for.
LangCode *string `json:"lang_code"`
// DEPRECATED in favour of `lang_code`
Code *string `json:"code,omitempty"`
// English text, generally clarifying the target sense of the translation.
//
// DEPRECATED in favour of `translation`
English *string `json:"english"`
Translation *string `json:"translation"`
// the language name that the translation is for
Lang string `json:"lang"`
// optional text describing or commenting on the translation
Note *string `json:"note,omitempty"`
// optional romanization of the translation (when in non-Latin characters)
Roman *string `json:"roman,omitempty"`
// optional sense indicating the meaning for which this is a translation
// (this is a free-text string, and may not match any gloss exactly)
Sense *string `json:"sense,omitempty"`
// optional list of qualifiers for the translations, e.g., gender
Tags []string `json:"tags,omitempty"`
// optional taxonomic name of an organism mentioned in the translation
Taxonomic *string `json:"taxonomic,omitempty"`
Topics []string `json:"topics,omitempty"`
// the translation in the specified language (may be missing when `note`
// is present)
Word *string `json:"word,omitempty"`
}
TranslationData represents a translation entry.
type WordData ¶
type WordData struct {
WordDataDetails `json:",inline"`
// name of the language this word belongs to (e.g., "English")
Lang string `json:"lang" db:"INDEX"`
// Wiktionary language code corresponding to `lang` key (e.g., "en")
LangCode string `json:"lang_code" db:"INDEX"`
// the word form
Word string `json:"word" db:"INDEX"`
}
WordData is the top-level dictionary containing lexical information of a single word extracted from Wiktionary with wiktextract.
Etymological information is stored under the `etymology_text` and `etymology_templates` keys in the word's data. When multiple parts-of-speech are listed under the same etymology, the same data is copied to each part-of-speech entry under that etymology.
Linkages (`synonyms`, `antonyms`, `hypernyms`, `derived`, `holonyms`, `meronyms`, `related`, `coordinate_terms`) are stored in the word's data if not sense-disambiguated, and in the word sense if sense-disambiguated.
func (WordData) GetLangCode ¶ added in v0.7.0
type WordDataDetails ¶ added in v0.2.2
type WordDataDetails struct {
Abbreviations []LinkageData `json:"abbreviations,omitempty"`
// list of words that this word is an alternative form of
AltOf []AltOf `json:"alt_of,omitempty"`
// non-disambiguated antonym linkages for the word
Antonyms []LinkageData `json:"antonyms,omitempty"`
// list of non-disambiguated categories for the word
Categories []string `json:"categories,omitempty"`
// non-disambiguated coordinate term linkages for the word
CoordinateTerms []LinkageData `json:"coordinate_terms,omitempty"`
// non-disambiguated derived word linkages for the word
Derived []LinkageData `json:"derived,omitempty"`
Descendants []DescendantData `json:"descendants,omitempty"`
EtymologyExamples []EtymologyExample `json:"etymology_examples,omitempty"`
// for words with multiple numbered etymologies, this contains the number
// of the etymology under which this entry appeared
EtymologyNumber *string `json:"etymology_number,omitempty"`
// templates and their arguments and expansions from the etymology section
EtymologyTemplates []TemplateData `json:"etymology_templates,omitempty"`
// etymology section as cleaned text
EtymologyText *string `json:"etymology_text,omitempty"`
FormOf []FormOf `json:"form_of,omitempty"`
// list of inflected or alternative forms specified for the word (e.g.,
// plural, comparative, superlative, roman script version). Each form has
// a `form` key and a `tags` key identifying what type of form it is.
// May also contain "ipa", "roman", and "source" fields.
Forms []FormData `json:"forms,omitempty"`
HeadTemplates []TemplateData `json:"head_templates,omitempty"`
Holonyms []LinkageData `json:"holonyms,omitempty"`
Hyphenation *DeprecatedHyphenation `json:"hyphenation,omitempty"` // Being deprecated.
Hyphenations []Hyphenation `json:"hyphenations,omitempty"`
// non-disambiguated hypernym linkages for the word
Hypernyms []LinkageData `json:"hypernyms,omitempty"`
// non-disambiguated hyponym linkages for the word
Hyponyms []LinkageData `json:"hyponyms,omitempty"`
// conjugation and declension templates found for the word
InflectionTemplates []TemplateData `json:"inflection_templates,omitempty"`
InfoTemplates []TemplateData `json:"info_templates,omitempty"`
Instances []LinkageData `json:"instances,omitempty"`
LiteralMeaning string `json:"literal_meaning"`
// non-disambiguated linkages indicating having a part (fairly rare)
Meronyms []LinkageData `json:"meronyms,omitempty"`
OriginalTitle string `json:"original_title"`
// part-of-speech, such as "noun", "verb", "adj", "adv", "pron",
// "determiner", "prep" (preposition), "postp" (postposition)
Pos string `json:"pos"`
Proverbs []LinkageData `json:"proverbs,omitempty"`
Redirects []string `json:"redirects,omitempty"`
// non-disambiguated related word linkages for the word
Related []LinkageData `json:"related,omitempty"`
// list of word senses for this word/part-of-speech
Senses []SenseData `json:"senses,omitempty"`
Sounds []SoundData `json:"sounds,omitempty"`
Synonyms []LinkageData `json:"synonyms,omitempty"`
Translations []TranslationData `json:"translations,omitempty"`
Troponyms []LinkageData `json:"troponyms,omitempty"`
// non-disambiguated Wikidata identifier
Wikidata []string `json:"wikidata,omitempty"`
Wikipedia []string `json:"wikipedia,omitempty"`
Anagrams []LinkageData `json:"anagrams,omitempty"`
}
WordDataDetails contains the detailed fields for a word entry. See: https://github.com/tatuylonen/wiktextract#format-of-the-extracted-word-entries