Sha256: 47fb31712e89184322f842a5a437aee4187f32d5e45d4c991e18dc12d2c1bed2
Contents?: true
Size: 1.55 KB
Versions: 2
Compression:
Stored size: 1.55 KB
Contents
#!/usr/bin/ruby require 'wordnet' unless defined?( WordNet ) require 'wordnet/model' # WordNet sense model class class WordNet::Sense < WordNet::Model( :senses ) include WordNet::Constants set_primary_key :senseid many_to_one :synset, :key => :synsetid many_to_one :word, :key => :wordid # Sense -> [ LexicalLinks ] -> [ Synsets ] one_to_many :lexlinks, :class => :"WordNet::LexicalLink", :key => [ :synset1id, :word1id ], :primary_key => [ :synsetid, :wordid ] ### Generate a method that will return Synsets related by the given lexical pointer ### +type+. def self::lexical_link( type, typekey=nil ) typekey ||= type.to_s.chomp( 's' ).to_sym WordNet.log.debug "Generating a %p method for %p links" % [ type, typekey ] method_body = Proc.new do linkinfo = WordNet::Synset.linktype_names[ typekey ] or raise ScriptError, "no such link type %p" % [ typekey ] ssids = self.lexlinks_dataset.filter( :linkid => linkinfo[:id] ).select( :synset2id ) self.class.filter( :synsetid => ssids ) end WordNet.log.debug " method body is: %p" % [ method_body ] define_method( type, &method_body ) end lexical_link :also_see, :also lexical_link :antonym lexical_link :derivation lexical_link :domain_categories, :domain_category lexical_link :domain_member_categories, :domain_member_category lexical_link :domain_member_region lexical_link :domain_member_usage lexical_link :domain_region lexical_link :domain_usage lexical_link :participle lexical_link :pertainym lexical_link :verb_group end # class WordNet::Sense
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
wordnet-1.0.0.pre.127 | lib/wordnet/sense.rb |
wordnet-1.0.0.pre.126 | lib/wordnet/sense.rb |