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)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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

Instance Attribute Details

#wclassZenlish::WClasses::WordClass (readonly)

Returns the word class to which the lexeme belongs.

Returns:



14
15
16
# File 'lib/zenlish/lex/lexeme.rb', line 14

def wclass
  @wclass
end

Instance Method Details

#all_inflectionsObject



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

def all_inflections
  table = paradigm
  table.all_inflections(self)
end

#entryZenlish::Lex::LexicalEntry

Returns Link to its dictionary entry (headword).

Returns:



35
36
37
# File 'lib/zenlish/lex/lexeme.rb', line 35

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.



42
43
44
45
# File 'lib/zenlish/lex/lexeme.rb', line 42

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.



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

def lemma
  entry.lemma
end

#paradigmInflect::InflectionTable

Return the inflection paradigm for the lexeme.



59
60
61
62
# File 'lib/zenlish/lex/lexeme.rb', line 59

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