Class WordNet::Synset |
|
"Synonym set" class - encapsulates the data for a set of words in the lexical database that are interchangeable in some context, and provides methods for accessing its relationships.
Methods |
Attributes |
filenum | [RW] | The number corresponding to the lexicographer file name containing the synset. Calling lexInfo will return the actual filename. |
frameslist | [RW] | The list of raw verb sentence frames for this synset. |
gloss | [RW] | Definition and/or example sentences for the Synset. |
lexicon | [R] | The WordNet::Lexicon that was used to look up this synset |
offset | [RW] | The original byte offset of the synset in the data file; acts as the unique identifier (when combined with partOfSpeech) of this Synset in the database. |
partOfSpeech | [RW] | The syntactic category of this Synset. Will be one of the keys of WordNet::SyntacticCategories. |
pointerlist | [RW] | The list of raw pointers to related synsets |
wordlist | [RW] | The raw list of word/lex_id pairs associated with this synset |
Classes and Modules |
Included modules |
Public Class methods |
new( lexicon, offset, pos, word=nil, data=nil ) |
Create a new Synset object in the specified lexicon for the specified word and partOfSpeech. If data is specified, initialize the synset’s other object data from it. This method shouldn’t be called directly: you should use one of the Lexicon class’s factory methods: createSynset, lookupSynsets, or lookupSynsetsByOffset.
Public Instance methods |
inspect() |
Return a human-readable representation of the Synset suitable for debugging.
key() |
Returns the Synset’s unique identifier, made up of its offset and syntactic category catenated together with a ’%’ symbol.
pos() |
The symbol which represents this synset’s syntactic category
glosses() |
Return each of the sentences of the gloss for this synset as an array.
==( otherSyn ) |
Returns true if the receiver and otherSyn are identical according to their offsets.
words() |
Returns an Array of words and/or collocations associated with this synset.
words=( *newWords ) |
Set the words in this synset’s wordlist to newWords
addWords( *newWords ) |
Add the specified newWords to this synset’s wordlist. Alias: add_words.
deleteWords( *oldWords ) |
Delete the specified oldWords from this synset’s wordlist. Alias: delete_words.
to_s() |
Return the synset as a string. Alias: overview.
store() |
Writes any changes made to the object to the database and updates all affected synset data and indexes. If the object passes out of scope before write is called, the changes are lost.
remove() |
Removes this synset from the database.
serialize() |
Returns the synset’s data in a form suitable for storage in the lexicon’s database.
coordinates() |
Returns an Array of the coordinate sisters of the receiver.
lexInfo() |
Return the name of the "lexicographer’s file" associated with this synset.
lexInfo=( id ) |
Sets the "lexicographer’s file" association for this synset to id. The value in id should correspond to one of the values in WordNet::Lexfiles
frames() |
Returns an Array of verb frame +String+s for the synset.
traverse( type, includeOrigin=true ) {| syn, newDepth | ...} |
Traversal iterator: Iterates depth-first over a particular type of the receiver, and all of the pointed-to synset’s pointers. If called with a block, the block is called once for each synset with the foundSyn and its depth in relation to the originating synset as arguments. The first call will be the originating synset with a depth of +0+ unless includeOrigin is false. If the callback returns true, the traversal is halted, and the method returns immediately. This method returns an Array of the synsets which were traversed if no block is given, or a flag which indicates whether or not the traversal was interrupted if a block is given.
distance( type, otherSynset ) |
Returns the distance in pointers between the receiver and otherSynset using type as the search path.
search( type, otherSynset ) |
Recursively searches all of the receiver’s pointers of the specified type for otherSynset, returning true if it is found.
|( otherSyn ) |
Union: Return the least general synset that the receiver and otherSynset have in common as a hypernym, or nil if it doesn’t share any.
pointers() |
Returns the pointers in this synset’s pointerlist as an Array
pointers=( *newPointers ) |
Set the pointers in this synset’s pointerlist to newPointers
pointerMap() |
Returns the synset’s pointers in a Hash keyed by their type.