Class: Langue::Japanese::Adjective
- Inherits:
-
Word
- Object
- Word
- Langue::Japanese::Adjective
show all
- Extended by:
- Classifier
- Includes:
- Attribute, Prefix
- Defined in:
- lib/langue/japanese/words/adjective.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Classifier
body_adjective?, body_verb?, first_adjective?, first_noun?, first_verb?, following_adjective?, following_noun?, following_symbol?, following_verb?, progressive_verb?, suru_verb?
Methods included from Attribute
#body, included, #index
Methods included from Prefix
included, #prefix
Class Method Details
.take(morphemes, index) ⇒ Object
17
18
19
20
21
22
23
24
25
|
# File 'lib/langue/japanese/words/adjective.rb', line 17
def take(morphemes, index)
if first_adjective?(morphemes, index)
take_adjective(morphemes, index)
elsif adjective_prefix?(morphemes, index)
take_adjective_with_prefix(morphemes, index)
else
0
end
end
|
.take_adjective(morphemes, index) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/langue/japanese/words/adjective.rb', line 27
def take_adjective(morphemes, index)
return 0 unless first_adjective?(morphemes, index)
size = 1
size += 1 while following_adjective?(morphemes, index + size) || conjunctive_particle?(morphemes, index + size) && following_adjective?(morphemes, index + size + 1)
size += 1 while auxiliary_verb?(morphemes, index + size)
size
end
|
.take_adjective_with_prefix(morphemes, index) ⇒ Object
35
36
37
38
39
40
41
|
# File 'lib/langue/japanese/words/adjective.rb', line 35
def take_adjective_with_prefix(morphemes, index)
size = 0
size += 1 while adjective_prefix?(morphemes, index + size)
return 0 unless size > 0
next_size = take_adjective(morphemes, index + size)
next_size > 0 ? size + next_size : 0
end
|
Instance Method Details
#key_morpheme ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/langue/japanese/words/adjective.rb', line 44
def key_morpheme
unless instance_variable_defined?(:@key_morpheme)
@key_morpheme = if empty?
nil
else
index = size - 1
index -= 1 while !self.class.body_adjective?(morphemes, index)
self[index]
end
end
@key_morpheme
end
|
#prefix_morphemes ⇒ Object
58
59
60
61
62
63
64
|
# File 'lib/langue/japanese/words/adjective.rb', line 58
def prefix_morphemes
@prefix_morphemes ||= begin
size = 0
size += 1 while self.class.adjective_prefix?(morphemes, size)
morphemes[0, size]
end
end
|