Method: WordNet::Synset#to_s

Defined in:
lib/wordnet/synset.rb

#to_sObject

Stringify the synset.



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/wordnet/synset.rb', line 423

def to_s

  # Make a sorted list of the semantic link types from this synset
  semlink_list = self.semlinks_dataset.
    group_and_count( :linkid ).
    to_hash( :linkid, :count ).
    collect do |linkid, count|
      '%s: %d' % [ self.class.linktype_table[linkid][:typename], count ]
    end.
    sort.
    join( ', ' )

  return "%s (%s): [%s] %s (%s)" % [
    self.words.map( &:to_s ).join(', '),
    self.part_of_speech,
    self.lexical_domain,
    self.definition,
    semlink_list
  ]
end