class Cadmium::WordNet::Synset

Overview

Represents a synset (or group of synonymous words) in WordNet. Synsets are related to each other by various (and numerous!) relationships, including Hypernym (x is a hypernym of y <=> x is a parent of y) and Hyponym (x is a child of y)

Defined in:

cadmium/wordnet/synset.cr

Constructors

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(pos, offset : Int32) #

Create a new synset by reading from the data file specified by pos, at offset bytes into the file. This is how the WordNet database is organized. You shouldn't be creating Synsets directly; instead, use Lemma#synsets.


[View source]

Class Method Detail

def self._apply_rules(forms, pos) #

[View source]
def self._filter_forms(forms, pos) #

[View source]
def self.find(word, pos) #

Similar to the method Lemma#find, but returns a list of Synsets instead of a Lemma


[View source]
def self.find_all(word) #

Similar to the method Lemma#find_all, but returns Synsets instead of Lemmas


[View source]
def self.load_exception_map #

[View source]
def self.morphy(form, pos) #

Get the root of a form by pos


[View source]
def self.morphy(form) #

Get all roots of a form regardless of part of speech


[View source]

Instance Method Detail

def antonyms #

Get the Synsets of this sense's antonym


[View source]
def expanded_first_hypernyms #

Get the entire hypernym tree (from this synset all the way up to entity) as an array.


[View source]
def expanded_hypernyms #

Get the entire hypernym tree (from this synset all the way up to entity) as an array.


[View source]
def expanded_hypernyms_depth #

[View source]
def gloss : String #

Get a string representation of this synset's gloss. "Gloss" is a human-readable description of this concept, often with example usage, e.g:

move upward; "The fog lifted"; "The smoke arose from the forest fire"; "The mist uprose from the meadows"

for the second sense of the verb "fall"


[View source]
def hypernym #

Get the parent synset (higher-level category, i.e. fruit -> reproductive_structure).


[View source]
def hypernyms #

Get the parent synset (higher-level category, i.e. fruit -> reproductive_structure) as an array.


[View source]
def hyponyms #

Get the child synset(s) (i.e., lower-level categories, i.e. fruit -> edible_fruit)


[View source]
def lex_filenum : Int32 #

A two digit decimal integer representing the name of the lexicographer file containing the synset for the sense. Probably only of interest if you're using a wordnet database marked up with custom attributes, and you want to ensure that you're using your own additions.


[View source]
def pos : String #

Get a shorthand representation of the part of speech this synset represents, e.g. "v" for verbs.


[View source]
def pos_offset : Int32 #

Get the offset, in bytes, at which this synset's POS information is stored in WordNet's internal DB. You almost certainly don't care about this.


[View source]
def relation(pointer_symbol) #

Get an array of Synsets with the relation pointer_symbol relative to this Synset. Mostly, this is an internal method used by convience methods (e.g. Synset#antonym), but it can take any valid valid pointer_symbol defined in pointers.cr.

Example (get the gloss of an antonym for 'fall'):

lemma = Cadmium::WordNet.lookup("fall", :verb)
puts lemma.synsets[1].relation("!")[0].gloss unless lemma.nil?

NOTE Valid pointer symbols are contained in the constants NOUN_POINTERS, VERB_POINTERS, ADJECTIVE_POINTERS, and ADVERB_POINTERS


[View source]
def synonyms #

Get the synonyms (hypernyms and hyponyms) for this Synset


[View source]
def synset_offset : String #

Get the offset, in bytes, at which this synset's information is stored in WordNet's internal DB. You almost certainly don't care about this.


[View source]
def synset_type : String #

Get the part of speech type of this synset. One of 'n' (noun), 'v' (verb), 'a' (adjective), or 'r' (adverb)


[View source]
def to_s(io) #

Returns a compact, human-readable form of this synset, e.g.

(v) fall (descend in free fall under the influence of gravity; "The branch fell from the tree"; "The unfortunate hiker fell into a crevasse")

for the second meaning of the verb "fall."


[View source]
def word_count #

How many words does this Synset include?


[View source]
def word_counts : Hash(String, Int32) #

Get the list of words (and their frequencies within the WordNet graph) contained in this Synset.


[View source]
def words #

Get a list of words included in this Synset


[View source]