Class: Lingo::Language::WordForm

Inherits:
Object
  • Object
show all
Includes:
Comparable
Defined in:
lib/lingo/language/word_form.rb

Overview

Die Klasse WordForm ist die Basisklasse für weitere Klassen, die im Rahmen der Objektstruktur eines Wortes benötigt werden. Die Klasse stellt eine Zeichenkette bereit, die mit einem Attribut versehen werden kann.

Direct Known Subclasses

Lexical, Token, Word

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (WordForm) initialize(form, attr = WA_UNSET, src = nil)

Returns a new instance of WordForm



39
40
41
42
# File 'lib/lingo/language/word_form.rb', line 39

def initialize(form, attr = WA_UNSET, src = nil)
  attr, @gender = attr
  @form, @attr, @src = form || '', attr || '', src
end

Instance Attribute Details

- (Object) attr

Returns the value of attribute attr



44
45
46
# File 'lib/lingo/language/word_form.rb', line 44

def attr
  @attr
end

- (Object) form

Returns the value of attribute form



44
45
46
# File 'lib/lingo/language/word_form.rb', line 44

def form
  @form
end

- (Object) gender

Returns the value of attribute gender



44
45
46
# File 'lib/lingo/language/word_form.rb', line 44

def gender
  @gender
end

- (Object) head

Returns the value of attribute head



44
45
46
# File 'lib/lingo/language/word_form.rb', line 44

def head
  @head
end

- (Object) src

Returns the value of attribute src



44
45
46
# File 'lib/lingo/language/word_form.rb', line 44

def src
  @src
end

Instance Method Details

- (Object) <=>(other)



54
55
56
# File 'lib/lingo/language/word_form.rb', line 54

def <=>(other)
  other.nil? ? 1 : to_a <=> other.to_a
end

- (Boolean) eql?(other) Also known as: ==

Returns:

  • (Boolean)


74
75
76
# File 'lib/lingo/language/word_form.rb', line 74

def eql?(other)
  self.class.equal?(other.class) && (self <=> other) == 0
end

- (Object) hash



70
71
72
# File 'lib/lingo/language/word_form.rb', line 70

def hash
  to_a.hash
end

- (Boolean) identified?

Returns:

  • (Boolean)


50
51
52
# File 'lib/lingo/language/word_form.rb', line 50

def identified?
  attr == WA_IDENTIFIED
end

- (Object) inspect



66
67
68
# File 'lib/lingo/language/word_form.rb', line 66

def inspect
  to_s
end

- (Object) to_a



58
59
60
# File 'lib/lingo/language/word_form.rb', line 58

def to_a
  [form, attr, gender].compact
end

- (Object) to_s



62
63
64
# File 'lib/lingo/language/word_form.rb', line 62

def to_s
  to_a.join('/')
end

- (Boolean) unknown?

Returns:

  • (Boolean)


46
47
48
# File 'lib/lingo/language/word_form.rb', line 46

def unknown?
  [WA_UNKNOWN, WA_UNKMULPART].include?(attr)
end