Sha256: fd41651bce977d7ea8e321f6599ae1fec78192ceef6ed61475c330f85dcf2625

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

# -*- ruby -*-
#encoding: utf-8

require 'wordnet' unless defined?( WordNet )
require 'wordnet/constants'
require 'wordnet/model'

# WordNet semantic link (pointer) model class
class WordNet::SemanticLink < WordNet::Model( :semlinks )
	include WordNet::Constants


	set_primary_key [:synset1id, :synset2id, :linkid]

	many_to_one :origin,
		:class       => :"WordNet::Synset",
		:key         => :synset1id,
		:primary_key => :synsetid

	one_to_one :target,
		:class       => :"WordNet::Synset",
		:key         => :synsetid,
		:primary_key => :synset2id,
		:eager       => :words


	######
	public
	######

	### Return a stringified version of the SemanticLink.
	def to_s
		return "%s: %s (%s)" % [
			self.type,
			self.target.words.map( &:to_s ).join( ', ' ),
			self.target.pos,
		]
	end


	### Return the type of link as a Symbol.
	def type
		return WordNet::Synset.linktype_table[ self.linkid ][ :type ]
	end


	### Return the name of the link type as a String.
	def typename
		return WordNet::Synset.linktype_table[ self.linkid ][ :typename ]
	end

end # class WordNet::SemanticLink

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordnet-1.0.1 lib/wordnet/semanticlink.rb