class Uwn::Api::Statement
Wrapper class for UWN Statement
equivalent (with some abstracter function)
Attributes
parent[RW]
statements[RW]
Public Class Methods
new(options={})
click to toggle source
Statement
constructor
# File lib/uwn/api/statement.rb, line 10 def initialize options={} self.parent = options[:parent] if options.include? :parent @object = options[:object] if options.include? :object self.statements = [] @parent_language = Util.parent_root(self).language end
Public Instance Methods
glosses()
click to toggle source
get filtered glosses from synset
# File lib/uwn/api/statement.rb, line 108 def glosses self.predicate_match "rel:has_gloss" end
has_synset?()
click to toggle source
is the current object referenced to a synset?
# File lib/uwn/api/statement.rb, line 40 def has_synset? self.synset.is_a? String end
is_lexical_category?()
click to toggle source
# File lib/uwn/api/statement.rb, line 44 def is_lexical_category? @object.get_predicate.to_s == "rel:lexical_category" end
is_subclass?()
click to toggle source
# File lib/uwn/api/statement.rb, line 48 def is_subclass? @object.get_predicate.to_s == "rel:subclass" end
is_synonym?()
click to toggle source
match current to the Meaning
(root object) language
# File lib/uwn/api/statement.rb, line 35 def is_synonym? @object.get_object.get_term_language == @parent_language end
language()
click to toggle source
language of object
# File lib/uwn/api/statement.rb, line 23 def language @object.get_object.get_term_language end
lexcat()
click to toggle source
word lexcat (noun, verb, adj etc.)
# File lib/uwn/api/statement.rb, line 28 def lexcat match = @object.get_object.to_s.match(/lexcat:([a-z]+)/) return match[1] unless match.nil? nil end
lexical_categories()
click to toggle source
get filtered categories (word types ex. verb, noun) from synset
# File lib/uwn/api/statement.rb, line 87 def lexical_categories self.predicate_match "rel:lexical_category" end
lexicalizations()
click to toggle source
get filtered lexicalizations (translations) from synset
# File lib/uwn/api/statement.rb, line 92 def lexicalizations self.predicate_match "rel:lexicalization" end
object()
click to toggle source
object of object (raw object)
# File lib/uwn/api/statement.rb, line 58 def object @object.get_object end
predicate()
click to toggle source
predicate object (tells something about the object)
# File lib/uwn/api/statement.rb, line 63 def predicate @object.get_predicate end
subclasses()
click to toggle source
get filtered subclasses from synset
# File lib/uwn/api/statement.rb, line 103 def subclasses self.predicate_match "rel:subclass" end
subject()
click to toggle source
subject object
# File lib/uwn/api/statement.rb, line 53 def subject @object.get_subject end
synonyms()
click to toggle source
get filtered synonyms from synset
# File lib/uwn/api/statement.rb, line 97 def synonyms sts = self.predicate_match "rel:lexicalization" sts.reject{|t| !t.is_synonym? } end
synset()
click to toggle source
synset for current statement (not tested, depends on predicate!)
# File lib/uwn/api/statement.rb, line 77 def synset unless @object.nil? os = @object.get_object.to_s return os unless os.match(/([s][\/][a-z]){1}[0-9]+/).nil? su = @object.get_subject.to_s return su unless su.match(/([s][\/][a-z]){1}[0-9]+/).nil? end end
synsets()
click to toggle source
get raw synsets
# File lib/uwn/api/statement.rb, line 113 def synsets self.predicate_match end
term_str()
click to toggle source
term name as a string
# File lib/uwn/api/statement.rb, line 18 def term_str @object.get_object.get_term_str end
to_s()
click to toggle source
# File lib/uwn/api/statement.rb, line 72 def to_s @object.get_subject.to_s end
weight()
click to toggle source
weight of the link
# File lib/uwn/api/statement.rb, line 68 def weight @object.get_weight end
Protected Instance Methods
lookup_synset(synset)
click to toggle source
get unique synsets from uwn
# File lib/uwn/api/statement.rb, line 129 def lookup_synset synset root = Util.parent_root self root.connect.statements(synset) end
predicate_match(predicate_name = nil)
click to toggle source
get predicates (with or without name filter)
# File lib/uwn/api/statement.rb, line 120 def predicate_match predicate_name = nil return [] if self.synset.nil? sts = self.lookup_synset self.synset sts.map!{|s| Statement.new(parent: self, object: s) } return sts.reject{|t| t.predicate.to_s != predicate_name} unless predicate_name.nil? sts end