class Cadmium::Wordnet::Synset
- Cadmium::Wordnet::Synset
- Reference
- Object
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.crConstructors
-
.new(pos : Lemma::POS, offset : Int32)
Create a new synset by reading from the data file specified by pos, at offset bytes into the file.
Class Method Summary
- ._apply_rules(forms, pos : Lemma::POS)
- ._filter_forms(forms, pos : Lemma::POS)
-
.data_dir : String
Wordnet data diretctory
-
.data_dir=(data_dir : String)
Wordnet data diretctory
-
.find(word : String, pos : Lemma::POS)
Similar to the method
Lemma#find
, but returns a list of Synsets instead of a Lemma -
.find_all(word)
Similar to the method
Lemma#find_all
, but returns Synsets instead of Lemmas - .load_exception_map
-
.morphy(form, pos : Lemma::POS)
Get the root of a form by pos
-
.morphy(form)
Get all roots of a form regardless of part of speech
Instance Method Summary
-
#antonyms
Get the Synsets of this sense's antonym
-
#expanded_first_hypernyms
Get the entire hypernym tree (from this synset all the way up to entity) as an array.
-
#expanded_hypernyms
Get the entire hypernym tree (from this synset all the way up to entity) as an array.
- #expanded_hypernyms_depth
-
#gloss : String
Get a string representation of this synset's gloss.
-
#hypernym
Get the parent synset (higher-level category, i.e.
-
#hypernyms
Get the parent synset (higher-level category, i.e.
-
#hyponyms
Get the child synset(s) (i.e., lower-level categories, i.e.
-
#lex_filenum : Int32
A two digit decimal integer representing the name of the lexicographer file containing the synset for the sense.
-
#pos : String
Get a shorthand representation of the part of speech this synset represents, e.g.
-
#pos_offset : Int32
Get the offset, in bytes, at which this synset's POS information is stored in Wordnet's internal DB.
-
#relation(pointer_symbol)
Get an array of Synsets with the relation
pointer_symbol
relative to this Synset. -
#synonyms
Get the synonyms (hypernyms and hyponyms) for this Synset
-
#synset_offset : String
Get the offset, in bytes, at which this synset's information is stored in Wordnet's internal DB.
-
#synset_type : String
Get the part of speech type of this synset.
-
#to_s(io)
Returns a compact, human-readable form of this synset, e.g.
-
#word_count
How many words does this Synset include?
-
#word_counts : Hash(String, Int32)
Get the list of words (and their frequencies within the Wordnet graph) contained in this Synset.
-
#words
Get a list of words included in this Synset
Constructor Detail
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.
Class Method Detail
Similar to the method Lemma#find
, but returns a list of Synsets instead of a Lemma
Similar to the method Lemma#find_all
, but returns Synsets instead of Lemmas
Instance Method Detail
Get the entire hypernym tree (from this synset all the way up to entity) as an array.
Get the entire hypernym tree (from this synset all the way up to entity) as an array.
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"
Get the parent synset (higher-level category, i.e. fruit -> reproductive_structure) as an array.
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.
Get a shorthand representation of the part of speech this synset represents, e.g. "v" for verbs.
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.
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
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.
Get the part of speech type of this synset. One of 'n' (noun), 'v' (verb), 'a' (adjective), or 'r' (adverb)
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."
Get the list of words (and their frequencies within the Wordnet graph) contained in this Synset.