Sha256: ee68f4007d2ed479bf33a95f43359b6833a58f88e00feddb8540ef1f73caeab7

Contents?: true

Size: 1.55 KB

Versions: 1

Compression:

Stored size: 1.55 KB

Contents

require_relative '../feature/feature_struct_def_bearer'
module Zenlish
  module Lex
    # 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'.
    class Lexeme
      include Feature::FeatureStructDefBearer
      
      # @return [Zenlish::WClasses::WordClass]
      attr_reader :wclass

      # @param aWClass [WClasses::WordClass, Rley::Syntax::Terminal]
      # @param anEntry [Zenlish::LexicalEntry]
      # @param aFeatureHash [Hash, NilClass]
      def initialize(aWClass, anEntry, aFeatureHash = nil)
        @wclass = aWClass
        @entry = anEntry.object_id
        anEntry.add_lexeme(self)
        
        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

      # @return [Zenlish::Lex::LexicalEntry]
      def entry
        ObjectSpace._id2ref(@entry)
      end
      
      def inflect(constraints)
        table = paradigm
        table.inflect(self, constraints)
      end

      # @return [String]
      def lemma
        entry.lemma
      end

      def paradigm
        paradigm_feat_def = self['PARADIGM']
        wclass.paradigms[paradigm_feat_def.default.val]      
      end
      
      alias base_form lemma
    end # class
  end # module
end # module

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
zenlish-0.2.00 lib/zenlish/lex/lexeme.rb