Class: Zenlish::Lex::Lexeme

Inherits:
Object
  • Object
show all
Includes:
Feature::FeatureStructDefBearer
Defined in:
lib/zenlish/lex/lexeme.rb

Overview

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'.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Feature::FeatureStructDefBearer

#[], #boolean, #enumeration, #feature_def, #feature_def_dsl, #identifier, #init_struct_def, #struct

Constructor Details

#initialize(aWClass, anEntry, aFeatureHash = nil) ⇒ Lexeme

Returns a new instance of Lexeme.

Parameters:

  • aWClass (WClasses::WordClass, Rley::Syntax::Terminal)
  • anEntry (Zenlish::LexicalEntry)
  • aFeatureHash (Hash, NilClass) (defaults to: nil)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/zenlish/lex/lexeme.rb', line 17

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?
      self.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

Instance Attribute Details

#wclassZenlish::WClasses::WordClass (readonly)

Returns the word class to which the lexeme belongs.

Returns:



12
13
14
# File 'lib/zenlish/lex/lexeme.rb', line 12

def wclass
  @wclass
end

Instance Method Details

#entryZenlish::Lex::LexicalEntry

Returns Link to its dictionary entry (headword).

Returns:



33
34
35
# File 'lib/zenlish/lex/lexeme.rb', line 33

def entry
  ObjectSpace._id2ref(@entry)
end

#inflect(constraints) ⇒ String

Inflect the lexeme according the default paradigm of the word class.

Parameters:

  • constraints (Array)

    Array of values (for each heading of inflection table

Returns:

  • (String)

    The word form (spelling) inflected to the given contraints.



40
41
42
43
# File 'lib/zenlish/lex/lexeme.rb', line 40

def inflect(constraints)
  table = paradigm
  table.inflect(self, constraints)
end

#lemmaString Also known as: base_form

Returns the base (dictionary) form.

Returns:

  • (String)

    the base (dictionary) form.



46
47
48
# File 'lib/zenlish/lex/lexeme.rb', line 46

def lemma
  entry.lemma
end

#paradigmInflect::InflectionTable

Return the inflection paradigm for the lexeme.



52
53
54
55
# File 'lib/zenlish/lex/lexeme.rb', line 52

def paradigm
  paradigm_feat_def = self['PARADIGM']
  wclass.paradigms[paradigm_feat_def.default.val]
end