Class: Langue::Japanese::Verb
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
26
27
28
29
|
# File 'lib/langue/japanese/words/verb.rb', line 17
def take(morphemes, index)
if first_verb?(morphemes, index)
take_verb(morphemes, index)
elsif verb_prefix?(morphemes, index)
take_verb_with_prefix(morphemes, index)
elsif first_noun?(morphemes, index)
take_noun_conjunct_to_suru(morphemes, index)
elsif noun_prefix?(morphemes, index)
take_noun_with_prefix_conjunct_to_suru(morphemes, index)
else
0
end
end
|
.take_noun_conjunct_to_suru(morphemes, index) ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'lib/langue/japanese/words/verb.rb', line 44
def take_noun_conjunct_to_suru(morphemes, index)
size = 0
size += 1 while following_noun?(morphemes, index + size)
return 0 unless size > 0
return 0 unless noun_conjunct_to_suru?(morphemes, index + size - 1)
return 0 unless suru_verb?(morphemes, index + size)
size + take_following_verb(morphemes, index + size)
end
|
.take_noun_with_prefix_conjunct_to_suru(morphemes, index) ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/langue/japanese/words/verb.rb', line 53
def take_noun_with_prefix_conjunct_to_suru(morphemes, index)
size = 0
size += 1 while noun_prefix?(morphemes, index + size)
return 0 unless size > 0
next_size = take_noun_conjunct_to_suru(morphemes, index + size)
next_size > 0 ? size + next_size : 0
end
|
.take_verb(morphemes, index) ⇒ Object
31
32
33
34
|
# File 'lib/langue/japanese/words/verb.rb', line 31
def take_verb(morphemes, index)
return 0 unless first_verb?(morphemes, index)
take_following_verb(morphemes, index)
end
|
.take_verb_with_prefix(morphemes, index) ⇒ Object
36
37
38
39
40
41
42
|
# File 'lib/langue/japanese/words/verb.rb', line 36
def take_verb_with_prefix(morphemes, index)
size = 0
size += 1 while verb_prefix?(morphemes, index + size)
return 0 unless size > 0
next_size = take_verb(morphemes, index + size)
next_size > 0 ? size + next_size : 0
end
|
Instance Method Details
#key_morpheme ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
|
# File 'lib/langue/japanese/words/verb.rb', line 71
def key_morpheme
unless instance_variable_defined?(:@key_morpheme)
@key_morpheme = if empty?
nil
else
index = size - 1
index -= 1 while !self.class.body_verb?(morphemes, index)
self[index]
end
end
@key_morpheme
end
|
#prefix_morphemes ⇒ Object
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# File 'lib/langue/japanese/words/verb.rb', line 85
def prefix_morphemes
@prefix_morphemes ||= begin
size = 0
if self.class.verb_prefix?(morphemes, size)
size += 1 while self.class.verb_prefix?(morphemes, size)
elsif self.class.noun_prefix?(morphemes, size)
size += 1 while self.class.noun_prefix?(morphemes, size)
end
morphemes[0, size]
end
end
|