github.com/fluhus/gostuff@v0.4.1-0.20240331134726-be71864f2b5d/nlp/wordnet/types.go (about)

     1  package wordnet
     2  
     3  // WordNet is an entire wordnet database.
     4  type WordNet struct {
     5  	// Maps from synset ID to synset.
     6  	Synset map[string]*Synset `json:"synset"`
     7  
     8  	// Maps from pos.lemma to synset IDs that contain it.
     9  	Lemma map[string][]string `json:"lemma"`
    10  
    11  	// Like Lemma, but synsets are ordered from the most frequently used to the
    12  	// least. Only a subset of the synsets are ranked, so LemmaRanked has less
    13  	// synsets.
    14  	LemmaRanked map[string][]string `json:"lemmaRanked"`
    15  
    16  	// Maps from exceptional word to its forms.
    17  	Exception map[string][]string `json:"exception"`
    18  
    19  	// Maps from example ID to sentence template. Using string keys for JSON
    20  	// compatibility.
    21  	Example map[string]string `json:"example"`
    22  }
    23  
    24  // Synset is a set of synonymous words.
    25  type Synset struct {
    26  	// Synset offset, also used as an identifier.
    27  	Offset string `json:"offset"`
    28  
    29  	// Part of speech, including 's' for adjective satellite.
    30  	Pos string `json:"pos"`
    31  
    32  	// Words in this synset.
    33  	Word []string `json:"word"`
    34  
    35  	// Pointers to other synsets.
    36  	Pointer []*Pointer `json:"pointer"`
    37  
    38  	// Sentence frames for verbs.
    39  	Frame []*Frame `json:"frame"`
    40  
    41  	// Lexical definition.
    42  	Gloss string `json:"gloss"`
    43  
    44  	// Usage examples for words in this synset. Verbs only.
    45  	Example []*Example `json:"example"`
    46  }
    47  
    48  // A Frame links a synset word to a generic phrase that illustrates how to use
    49  // it. Applies to verbs only.
    50  //
    51  // See the list of frames here:
    52  // https://wordnet.princeton.edu/man/wninput.5WN.html#sect4
    53  type Frame struct {
    54  	// Index of word in the containing synset, -1 for entire synset.
    55  	WordNumber int `json:"wordNumber"`
    56  
    57  	// Frame number on the WordNet site.
    58  	FrameNumber int `json:"frameNumber"`
    59  }
    60  
    61  // A Pointer denotes a semantic relation between one synset/word to another.
    62  //
    63  // See list of pointer symbols here:
    64  // https://wordnet.princeton.edu/man/wninput.5WN.html#sect3
    65  type Pointer struct {
    66  	// Relation between the 2 words. Target is <symbol> to source. See
    67  	// package constants for meaning of symbols.
    68  	Symbol string `json:"symbol"`
    69  
    70  	// Target synset ID.
    71  	Synset string `json:"synset"`
    72  
    73  	// Index of word in source synset, -1 for entire synset.
    74  	Source int `json:"source"`
    75  
    76  	// Index of word in target synset, -1 for entire synset.
    77  	Target int `json:"target"`
    78  }
    79  
    80  // An Example links a synset word to an example sentence. Applies to verbs only.
    81  type Example struct {
    82  	// Index of word in the containing synset.
    83  	WordNumber int `json:"wordNumber"`
    84  
    85  	// Number of template in the WordNet.Example field.
    86  	TemplateNumber int `json:"templateNumber"`
    87  }