zenlish 0.2.05 → 0.2.07
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +228 -0
- data/CHANGELOG.md +19 -0
- data/Gemfile +5 -3
- data/LICENSE.txt +1 -1
- data/Rakefile +5 -3
- data/lib/zenlish/feature/boolean_domain.rb +6 -4
- data/lib/zenlish/feature/boolean_value.rb +3 -2
- data/lib/zenlish/feature/enumeration_domain.rb +5 -2
- data/lib/zenlish/feature/feature.rb +9 -7
- data/lib/zenlish/feature/feature_def.rb +9 -6
- data/lib/zenlish/feature/feature_domain.rb +4 -2
- data/lib/zenlish/feature/feature_struct.rb +3 -1
- data/lib/zenlish/feature/feature_struct_def.rb +5 -3
- data/lib/zenlish/feature/feature_struct_def_bearer.rb +6 -4
- data/lib/zenlish/feature/feature_value.rb +4 -2
- data/lib/zenlish/feature/identifier_domain.rb +5 -3
- data/lib/zenlish/feature/identifier_value.rb +3 -2
- data/lib/zenlish/feature/symbol_value.rb +3 -1
- data/lib/zenlish/inflect/atomic_o_expression.rb +2 -1
- data/lib/zenlish/inflect/composite_o_expression.rb +3 -1
- data/lib/zenlish/inflect/concatenation.rb +3 -2
- data/lib/zenlish/inflect/equals_literal.rb +3 -1
- data/lib/zenlish/inflect/feature_heading.rb +2 -5
- data/lib/zenlish/inflect/formal_argument.rb +3 -1
- data/lib/zenlish/inflect/function_call.rb +4 -1
- data/lib/zenlish/inflect/heading.rb +2 -0
- data/lib/zenlish/inflect/inflection_rule.rb +2 -0
- data/lib/zenlish/inflect/inflection_table.rb +6 -4
- data/lib/zenlish/inflect/inflection_table_builder.rb +21 -18
- data/lib/zenlish/inflect/input_asis.rb +3 -0
- data/lib/zenlish/inflect/input_expression.rb +4 -2
- data/lib/zenlish/inflect/literal_asis.rb +4 -1
- data/lib/zenlish/inflect/matches_pattern.rb +2 -0
- data/lib/zenlish/inflect/membership.rb +2 -0
- data/lib/zenlish/inflect/method_heading.rb +3 -6
- data/lib/zenlish/inflect/not_equals_literal.rb +2 -0
- data/lib/zenlish/inflect/nullary_input_expression.rb +3 -1
- data/lib/zenlish/inflect/output_expression.rb +6 -0
- data/lib/zenlish/inflect/substitution.rb +3 -1
- data/lib/zenlish/inflect/unary_input_expression.rb +4 -1
- data/lib/zenlish/inflect/unconditionally_true.rb +4 -2
- data/lib/zenlish/lang/dictionary.rb +19 -16
- data/lib/zenlish/lang/lemmatizer.rb +40 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +6 -4
- data/lib/zenlish/lex/empty_lexicon_factory.rb +3 -2
- data/lib/zenlish/lex/lexeme.rb +6 -4
- data/lib/zenlish/lex/lexical_entry.rb +6 -4
- data/lib/zenlish/lex/lexicon.rb +4 -3
- data/lib/zenlish/lex/literal.rb +3 -1
- data/lib/zenlish/lexer/lexer.rb +144 -0
- data/lib/zenlish/trie/base_trie_node.rb +27 -0
- data/lib/zenlish/trie/trie.rb +132 -0
- data/lib/zenlish/trie/trie_node.rb +21 -0
- data/lib/zenlish/trie/trie_root.rb +10 -0
- data/lib/zenlish/version.rb +3 -1
- data/lib/zenlish/wclasses/adjective.rb +4 -2
- data/lib/zenlish/wclasses/adverb.rb +3 -1
- data/lib/zenlish/wclasses/adverb_maybe.rb +3 -1
- data/lib/zenlish/wclasses/adverb_not.rb +2 -0
- data/lib/zenlish/wclasses/all_word_classes.rb +3 -1
- data/lib/zenlish/wclasses/article.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary_be.rb +7 -6
- data/lib/zenlish/wclasses/auxiliary_do.rb +6 -5
- data/lib/zenlish/wclasses/cardinal.rb +3 -1
- data/lib/zenlish/wclasses/common_noun.rb +2 -0
- data/lib/zenlish/wclasses/comparative_particle.rb +5 -3
- data/lib/zenlish/wclasses/conjunction.rb +2 -0
- data/lib/zenlish/wclasses/conjunctive_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/coordinator.rb +4 -2
- data/lib/zenlish/wclasses/definite_article.rb +2 -0
- data/lib/zenlish/wclasses/degree_adverb.rb +2 -0
- data/lib/zenlish/wclasses/demonstrative_determiner.rb +6 -4
- data/lib/zenlish/wclasses/demonstrative_pronoun.rb +2 -0
- data/lib/zenlish/wclasses/determiner.rb +3 -1
- data/lib/zenlish/wclasses/distributive_determiner.rb +2 -0
- data/lib/zenlish/wclasses/existential_there.rb +2 -0
- data/lib/zenlish/wclasses/fronting_quantifier.rb +3 -1
- data/lib/zenlish/wclasses/indefinite_article.rb +2 -0
- data/lib/zenlish/wclasses/indefinite_pronoun.rb +3 -1
- data/lib/zenlish/wclasses/irregular_linking_verb.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb.rb +13 -15
- data/lib/zenlish/wclasses/irregular_verb_be.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_can.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_do.rb +7 -6
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -7
- data/lib/zenlish/wclasses/irregular_verb_have.rb +12 -11
- data/lib/zenlish/wclasses/irregular_verb_know.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_say.rb +3 -1
- data/lib/zenlish/wclasses/irregular_verb_think.rb +3 -1
- data/lib/zenlish/wclasses/lexical_verb.rb +3 -4
- data/lib/zenlish/wclasses/linking_adverb.rb +2 -0
- data/lib/zenlish/wclasses/modal_verb_can.rb +7 -5
- data/lib/zenlish/wclasses/noun.rb +4 -2
- data/lib/zenlish/wclasses/numeral.rb +2 -0
- data/lib/zenlish/wclasses/personal_pronoun.rb +8 -6
- data/lib/zenlish/wclasses/possessive_determiner.rb +13 -12
- data/lib/zenlish/wclasses/preposition.rb +3 -1
- data/lib/zenlish/wclasses/preposition_of.rb +2 -0
- data/lib/zenlish/wclasses/preposition_than.rb +2 -0
- data/lib/zenlish/wclasses/pronoun.rb +3 -1
- data/lib/zenlish/wclasses/proper_noun.rb +10 -8
- data/lib/zenlish/wclasses/quantifier.rb +3 -1
- data/lib/zenlish/wclasses/regular_verb.rb +9 -9
- data/lib/zenlish/wclasses/regular_verb_want.rb +4 -2
- data/lib/zenlish/wclasses/relative_pronoun.rb +4 -2
- data/lib/zenlish/wclasses/subordinating_conjunction.rb +7 -5
- data/lib/zenlish/wclasses/verb.rb +5 -3
- data/lib/zenlish/wclasses/word_class.rb +7 -5
- data/lib/zenlish.rb +3 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/zenlish/feature/boolean_domain_spec.rb +16 -16
- data/spec/zenlish/feature/boolean_value_spec.rb +7 -6
- data/spec/zenlish/feature/enumeration_domain_spec.rb +21 -21
- data/spec/zenlish/feature/feature_def_spec.rb +15 -14
- data/spec/zenlish/feature/feature_spec.rb +17 -17
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +23 -21
- data/spec/zenlish/feature/feature_struct_def_spec.rb +26 -25
- data/spec/zenlish/feature/identifier_domain_spec.rb +15 -15
- data/spec/zenlish/feature/identifier_value_spec.rb +10 -9
- data/spec/zenlish/feature/symbol_value_spec.rb +9 -8
- data/spec/zenlish/inflect/concatenation_spec.rb +14 -14
- data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/feature_heading_spec.rb +22 -21
- data/spec/zenlish/inflect/formal_argument_spec.rb +7 -7
- data/spec/zenlish/inflect/function_call_spec.rb +11 -12
- data/spec/zenlish/inflect/inflection_rule_spec.rb +28 -24
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +62 -57
- data/spec/zenlish/inflect/inflection_table_spec.rb +49 -46
- data/spec/zenlish/inflect/input_asis_spec.rb +12 -15
- data/spec/zenlish/inflect/literal_asis_spec.rb +10 -10
- data/spec/zenlish/inflect/matches_pattern_spec.rb +16 -15
- data/spec/zenlish/inflect/membership_spec.rb +17 -16
- data/spec/zenlish/inflect/method_heading_spec.rb +15 -14
- data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/substitution_spec.rb +10 -11
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +8 -6
- data/spec/zenlish/lang/dictionary_spec.rb +28 -31
- data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +5 -5
- data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
- data/spec/zenlish/lex/lexeme_spec.rb +27 -28
- data/spec/zenlish/lex/lexical_entry_spec.rb +15 -15
- data/spec/zenlish/lex/lexicon_spec.rb +52 -50
- data/spec/zenlish/lex/literal_spec.rb +8 -8
- data/spec/zenlish/lexer/lexer_spec.rb +52 -0
- data/spec/zenlish/parser/lesson1_spec.rb +81 -81
- data/spec/zenlish/parser/lesson2_spec.rb +133 -138
- data/spec/zenlish/parser/lesson3_spec.rb +186 -226
- data/spec/zenlish/parser/zparser_spec.rb +8 -7
- data/spec/zenlish/support/minimal_lexicon.rb +2 -0
- data/spec/zenlish/support/var2word.rb +16 -9
- data/spec/zenlish/trie/base_trie_node_spec.rb +33 -0
- data/spec/zenlish/trie/trie_spec.rb +108 -0
- data/spec/zenlish/wclasses/common_noun_spec.rb +15 -19
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +12 -12
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +18 -18
- data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +28 -28
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -9
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +12 -12
- data/spec/zenlish/wclasses/noun_spec.rb +7 -7
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +20 -23
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +28 -31
- data/spec/zenlish/wclasses/preposition_spec.rb +5 -5
- data/spec/zenlish/wclasses/proper_noun_spec.rb +3 -3
- data/spec/zenlish/wclasses/regular_verb_spec.rb +30 -30
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -9
- data/spec/zenlish_spec.rb +4 -2
- data/zenlish.gemspec +18 -14
- metadata +49 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a977fc6ec2982826186dd5f45b38e2394680d1827ba50b525650c2a9804daa5
|
4
|
+
data.tar.gz: be6b8cc9f1d842ff970202854de9baeb86ca35d1548f6331b85438dcd1791f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c961a939f20fc20123e07a87156cf58d1fa772713ba75f2ab106e151b45b18ec8812d2860b9dd8dc133bab496de14e551e24ebc76e91de03d9e002d875b531d5
|
7
|
+
data.tar.gz: 2e00f8de8768339a8b03a9ebeb95a828761b429f10dba844ab5fea78873c3f05a1d32a14d2caa0d81a1096a3a34378a1ac971e81d80e4dc1cde44fdda266112a
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,228 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- 'exp/**/*'
|
4
|
+
- 'demo/**/*'
|
5
|
+
NewCops: enable
|
6
|
+
SuggestExtensions: false
|
7
|
+
|
8
|
+
Gemspec/DevelopmentDependencies:
|
9
|
+
EnforcedStyle: gemspec
|
10
|
+
|
11
|
+
Layout/ArgumentAlignment:
|
12
|
+
Enabled: false
|
13
|
+
|
14
|
+
Layout/ArrayAlignment:
|
15
|
+
Enabled: true
|
16
|
+
EnforcedStyle: with_fixed_indentation
|
17
|
+
|
18
|
+
Layout/CaseIndentation:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Layout/ClosingHeredocIndentation:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Layout/CommentIndentation:
|
25
|
+
Enabled: false
|
26
|
+
|
27
|
+
Layout/ElseAlignment:
|
28
|
+
Enabled: false
|
29
|
+
|
30
|
+
Layout/EmptyLines:
|
31
|
+
Enabled: false
|
32
|
+
|
33
|
+
Layout/EndAlignment:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Layout/EndOfLine:
|
37
|
+
Enabled: true
|
38
|
+
EnforcedStyle: lf
|
39
|
+
|
40
|
+
Layout/FirstArgumentIndentation:
|
41
|
+
Enabled: false
|
42
|
+
|
43
|
+
Layout/HashAlignment:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Layout/IndentationWidth:
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Layout/IndentationConsistency:
|
50
|
+
Enabled: true
|
51
|
+
|
52
|
+
Layout/HeredocIndentation:
|
53
|
+
Enabled: false
|
54
|
+
|
55
|
+
Layout/MultilineMethodCallBraceLayout:
|
56
|
+
Enabled: true
|
57
|
+
EnforcedStyle: same_line
|
58
|
+
|
59
|
+
Lint/Void:
|
60
|
+
Enabled: false
|
61
|
+
|
62
|
+
Metrics/AbcSize:
|
63
|
+
Enabled: false
|
64
|
+
|
65
|
+
Metrics/BlockLength:
|
66
|
+
Enabled: true
|
67
|
+
Max: 350
|
68
|
+
|
69
|
+
Metrics/BlockNesting:
|
70
|
+
Enabled: true
|
71
|
+
Max: 5
|
72
|
+
|
73
|
+
Metrics/ClassLength:
|
74
|
+
Enabled: true
|
75
|
+
Max: 450
|
76
|
+
|
77
|
+
Metrics/CyclomaticComplexity:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
Layout/LineLength:
|
81
|
+
Enabled: false
|
82
|
+
Max: 90
|
83
|
+
|
84
|
+
Metrics/MethodLength:
|
85
|
+
Enabled: true
|
86
|
+
Max: 60
|
87
|
+
|
88
|
+
Metrics/ModuleLength:
|
89
|
+
Enabled: true
|
90
|
+
Max: 500
|
91
|
+
|
92
|
+
Metrics/PerceivedComplexity:
|
93
|
+
Enabled: false
|
94
|
+
|
95
|
+
Naming/BlockForwarding:
|
96
|
+
EnforcedStyle: explicit
|
97
|
+
BlockForwardingName: aBlock
|
98
|
+
|
99
|
+
Naming/ConstantName:
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Naming/ClassAndModuleCamelCase:
|
103
|
+
Enabled: false
|
104
|
+
|
105
|
+
Naming/MethodParameterName:
|
106
|
+
Enabled: false
|
107
|
+
|
108
|
+
Naming/MethodName:
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
Naming/VariableName:
|
112
|
+
Enabled: false
|
113
|
+
|
114
|
+
Style/AsciiComments:
|
115
|
+
Enabled: false
|
116
|
+
|
117
|
+
Style/BarePercentLiterals:
|
118
|
+
Enabled: false
|
119
|
+
|
120
|
+
Style/BlockComments:
|
121
|
+
Enabled: false
|
122
|
+
|
123
|
+
Style/CharacterLiteral:
|
124
|
+
Enabled: false
|
125
|
+
|
126
|
+
Style/ClassCheck:
|
127
|
+
Enabled: false
|
128
|
+
|
129
|
+
Style/ClassVars:
|
130
|
+
Enabled: false
|
131
|
+
|
132
|
+
Style/ColonMethodCall:
|
133
|
+
Enabled: false
|
134
|
+
|
135
|
+
Style/CommentAnnotation:
|
136
|
+
Enabled: false
|
137
|
+
|
138
|
+
Style/CommentedKeyword:
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Style/ConditionalAssignment:
|
142
|
+
Enabled: false
|
143
|
+
|
144
|
+
Style/Documentation:
|
145
|
+
Enabled: false
|
146
|
+
|
147
|
+
Style/ExpandPathArguments:
|
148
|
+
Enabled: false
|
149
|
+
|
150
|
+
Style/GuardClause:
|
151
|
+
Enabled: false
|
152
|
+
|
153
|
+
Style/IfUnlessModifier:
|
154
|
+
Enabled: false
|
155
|
+
|
156
|
+
Style/InverseMethods:
|
157
|
+
Enabled: false
|
158
|
+
|
159
|
+
Style/MissingRespondToMissing:
|
160
|
+
Enabled: false
|
161
|
+
|
162
|
+
Style/Next:
|
163
|
+
Enabled: false
|
164
|
+
|
165
|
+
Style/NumericLiterals:
|
166
|
+
Enabled: false
|
167
|
+
|
168
|
+
Style/QuotedSymbols:
|
169
|
+
Enabled: true
|
170
|
+
|
171
|
+
Style/RedundantReturn:
|
172
|
+
Enabled: false
|
173
|
+
|
174
|
+
Style/RegexpLiteral:
|
175
|
+
Enabled: false
|
176
|
+
|
177
|
+
Style/PercentLiteralDelimiters:
|
178
|
+
Enabled: false
|
179
|
+
|
180
|
+
Style/StderrPuts:
|
181
|
+
Enabled: false
|
182
|
+
|
183
|
+
# Calling super is mandatory for WClass subclasses, therefore we disable this cop
|
184
|
+
Style/SuperArguments:
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
Style/TernaryParentheses:
|
188
|
+
Enabled: false
|
189
|
+
|
190
|
+
Style/UnlessElse:
|
191
|
+
Enabled: false
|
192
|
+
|
193
|
+
# Optional rubocop-rspec plugin rule checking
|
194
|
+
#RSpec/ContextWording:
|
195
|
+
# Enabled: false
|
196
|
+
#
|
197
|
+
#RSpec/DescribeClass:
|
198
|
+
# Enabled: false
|
199
|
+
#
|
200
|
+
#RSpec/EmptyExampleGroup:
|
201
|
+
# Enabled: false
|
202
|
+
#
|
203
|
+
#RSpec/ExampleLength:
|
204
|
+
# Max: 60
|
205
|
+
#
|
206
|
+
#RSpec/IndexedLet:
|
207
|
+
# Enabled: false
|
208
|
+
#
|
209
|
+
#RSpec/MultipleExpectations:
|
210
|
+
# Max: 25
|
211
|
+
#
|
212
|
+
#RSpec/MultipleMemoizedHelpers:
|
213
|
+
# Max: 35
|
214
|
+
#
|
215
|
+
#RSpec/NoExpectationExample:
|
216
|
+
# Enabled: false
|
217
|
+
#
|
218
|
+
#RSpec/RepeatedDescription:
|
219
|
+
# Enabled: false
|
220
|
+
#
|
221
|
+
#RSpec/RepeatedExample:
|
222
|
+
# Enabled: false
|
223
|
+
#
|
224
|
+
#RSpec/RepeatedExampleGroupDescription:
|
225
|
+
# Enabled: false
|
226
|
+
#
|
227
|
+
#RSpec/VerifiedDoubles:
|
228
|
+
# Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
# CHANGELOG
|
2
|
+
## [0.2.07] - 2025-04-03
|
3
|
+
Minor changes
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
- File `zenlish.gempsec` updated versions in depedencies
|
7
|
+
- Code re-styling to please `Rubocop` 1.75.1
|
8
|
+
- Spec files re-styling to please `rubocop-rspec` 3.5.0
|
9
|
+
|
10
|
+
## [0.2.06] - 2021-09-04
|
11
|
+
- Fixes and code re-styling to please `Rubocop` 1.19.1
|
12
|
+
|
13
|
+
### Changed
|
14
|
+
- File `zenlish.gemspec` updated dependency towards `rley` gem (now ~> 0.8.03)
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- File `zenlish_grammar.rb` fixed small code breaking caused due to `Rley` v.0.8+ library.
|
18
|
+
- File `lexer_spec.rb` corrected a test.
|
19
|
+
|
1
20
|
# CHANGELOG
|
2
21
|
## [0.2.05] - 2020-02-16
|
3
22
|
Zenlish can now inflect all the lexemes in its lexicon.
|
data/Gemfile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
|
5
|
+
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
|
6
|
+
|
7
|
+
# Specify your gem's dependencies in zenlish.gemspec
|
6
8
|
gemspec
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2019-
|
3
|
+
Copyright (c) 2019-2025, Dimitri Geshef
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
require_relative 'feature_domain'
|
3
5
|
require_relative 'boolean_value'
|
@@ -6,15 +8,15 @@ module Zenlish
|
|
6
8
|
module Feature
|
7
9
|
class BooleanDomain < FeatureDomain
|
8
10
|
include Singleton # Use the Singleton design patttern
|
9
|
-
|
11
|
+
|
10
12
|
def build_value(aValue)
|
11
13
|
BooleanValue.new(validated_value(aValue))
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def include?(aValue)
|
15
17
|
aValue.kind_of?(TrueClass) || aValue.kind_of?(FalseClass)
|
16
18
|
end
|
17
|
-
|
19
|
+
|
18
20
|
def to_a
|
19
21
|
[false, true]
|
20
22
|
end
|
@@ -22,7 +24,7 @@ module Zenlish
|
|
22
24
|
private
|
23
25
|
|
24
26
|
def validated_value(aValue)
|
25
|
-
if
|
27
|
+
if !aValue.is_a?(FalseClass) && !aValue.is_a?(TrueClass)
|
26
28
|
raise StandardError, "Expected a boolean instead of #{aValue.class}."
|
27
29
|
end
|
28
30
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'feature_domain'
|
2
4
|
require_relative 'symbol_value'
|
3
5
|
|
@@ -7,17 +9,18 @@ module Zenlish
|
|
7
9
|
attr_reader :enum
|
8
10
|
|
9
11
|
def initialize(*symbols)
|
12
|
+
super()
|
10
13
|
@enum = symbols
|
11
14
|
end
|
12
15
|
|
13
16
|
def build_value(aValue)
|
14
17
|
SymbolValue.new(validated_value(aValue))
|
15
18
|
end
|
16
|
-
|
19
|
+
|
17
20
|
def include?(aValue)
|
18
21
|
enum.include?(aValue)
|
19
22
|
end
|
20
|
-
|
23
|
+
|
21
24
|
def to_a
|
22
25
|
enum
|
23
26
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'forwardable'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -5,26 +7,26 @@ module Zenlish
|
|
5
7
|
class Feature
|
6
8
|
# Forwardable mix-in module to implement delegation of specified methods.
|
7
9
|
extend Forwardable
|
8
|
-
|
10
|
+
|
9
11
|
# The feature definition
|
10
12
|
attr_reader :definition
|
11
|
-
|
13
|
+
|
12
14
|
attr_reader :binding
|
13
15
|
|
14
16
|
def_delegators :@definition, :name, :domain
|
15
|
-
|
17
|
+
|
16
18
|
# @param aDefinition [FeatureDef]
|
17
19
|
def initialize(aDefinition)
|
18
20
|
@definition = aDefinition
|
19
21
|
end
|
20
|
-
|
22
|
+
|
21
23
|
def bound?
|
22
|
-
|
24
|
+
!binding.nil?
|
23
25
|
end
|
24
|
-
|
26
|
+
|
25
27
|
def bind_to(aFeatureValue)
|
26
28
|
@binding = aFeatureValue
|
27
29
|
end
|
28
30
|
end # class
|
29
31
|
end # module
|
30
|
-
end # module
|
32
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'boolean_domain'
|
2
4
|
require_relative 'enumeration_domain'
|
3
5
|
require_relative 'feature_value'
|
@@ -27,23 +29,24 @@ module Zenlish
|
|
27
29
|
|
28
30
|
def validated_name(aName)
|
29
31
|
raise StandardError, 'feature name cannot be empty.' if aName.empty?
|
32
|
+
|
30
33
|
aName.dup
|
31
34
|
end
|
32
35
|
|
33
36
|
def validated_default(aDomain, aDefault)
|
34
37
|
if aDefault
|
35
|
-
default = aDefault
|
38
|
+
@default = aDefault
|
36
39
|
elsif aDomain.is_a?(BooleanDomain)
|
37
|
-
default = nil
|
38
|
-
|
40
|
+
@default = nil
|
41
|
+
elsif aDomain.is_a?(EnumerationDomain)
|
39
42
|
if aDomain.enum.size == 1
|
40
43
|
val = FeatureValue.new(aDomain.enum[0])
|
41
|
-
default = val
|
44
|
+
@default = val
|
42
45
|
else
|
43
|
-
default = nil
|
46
|
+
@default = nil
|
44
47
|
end
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end # class
|
48
51
|
end # module
|
49
|
-
end # module
|
52
|
+
end # module
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Zenlish
|
2
4
|
module Feature
|
3
5
|
class FeatureDomain
|
4
|
-
def include?(
|
6
|
+
def include?(_value)
|
5
7
|
raise NotImplementedError, "Implement #{__callee__} method in subclass(es)."
|
6
8
|
end
|
7
9
|
|
@@ -10,4 +12,4 @@ module Zenlish
|
|
10
12
|
end
|
11
13
|
end # class
|
12
14
|
end # module
|
13
|
-
end # module
|
15
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'feature_domain'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -8,6 +10,7 @@ module Zenlish
|
|
8
10
|
|
9
11
|
# @param aParent [FeatureStructDef]
|
10
12
|
def initialize(aParent = nil)
|
13
|
+
super()
|
11
14
|
@parent = validated_parent(aParent)
|
12
15
|
@struct = {}
|
13
16
|
end
|
@@ -15,6 +18,7 @@ module Zenlish
|
|
15
18
|
# @param aFeatureName [String]
|
16
19
|
def [](aFeatureName)
|
17
20
|
return struct[aFeatureName] if struct.include? aFeatureName
|
21
|
+
|
18
22
|
if parent
|
19
23
|
p_struct = parent.struct
|
20
24
|
return p_struct[aFeatureName] if p_struct.include? aFeatureName
|
@@ -35,10 +39,8 @@ module Zenlish
|
|
35
39
|
aParent
|
36
40
|
elsif aParent
|
37
41
|
aParent.struct
|
38
|
-
else
|
39
|
-
nil
|
40
42
|
end
|
41
43
|
end
|
42
44
|
end # class
|
43
45
|
end # module
|
44
|
-
end # module
|
46
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'boolean_domain'
|
2
4
|
require_relative 'identifier_domain'
|
3
5
|
require_relative 'enumeration_domain'
|
@@ -31,17 +33,17 @@ module Zenlish
|
|
31
33
|
struct[aName]
|
32
34
|
end
|
33
35
|
|
34
|
-
# @return [Feature::BooleanDomain]
|
36
|
+
# @return [Feature::BooleanDomain]
|
35
37
|
def boolean
|
36
38
|
BooleanDomain.instance
|
37
39
|
end
|
38
40
|
|
39
|
-
# @return [Feature::EnumerationDomain]
|
41
|
+
# @return [Feature::EnumerationDomain]
|
40
42
|
def enumeration(*items)
|
41
43
|
EnumerationDomain.new(*items)
|
42
44
|
end
|
43
|
-
|
44
|
-
def identifier(
|
45
|
+
|
46
|
+
def identifier(_default_value = nil)
|
45
47
|
IdentifierDomain.instance
|
46
48
|
end
|
47
49
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Zenlish
|
2
4
|
module Feature
|
3
5
|
class FeatureValue
|
@@ -9,9 +11,9 @@ module Zenlish
|
|
9
11
|
|
10
12
|
protected
|
11
13
|
|
12
|
-
def valid_value
|
14
|
+
def valid_value
|
13
15
|
raise NotImplementedError
|
14
16
|
end
|
15
17
|
end # class
|
16
18
|
end # module
|
17
|
-
end # module
|
19
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'singleton'
|
2
4
|
require_relative 'feature_domain'
|
3
5
|
require_relative 'identifier_value'
|
@@ -10,9 +12,9 @@ module Zenlish
|
|
10
12
|
def build_value(aValue)
|
11
13
|
IdentifierValue.new(validated_value(aValue))
|
12
14
|
end
|
13
|
-
|
15
|
+
|
14
16
|
def include?(aValue)
|
15
|
-
aValue =~ /^[a-zA-
|
17
|
+
aValue =~ /^[a-zA-Z_][a-zA-Z0-9_]*$/
|
16
18
|
end
|
17
19
|
|
18
20
|
private
|
@@ -23,7 +25,7 @@ module Zenlish
|
|
23
25
|
end
|
24
26
|
|
25
27
|
aValue
|
26
|
-
end
|
28
|
+
end
|
27
29
|
end # class
|
28
30
|
end # module
|
29
31
|
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'output_expression'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -6,9 +8,9 @@ module Zenlish
|
|
6
8
|
attr_reader :children
|
7
9
|
|
8
10
|
def initialize(theChildren)
|
11
|
+
super()
|
9
12
|
@children = theChildren.dup
|
10
13
|
end
|
11
14
|
end # class
|
12
15
|
end # module
|
13
16
|
end # module
|
14
|
-
|
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'literal_asis'
|
2
4
|
require_relative 'composite_o_expression'
|
3
5
|
|
4
6
|
module Zenlish
|
5
7
|
module Inflect
|
6
8
|
class Concatenation < CompositeOExpression
|
7
|
-
|
8
9
|
def initialize(argument1, argument2)
|
9
10
|
super([validated_argument(argument1), validated_argument(argument2)])
|
10
11
|
end
|
@@ -33,4 +34,4 @@ module Zenlish
|
|
33
34
|
end
|
34
35
|
end # class
|
35
36
|
end # module
|
36
|
-
end # module
|
37
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'unary_input_expression'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -15,7 +17,7 @@ module Zenlish
|
|
15
17
|
hd = headings[argument.index]
|
16
18
|
feat_def = hd.evaluate_for(lexeme)
|
17
19
|
feat_def.domain.include?(literal)
|
18
|
-
else
|
20
|
+
else
|
19
21
|
val = actuals[argument.index]
|
20
22
|
if val.kind_of?(Feature::FeatureDef)
|
21
23
|
val.domain.include?(literal)
|
@@ -1,13 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'heading'
|
2
4
|
|
3
5
|
module Zenlish
|
4
6
|
module Inflect
|
5
7
|
class FeatureHeading < Heading
|
6
|
-
|
7
|
-
def initialize(aLabel)
|
8
|
-
super(aLabel)
|
9
|
-
end
|
10
|
-
|
11
8
|
def evaluate_for(aFeatureBearer)
|
12
9
|
aFeatureBearer[label]
|
13
10
|
end
|