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

#initialize(form, attr = WA_UNSET, src = nil) ⇒ WordForm

Returns a new instance of WordForm.



41
42
43
44
# File 'lib/lingo/language/word_form.rb', line 41

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

Instance Attribute Details

#attrObject

Returns the value of attribute attr.



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

def attr
  @attr
end

#formObject

Returns the value of attribute form.



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

def form
  @form
end

#genderObject

Returns the value of attribute gender.



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

def gender
  @gender
end

#headObject

Returns the value of attribute head.



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

def head
  @head
end

#srcObject

Returns the value of attribute src.



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

def src
  @src
end

#tokenObject

Returns the value of attribute token.



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

def token
  @token
end

Instance Method Details

#<=>(other) ⇒ Object



60
61
62
# File 'lib/lingo/language/word_form.rb', line 60

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

#eql?(other) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


80
81
82
# File 'lib/lingo/language/word_form.rb', line 80

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

#hashObject



76
77
78
# File 'lib/lingo/language/word_form.rb', line 76

def hash
  to_a.hash
end

#identified?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/lingo/language/word_form.rb', line 52

def identified?
  attr == WA_IDENTIFIED
end

#inspectObject



72
73
74
# File 'lib/lingo/language/word_form.rb', line 72

def inspect
  to_s
end

#to_aObject



64
65
66
# File 'lib/lingo/language/word_form.rb', line 64

def to_a
  [form, attr, gender]
end

#to_sObject



68
69
70
# File 'lib/lingo/language/word_form.rb', line 68

def to_s
  to_a.compact.join('/')
end

#unknown?Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/lingo/language/word_form.rb', line 48

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

#word_token?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/lingo/language/word_form.rb', line 56

def word_token?
  false
end