class Zenlish::Lex::Lexeme

A word in the abstract sense; an individual, distinct item of a lexicon that belongs to a word class and of which a number of actual word forms may exist. For instance, the word forms: 'hide', 'hides', 'hid', 'hidden' relate to the lexeme for verb 'hide'. Also called 'dictionary word'.

Attributes

wclass[R]

@return [Zenlish::WClasses::WordClass] the word class to which the lexeme belongs

Public Class Methods

new(aWClass, anEntry, aFeatureHash = nil) click to toggle source

@param aWClass [WClasses::WordClass, Rley::Syntax::Terminal] @param anEntry [Zenlish::LexicalEntry] @param aFeatureHash [Hash, NilClass]

# File lib/zenlish/lex/lexeme.rb, line 19
def initialize(aWClass, anEntry, aFeatureHash = nil)
  @wclass = aWClass
  @entry = anEntry.object_id
  anEntry.add_lexeme(self)
  if aWClass.kind_of?(WClasses::WordClass)
    unless wclass.extension.nil?
      extend(wclass.extension)
      init_extension(self)
    end
    p_struct = aWClass.kind_of?(WClasses::WordClass) ? aWClass.struct : nil
    overriding_struct_defs = aFeatureHash.nil? ? {} : aFeatureHash
    init_struct_def(p_struct, overriding_struct_defs)
  end
end

Public Instance Methods

all_inflections() click to toggle source
# File lib/zenlish/lex/lexeme.rb, line 47
def all_inflections
  table = paradigm
  table.all_inflections(self)
end
base_form()
Alias for: lemma
entry() click to toggle source

@return [Zenlish::Lex::LexicalEntry] Link to its dictionary entry (headword)

# File lib/zenlish/lex/lexeme.rb, line 35
def entry
  ObjectSpace._id2ref(@entry)
end
inflect(constraints) click to toggle source

Inflect the lexeme according the default paradigm of the word class. @param constraints [Array] Array of values (for each heading of inflection table @return [String] The word form (spelling) inflected to the given contraints.

# File lib/zenlish/lex/lexeme.rb, line 42
def inflect(constraints)
  table = paradigm
  table.inflect(self, constraints)
end
lemma() click to toggle source

@return [String] the base (dictionary) form.

# File lib/zenlish/lex/lexeme.rb, line 53
def lemma
  entry.lemma
end
Also aliased as: base_form
paradigm() click to toggle source

Return the inflection paradigm for the lexeme. @return [Inflect::InflectionTable]

# File lib/zenlish/lex/lexeme.rb, line 59
def paradigm
  paradigm_feat_def = self['PARADIGM']
  wclass.paradigms[paradigm_feat_def.default.val]
end