Class: Lingo::Language::Word
- Inherits:
-
WordForm
show all
- Defined in:
- lib/lingo/language/word.rb
Overview
Die Klasse Word bündelt spezifische Eigenschaften eines Wortes mit den dazu
notwendigen Methoden.
Instance Attribute Summary
Attributes inherited from WordForm
#attr, #form, #src
Class Method Summary
(collapse)
Instance Method Summary
(collapse)
Methods inherited from WordForm
#eql?, #hash, #identified?, #inspect, #to_a, #unknown?
Constructor Details
- (Word) initialize(form, attr = WA_UNSET)
Exakte Representation der originären Zeichenkette, so wie sie im Satz
gefunden wurde, z.B. form = "RubyLing"
Ergebnis der Wörterbuch-Suche. Sie stellt die Grundform des Wortes dar.
Dabei kann es mehrere mögliche Grundformen geben, z.B. kann
abgeschoben als Grundform das Adjektiv
abgeschoben sein, oder aber das Verb abschieben.
lemma = [['abgeschoben', '#a'], ['abschieben',
'#v']].
Achtung: Lemma wird nicht durch die Word-Klasse bestückt, sondern extern
durch die Klasse Dictionary
61
62
63
64
|
# File 'lib/lingo/language/word.rb', line 61
def initialize(form, attr = WA_UNSET)
super
@lexicals = []
end
|
Class Method Details
+ (Object) new_lexical(form, attr, lex_attr)
42
43
44
|
# File 'lib/lingo/language/word.rb', line 42
def new_lexical(form, attr, lex_attr)
new_lexicals(form, attr, Lexical.new(form, lex_attr))
end
|
+ (Object) new_lexicals(form, attr, lex)
38
39
40
|
# File 'lib/lingo/language/word.rb', line 38
def new_lexicals(form, attr, lex)
new(form, attr) << lex
end
|
Instance Method Details
- (Object) <<(*other)
125
126
127
128
129
|
# File 'lib/lingo/language/word.rb', line 125
def <<(*other)
other.flatten!
lexicals.concat(other)
self
end
|
- (Object) <=>(other)
131
132
133
|
# File 'lib/lingo/language/word.rb', line 131
def <=>(other)
other.nil? ? 1 : to_a.push(lexicals) <=> other.to_a.push(other.lexicals)
end
|
- (Object) add_lexicals(lex)
82
83
84
85
86
87
|
# File 'lib/lingo/language/word.rb', line 82
def add_lexicals(lex)
unless lex.empty?
@lexicals.concat(lex).uniq!
@lexicals.sort!
end
end
|
- (Object) attrs(compound_parts = true)
89
90
91
|
# File 'lib/lingo/language/word.rb', line 89
def attrs(compound_parts = true)
lexicals(compound_parts).map { |i| i.attr }
end
|
117
118
119
|
# File 'lib/lingo/language/word.rb', line 117
def compo_form
get_class(LA_COMPOUND).first if attr == WA_COMPOUND
end
|
- (Boolean) full_compound?
121
122
123
|
# File 'lib/lingo/language/word.rb', line 121
def full_compound?
attr == WA_COMPOUND && get_class('x+').empty?
end
|
- (Object) get_class(wc_re)
Gibt genau die Grundform der Wortklasse zurück, die der RegExp des
Übergabe-Parameters entspricht, z.B. word.get_wc(/a/) =
['abgeschoben', '#a']
103
104
105
106
107
108
109
110
111
|
# File 'lib/lingo/language/word.rb', line 103
def get_class(wc_re)
wc_re = Regexp.new(wc_re) unless wc_re.is_a?(Regexp)
unless lexicals.empty?
lexicals.select { |lex| lex.attr =~ wc_re }
else
attr =~ wc_re ? [self] : []
end
end
|
- (Object) lexicals(compound_parts = true)
66
67
68
69
70
71
72
|
# File 'lib/lingo/language/word.rb', line 66
def lexicals(compound_parts = true)
if !compound_parts && attr == WA_COMPOUND
@lexicals.select { |lex| lex.attr == LA_COMPOUND }
else
@lexicals
end
end
|
- (Object) lexicals=(lex)
74
75
76
77
78
79
80
|
# File 'lib/lingo/language/word.rb', line 74
def lexicals=(lex)
if lex.is_a?(Array)
@lexicals = lex.sort.uniq
else
raise TypeError, "wrong argument type #{lex.class} (expected Array)"
end
end
|
- (Object) min_part_size
97
98
99
|
# File 'lib/lingo/language/word.rb', line 97
def min_part_size
form.length
end
|
- (Object) norm
113
114
115
|
# File 'lib/lingo/language/word.rb', line 113
def norm
identified? ? lexicals.first.form : form
end
|
- (Object) parts
93
94
95
|
# File 'lib/lingo/language/word.rb', line 93
def parts
1
end
|
- (Object) to_s
135
136
137
138
139
140
|
# File 'lib/lingo/language/word.rb', line 135
def to_s
s = "<#{form}"
s << "|#{attr}" unless identified?
s << " = #{lexicals.inspect}" unless lexicals.empty?
s << '>'
end
|