Class: Langue::Japanese::AdjectiveNoun
- Inherits:
-
Noun
- Object
- Word
- Noun
- Langue::Japanese::AdjectiveNoun
show all
- Extended by:
- Classifier
- Includes:
- Prefix
- Defined in:
- lib/langue/japanese/words/adjective_noun.rb
Constant Summary
Constants inherited
from Noun
Noun::INHIBITED_FIRST_CHARS, Noun::INHIBITED_LAST_CHARS
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 Prefix
included, #prefix
Methods inherited from Noun
take_adverbable_noun, take_noun
Class Method Details
.take(morphemes, index) ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 13
def take(morphemes, index)
if adjective_stem_noun?(morphemes, index)
take_adjective_stem_noun(morphemes, index)
elsif first_noun?(morphemes, index)
take_noun_with_suffix(morphemes, index)
elsif noun_prefix?(morphemes, index)
take_noun_with_prefix(morphemes, index)
else
0
end
end
|
.take_adjective_stem_noun(morphemes, index) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 25
def take_adjective_stem_noun(morphemes, index)
size = 0
size += 1 while adjective_stem_noun?(morphemes, index + size)
return 0 unless size > 0
if adjective_stem_suffix?(morphemes, index + size)
size
elsif following_noun?(morphemes, index + size)
0
else
size
end
end
|
.take_noun_with_prefix(morphemes, index) ⇒ Object
53
54
55
56
57
58
59
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 53
def take_noun_with_prefix(morphemes, index)
size = 0
size += 1 while noun_prefix?(morphemes, index + size)
return 0 unless size > 0
next_size = take(morphemes, index + size)
next_size > 0 ? size + next_size : 0
end
|
.take_noun_with_suffix(morphemes, index) ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 39
def take_noun_with_suffix(morphemes, index)
return 0 unless first_noun?(morphemes, index)
size = 1
size += 1 while following_noun?(morphemes, index + size) && !adjective_stem_suffix?(morphemes, index + size)
return 0 unless adjective_stem_suffix?(morphemes, index + size)
size += 1 while adjective_stem_suffix?(morphemes, index + size)
if following_noun?(morphemes, index + size)
0
else
size
end
end
|
Instance Method Details
#body ⇒ Object
70
71
72
73
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 70
def body
@body = body_morphemes.empty? ? nil : body_morphemes.map(&:text).join unless instance_variable_defined?(:@body)
@body
end
|
#prefix_morphemes ⇒ Object
62
63
64
65
66
67
68
|
# File 'lib/langue/japanese/words/adjective_noun.rb', line 62
def prefix_morphemes
@prefix_morphemes ||= begin
size = 0
size += 1 while self.class.noun_prefix?(morphemes, size)
morphemes[0, size]
end
end
|