zenlish 0.2.02 → 0.2.06
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +455 -0
- data/CHANGELOG.md +58 -1
- data/Gemfile +5 -3
- data/README.md +27 -0
- data/Rakefile +5 -3
- data/lib/zenlish/feature/boolean_domain.rb +9 -3
- data/lib/zenlish/feature/boolean_value.rb +3 -2
- data/lib/zenlish/feature/enumeration_domain.rb +8 -1
- data/lib/zenlish/feature/feature.rb +9 -7
- data/lib/zenlish/feature/feature_def.rb +10 -6
- data/lib/zenlish/feature/feature_domain.rb +9 -3
- data/lib/zenlish/feature/feature_struct.rb +3 -1
- data/lib/zenlish/feature/feature_struct_def.rb +5 -1
- 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 +7 -1
- data/lib/zenlish/inflect/feature_heading.rb +11 -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 +5 -0
- data/lib/zenlish/inflect/inflection_rule.rb +2 -0
- data/lib/zenlish/inflect/inflection_table.rb +29 -4
- data/lib/zenlish/inflect/inflection_table_builder.rb +27 -20
- 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 +7 -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 +2 -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 +35 -29
- data/lib/zenlish/lang/lemmatizer.rb +40 -0
- data/lib/zenlish/lang/zenlish_grammar.rb +9 -6
- data/lib/zenlish/lex/empty_lexicon_factory.rb +4 -3
- data/lib/zenlish/lex/lexeme.rb +9 -2
- data/lib/zenlish/lex/lexical_entry.rb +6 -4
- data/lib/zenlish/lex/lexicon.rb +10 -8
- 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 +5 -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 +4 -2
- data/lib/zenlish/wclasses/article.rb +2 -0
- data/lib/zenlish/wclasses/auxiliary.rb +5 -2
- data/lib/zenlish/wclasses/auxiliary_be.rb +34 -1
- data/lib/zenlish/wclasses/auxiliary_do.rb +31 -0
- 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 +40 -1
- 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 +14 -22
- data/lib/zenlish/wclasses/irregular_verb_be.rb +41 -1
- data/lib/zenlish/wclasses/irregular_verb_can.rb +35 -0
- data/lib/zenlish/wclasses/irregular_verb_do.rb +38 -1
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +8 -6
- data/lib/zenlish/wclasses/irregular_verb_have.rb +38 -1
- 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 +27 -0
- data/lib/zenlish/wclasses/noun.rb +4 -2
- data/lib/zenlish/wclasses/numeral.rb +2 -0
- data/lib/zenlish/wclasses/personal_pronoun.rb +70 -1
- data/lib/zenlish/wclasses/possessive_determiner.rb +60 -0
- 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 +13 -18
- 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 +16 -8
- data/lib/zenlish/wclasses/word_class.rb +11 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/zenlish/feature/boolean_domain_spec.rb +6 -1
- data/spec/zenlish/feature/boolean_value_spec.rb +1 -1
- data/spec/zenlish/feature/enumeration_domain_spec.rb +9 -5
- data/spec/zenlish/feature/feature_spec.rb +3 -3
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +10 -8
- data/spec/zenlish/feature/feature_struct_def_spec.rb +3 -2
- data/spec/zenlish/feature/identifier_domain_spec.rb +3 -3
- data/spec/zenlish/feature/identifier_value_spec.rb +4 -4
- data/spec/zenlish/feature/symbol_value_spec.rb +3 -3
- data/spec/zenlish/inflect/concatenation_spec.rb +7 -7
- data/spec/zenlish/inflect/feature_heading_spec.rb +23 -3
- data/spec/zenlish/inflect/formal_argument_spec.rb +2 -2
- data/spec/zenlish/inflect/function_call_spec.rb +4 -4
- data/spec/zenlish/inflect/inflection_rule_spec.rb +9 -5
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +26 -21
- data/spec/zenlish/inflect/inflection_table_spec.rb +39 -22
- data/spec/zenlish/inflect/input_asis_spec.rb +2 -6
- data/spec/zenlish/inflect/literal_asis_spec.rb +3 -3
- data/spec/zenlish/inflect/matches_pattern_spec.rb +1 -1
- data/spec/zenlish/inflect/membership_spec.rb +2 -2
- data/spec/zenlish/inflect/method_heading_spec.rb +7 -1
- data/spec/zenlish/inflect/substitution_spec.rb +1 -1
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +2 -2
- data/spec/zenlish/lang/dictionary_spec.rb +51 -16
- data/spec/zenlish/lang/lemmatizer_spec.rb +43 -0
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +2 -2
- data/spec/zenlish/lex/lexeme_spec.rb +16 -11
- data/spec/zenlish/lex/lexical_entry_spec.rb +1 -2
- data/spec/zenlish/lex/lexicon_spec.rb +9 -8
- data/spec/zenlish/lex/literal_spec.rb +2 -2
- data/spec/zenlish/lexer/lexer_spec.rb +52 -0
- data/spec/zenlish/parser/lesson1_spec.rb +2 -2
- data/spec/zenlish/parser/lesson2_spec.rb +31 -36
- data/spec/zenlish/parser/lesson3_spec.rb +98 -138
- data/spec/zenlish/parser/zparser_spec.rb +2 -1
- data/spec/zenlish/support/minimal_lexicon.rb +2 -0
- data/spec/zenlish/support/var2word.rb +27 -18
- 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 +19 -7
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +47 -0
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +60 -0
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +14 -4
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +9 -2
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +50 -0
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +66 -0
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +69 -0
- data/spec/zenlish/wclasses/regular_verb_spec.rb +35 -15
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +30 -0
- data/spec/zenlish/wclasses/verb_spec.rb +9 -2
- data/spec/zenlish_spec.rb +3 -1
- data/zenlish.gemspec +17 -14
- metadata +37 -10
- data/lib/zenlish/wclasses/modal_verb_could.rb +0 -9
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'conjunction'
|
2
4
|
|
3
5
|
module Zenlish
|
@@ -5,12 +7,12 @@ module Zenlish
|
|
5
7
|
# A subordinating conjunction is a word or phrase that connects a dependent
|
6
8
|
# clause to a main clause. The subordinating conjunction indicates how the
|
7
9
|
# dependent clause adds informative value to the main clause. For instance,
|
8
|
-
# by signaling a cause-and-effect relation, a shift in time or place between
|
9
|
-
# the two clauses.
|
10
|
-
# Common subordinating conjunctions: after, although, as, because, before,
|
11
|
-
# how, if, once, since, than, that, though, till, until, when, where,
|
10
|
+
# by signaling a cause-and-effect relation, a shift in time or place between
|
11
|
+
# the two clauses.
|
12
|
+
# Common subordinating conjunctions: after, although, as, because, before,
|
13
|
+
# how, if, once, since, than, that, though, till, until, when, where,
|
12
14
|
# whether, while
|
13
|
-
class SubordinatingConjunction < WordClass
|
15
|
+
class SubordinatingConjunction < WordClass
|
14
16
|
end # class
|
15
17
|
end # module
|
16
18
|
end # module
|
@@ -1,17 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'word_class'
|
2
4
|
require_relative '../inflect/inflection_table_builder'
|
3
5
|
|
4
6
|
module Zenlish
|
5
7
|
module WClasses
|
6
|
-
# Abstract class. In traditional grammar, the verb is often defined
|
8
|
+
# Abstract class. In traditional grammar, the verb is often defined
|
7
9
|
# notionally as a 'doing' word (i.e. a word that describes the action
|
8
10
|
# in a clause).
|
9
11
|
class Verb < WordClass
|
10
12
|
def initialize
|
11
13
|
super()
|
14
|
+
@paradigms = {}
|
12
15
|
init_feature_defs
|
13
|
-
|
14
|
-
|
16
|
+
init_paradigms
|
17
|
+
end
|
18
|
+
|
15
19
|
# As all verbs inflect, or change form, to reflect changes in tense,
|
16
20
|
# person, number, and voice, they are, by definition, variable.
|
17
21
|
def invariable?
|
@@ -22,13 +26,17 @@ module Zenlish
|
|
22
26
|
|
23
27
|
def init_feature_defs
|
24
28
|
# Create standard feature definitions for lexical verbs.
|
25
|
-
feature_def_dsl
|
29
|
+
feature_def_dsl do
|
26
30
|
feature_def 'NUMBER' => enumeration(:singular, :plural)
|
27
31
|
feature_def 'PERSON' => enumeration(:first, :second, :third)
|
28
|
-
feature_def 'TIME' => enumeration(:present, :progressive, :past_simple, :past_participle)
|
32
|
+
feature_def 'TIME' => enumeration(:present, :progressive, :past_simple, :past_participle)
|
29
33
|
feature_def 'PARADIGM' => [identifier, 'Regular_inflection'] # 2nd item is default value
|
30
|
-
|
31
|
-
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def init_paradigms
|
38
|
+
raise NotImplementedError, "Method #{__callee__} must implemented for #{self.class}."
|
39
|
+
end
|
32
40
|
end # class
|
33
41
|
end # module
|
34
|
-
end # module
|
42
|
+
end # module
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'rley'
|
2
4
|
require_relative '../feature/feature_struct_def_bearer'
|
3
5
|
|
@@ -29,13 +31,19 @@ module Zenlish
|
|
29
31
|
# form.
|
30
32
|
# @return [FalseClass, TrueClass] true iff the words in the class are invariable.
|
31
33
|
def invariable?
|
32
|
-
|
34
|
+
true
|
33
35
|
end
|
34
|
-
|
36
|
+
|
35
37
|
# @return [Module, NilClass]
|
36
38
|
def extension
|
37
39
|
nil
|
38
40
|
end
|
41
|
+
|
42
|
+
protected
|
43
|
+
|
44
|
+
def add_paradigm(anInflectionTable)
|
45
|
+
@paradigms[anInflectionTable.name] = anInflectionTable
|
46
|
+
end
|
39
47
|
end # class
|
40
48
|
end # module
|
41
|
-
end # module
|
49
|
+
end # module
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/setup'
|
2
4
|
require 'rspec' # Use the RSpec framework
|
3
5
|
|
4
6
|
RSpec.configure do |config|
|
5
7
|
# Enable flags like --only-failures and --next-failure
|
6
|
-
config.example_status_persistence_file_path =
|
8
|
+
config.example_status_persistence_file_path = '.rspec_status'
|
7
9
|
|
8
10
|
config.expect_with :rspec do |c|
|
9
11
|
# Disable the `should` syntax
|
@@ -18,12 +18,17 @@ module Zenlish
|
|
18
18
|
expect(subject.include?('invalid')).to be_falsey
|
19
19
|
expect(subject.include?(true)).to be_truthy
|
20
20
|
expect(subject.include?(false)).to be_truthy
|
21
|
-
end
|
21
|
+
end
|
22
|
+
|
22
23
|
it 'should provide a factory method for boolean values' do
|
23
24
|
expect(subject.build_value(true)).to be_kind_of(BooleanValue)
|
24
25
|
expect(subject.build_value(false)).to be_kind_of(BooleanValue)
|
25
26
|
end
|
26
27
|
|
28
|
+
it 'should return all valid values in domain when requested' do
|
29
|
+
expect(subject.to_a).to eq([false, true])
|
30
|
+
end
|
31
|
+
|
27
32
|
it 'should complain when asked to build a non-boolean value' do
|
28
33
|
err = StandardError
|
29
34
|
err_msg = 'Expected a boolean instead of String.'
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Load the class under test
|
4
|
-
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
|
+
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
5
5
|
|
6
6
|
module Zenlish
|
7
7
|
module Feature
|
@@ -12,9 +12,9 @@ module Zenlish
|
|
12
12
|
it 'should be initialized with arguments' do
|
13
13
|
expect { EnumerationDomain.new(:singular, :plural) }.not_to raise_error
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it 'should know the values of enumeration' do
|
17
|
-
expect(subject.enum).to eq([
|
17
|
+
expect(subject.enum).to eq(%i[singular plural])
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
@@ -24,18 +24,22 @@ module Zenlish
|
|
24
24
|
expect(subject.include?(:singular)).to be_truthy
|
25
25
|
expect(subject.include?(:plural)).to be_truthy
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
it 'should provide a factory method for enumerated value' do
|
29
29
|
expect(subject.build_value(:plural)).to be_kind_of(SymbolValue)
|
30
30
|
value = subject.build_value(:plural)
|
31
31
|
expect(value.val).to eq(:plural)
|
32
32
|
end
|
33
33
|
|
34
|
+
it 'should return all valid values in domain when requested' do
|
35
|
+
expect(subject.to_a).to eq(%i[singular plural])
|
36
|
+
end
|
37
|
+
|
34
38
|
it 'should complain when asked to build a non-member value' do
|
35
39
|
err = StandardError
|
36
40
|
err_msg = "dual isn't part of enumeration [singular, plural]."
|
37
41
|
expect { subject.build_value(:dual) }.to raise_error(err, err_msg)
|
38
|
-
end
|
42
|
+
end
|
39
43
|
end # context
|
40
44
|
end # describe
|
41
45
|
end # module
|
@@ -36,16 +36,16 @@ module Zenlish
|
|
36
36
|
expect(subject.name).to eq(feat_def.name)
|
37
37
|
end
|
38
38
|
|
39
|
-
it
|
39
|
+
it 'should know the domain of its values' do
|
40
40
|
expect(subject.domain).to eq(a_domain)
|
41
41
|
end
|
42
42
|
|
43
43
|
it 'should accept a value binding' do
|
44
44
|
expect { subject.bind_to(plural_value) }.not_to raise_error
|
45
45
|
expect(subject).to be_bound
|
46
|
-
|
46
|
+
expect(subject.binding).to eq(plural_value)
|
47
47
|
end
|
48
48
|
end # context
|
49
49
|
end # describe
|
50
50
|
end # module
|
51
|
-
end # module
|
51
|
+
end # module
|
@@ -7,6 +7,7 @@ module Zenlish
|
|
7
7
|
module Feature
|
8
8
|
describe FeatureStructDefBearer do
|
9
9
|
# @nodoc Class created just for testing purposes.
|
10
|
+
# rubocop: disable Lint/ConstantDefinitionInBlock
|
10
11
|
class Dummy
|
11
12
|
include FeatureStructDefBearer
|
12
13
|
|
@@ -20,8 +21,9 @@ module Zenlish
|
|
20
21
|
init_struct_def(aParent, feature_hash)
|
21
22
|
end
|
22
23
|
end # class
|
24
|
+
# rubocop: enable Lint/ConstantDefinitionInBlock
|
23
25
|
|
24
|
-
subject { Dummy.new
|
26
|
+
subject { Dummy.new(nil) }
|
25
27
|
|
26
28
|
context 'Mix-in initialization' do
|
27
29
|
it 'should have initialized properly the injected data' do
|
@@ -33,22 +35,22 @@ module Zenlish
|
|
33
35
|
expect(subject['NUMBER']).not_to be_nil
|
34
36
|
expect(subject['NUMBER']).to be_kind_of(FeatureDef)
|
35
37
|
ft = subject['NUMBER']
|
36
|
-
expect(ft.domain.enum).to eq([
|
37
|
-
|
38
|
+
expect(ft.domain.enum).to eq(%i[singular plural])
|
39
|
+
|
38
40
|
expect(subject['COUNTABILITY']).to be_kind_of(FeatureDef)
|
39
41
|
expect(subject['COUNTABILITY'].domain).to be_kind_of(BooleanDomain)
|
40
42
|
expect(subject['PARADIGM']).to be_kind_of(FeatureDef)
|
41
43
|
expect(subject['PARADIGM'].domain).to be_kind_of(IdentifierDomain)
|
42
|
-
expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)
|
44
|
+
expect(subject['PARADIGM'].default).to be_kind_of(IdentifierValue)
|
43
45
|
end
|
44
|
-
|
46
|
+
|
45
47
|
it 'should support the addition of feature def' do
|
46
48
|
subject.feature_def_dsl { feature_def 'CASE' => boolean }
|
47
|
-
|
49
|
+
|
48
50
|
expect(subject['CASE']).to be_kind_of(FeatureDef)
|
49
|
-
expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)
|
51
|
+
expect(subject['CASE'].domain).to be_kind_of(BooleanDomain)
|
50
52
|
end
|
51
53
|
end # context
|
52
54
|
end # describe
|
53
55
|
end # module
|
54
|
-
end # module
|
56
|
+
end # module
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative '../../../lib/zenlish/feature/boolean_domain'
|
3
4
|
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
5
|
require_relative '../../../lib/zenlish/feature/feature_def'
|
@@ -54,10 +55,10 @@ module Zenlish
|
|
54
55
|
sample_parent.add_feature_def(ft_case)
|
55
56
|
expect(subject['CASE']).to eq(ft_case)
|
56
57
|
end
|
57
|
-
|
58
|
+
|
58
59
|
it "should be able to override parent's feature def" do
|
59
60
|
sample_parent.add_feature_def(ft_case)
|
60
|
-
|
61
|
+
|
61
62
|
other_case_domain = BooleanDomain.instance
|
62
63
|
other_ft_case = FeatureDef.new('CASE', other_case_domain)
|
63
64
|
subject.add_feature_def(other_ft_case)
|
@@ -18,8 +18,8 @@ module Zenlish
|
|
18
18
|
expect(subject.include?('CommonForm')).to be_truthy
|
19
19
|
expect(subject.include?('Common Form')).to be_falsey
|
20
20
|
expect(subject.include?('+123')).to be_falsey
|
21
|
-
end
|
22
|
-
|
21
|
+
end
|
22
|
+
|
23
23
|
it 'should provide a factory method for identifier values' do
|
24
24
|
expect(subject.build_value('CommonForm')).to be_kind_of(IdentifierValue)
|
25
25
|
expect(subject.build_value('Common_Form')).to be_kind_of(IdentifierValue)
|
@@ -33,4 +33,4 @@ module Zenlish
|
|
33
33
|
end # context
|
34
34
|
end # describe
|
35
35
|
end # module
|
36
|
-
end # module
|
36
|
+
end # module
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# Load the class under test
|
4
|
-
require_relative '../../../lib/zenlish/feature/identifier_value'
|
4
|
+
require_relative '../../../lib/zenlish/feature/identifier_value'
|
5
5
|
|
6
6
|
module Zenlish
|
7
7
|
module Feature
|
@@ -13,14 +13,14 @@ module Zenlish
|
|
13
13
|
it 'should be initialized with a value argument' do
|
14
14
|
expect { IdentifierValue.new(its_value) }.not_to raise_error
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it 'should know its internal value' do
|
18
18
|
expect(subject.val).to eq(its_value)
|
19
|
-
end
|
19
|
+
end
|
20
20
|
end # context
|
21
21
|
|
22
22
|
context 'Provided services:' do
|
23
23
|
end # context
|
24
24
|
end # describe
|
25
25
|
end # module
|
26
|
-
end # module
|
26
|
+
end # module
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative '../../../lib/zenlish/feature/enumeration_domain'
|
4
4
|
# Load the class under test
|
5
|
-
require_relative '../../../lib/zenlish/feature/symbol_value'
|
5
|
+
require_relative '../../../lib/zenlish/feature/symbol_value'
|
6
6
|
|
7
7
|
module Zenlish
|
8
8
|
module Feature
|
@@ -14,10 +14,10 @@ module Zenlish
|
|
14
14
|
it 'should be initialized with a value argument' do
|
15
15
|
expect { SymbolValue.new(its_value) }.not_to raise_error
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
it 'should know its internal value' do
|
19
19
|
expect(subject.val).to eq(its_value)
|
20
|
-
end
|
20
|
+
end
|
21
21
|
end # context
|
22
22
|
|
23
23
|
context 'Provided services:' do
|
@@ -11,30 +11,30 @@ module Zenlish
|
|
11
11
|
let(:suffix) { LiteralAsIs.new('s') }
|
12
12
|
let(:sample_argument) { FormalArgument.new(2) }
|
13
13
|
let(:base_form) { InputAsIs.new(sample_argument) }
|
14
|
-
|
14
|
+
|
15
15
|
subject { Concatenation.new(base_form, suffix) }
|
16
16
|
|
17
17
|
context 'Initialization:' do
|
18
18
|
it 'should be initialized with two arguments' do
|
19
19
|
expect { Concatenation.new(base_form, suffix) }.not_to raise_error
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it 'should know its arguments' do
|
23
23
|
expect(subject.children.first).to eq(base_form)
|
24
|
-
expect(subject.children.last).to eq(suffix)
|
24
|
+
expect(subject.children.last).to eq(suffix)
|
25
25
|
end
|
26
26
|
end # context
|
27
27
|
|
28
28
|
context 'Provided services:' do
|
29
|
-
let(:sample_values) { [nil, nil, 'place', nil] }
|
30
|
-
|
29
|
+
let(:sample_values) { [nil, nil, 'place', nil] }
|
30
|
+
|
31
31
|
it 'should do the concatenation of children results' do
|
32
32
|
headings = double('fake-headings')
|
33
33
|
lexeme = double('fake-lexeme')
|
34
|
-
|
34
|
+
|
35
35
|
expect(subject.generate(headings, lexeme, sample_values)).to eq('places')
|
36
36
|
end
|
37
37
|
end # context
|
38
38
|
end # describe
|
39
39
|
end # module
|
40
|
-
end # module
|
40
|
+
end # module
|
@@ -13,18 +13,38 @@ module Zenlish
|
|
13
13
|
it 'should be initialized with a feature name' do
|
14
14
|
expect { FeatureHeading.new(feature_name) }.not_to raise_error
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it 'should know its label' do
|
18
18
|
expect(subject.label).to eq(feature_name)
|
19
19
|
end
|
20
20
|
end # context
|
21
21
|
|
22
22
|
context 'Provided services:' do
|
23
|
-
|
23
|
+
let(:a_domain) { Feature::EnumerationDomain.new(:singular, :plural) }
|
24
|
+
let(:enum_def) { Feature::FeatureDef.new(feature_name, a_domain) }
|
25
|
+
let(:b_domain) { Feature::BooleanDomain.instance }
|
26
|
+
let(:bool_def) { Feature::FeatureDef.new(feature_name, b_domain) }
|
27
|
+
|
28
|
+
it 'should obtain the value of a feature' do
|
24
29
|
mocked = { 'NUMBER' => :plural }
|
25
30
|
expect(subject.evaluate_for(mocked)).to eq(:plural)
|
26
31
|
end
|
32
|
+
|
33
|
+
it 'should obtain all possible values of a feature' do
|
34
|
+
mocked = { 'NUMBER' => :plural }
|
35
|
+
expect(subject.all_matches(mocked)).to eq([:plural])
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should obtain all possible values of a enumeration domain' do
|
39
|
+
mocked = { 'NUMBER' => enum_def }
|
40
|
+
expect(subject.all_matches(mocked)).to eq(%i[singular plural])
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should obtain all possible values of a enumeration domain' do
|
44
|
+
mocked = { 'NUMBER' => bool_def }
|
45
|
+
expect(subject.all_matches(mocked)).to eq([false, true])
|
46
|
+
end
|
27
47
|
end # context
|
28
48
|
end # describe
|
29
49
|
end # module
|
30
|
-
end # module
|
50
|
+
end # module
|
@@ -12,7 +12,7 @@ module Zenlish
|
|
12
12
|
it 'should be initialized with a text literal' do
|
13
13
|
expect { FormalArgument.new(1) }.not_to raise_error
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it 'should know its index value' do
|
17
17
|
expect(subject.index).to eq(3)
|
18
18
|
end
|
@@ -22,4 +22,4 @@ module Zenlish
|
|
22
22
|
end # context
|
23
23
|
end # describe
|
24
24
|
end # module
|
25
|
-
end # module
|
25
|
+
end # module
|