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
@@ -10,24 +10,24 @@ require_relative '../../../lib/zenlish/wclasses/modal_verb_can'
|
|
10
10
|
module Zenlish
|
11
11
|
module WClasses
|
12
12
|
describe ModalVerbCan do
|
13
|
-
subject {
|
13
|
+
subject(:modal_can) { described_class.new }
|
14
14
|
|
15
15
|
context 'Initialization:' do
|
16
|
-
it '
|
17
|
-
expect {
|
16
|
+
it 'is initialized without argument' do
|
17
|
+
expect { described_class.new }.not_to raise_error
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
21
21
|
context 'Provided services:' do
|
22
|
-
it '
|
23
|
-
expect(
|
24
|
-
expect(
|
25
|
-
expect(
|
22
|
+
it 'knows its inherited feature definitions' do
|
23
|
+
expect(modal_can['NUMBER']).to be_a(Feature::FeatureDef)
|
24
|
+
expect(modal_can['PERSON']).to be_a(Feature::FeatureDef)
|
25
|
+
expect(modal_can['PARADIGM'].default.val).to eq('Verb_can_inflection')
|
26
26
|
end
|
27
27
|
|
28
28
|
def build_verb(aBaseForm)
|
29
29
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
30
|
-
|
30
|
+
Zenlish::Lex::Lexeme.new(modal_can, entry)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_inflection_of(verb_form, pairs)
|
@@ -37,14 +37,14 @@ module Zenlish
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
41
|
-
|
40
|
+
it 'knows how to inflect modal verb can' do
|
41
|
+
expectations1 = [
|
42
42
|
[:present, 'can'],
|
43
43
|
[:past_simple, 'could']
|
44
44
|
]
|
45
|
-
test_inflection_of('can',
|
45
|
+
test_inflection_of('can', expectations1)
|
46
46
|
end
|
47
47
|
end # context
|
48
48
|
end # describe
|
49
49
|
end # module
|
50
|
-
end # module
|
50
|
+
end # module
|
@@ -6,23 +6,23 @@ require_relative '../../../lib/zenlish/wclasses/noun' # Load the class under tes
|
|
6
6
|
module Zenlish
|
7
7
|
module WClasses
|
8
8
|
describe Noun do
|
9
|
-
subject {
|
9
|
+
subject(:noun) { described_class.new }
|
10
10
|
|
11
11
|
context 'Initialization:' do
|
12
|
-
it '
|
13
|
-
expect {
|
12
|
+
it 'is initialized without argument' do
|
13
|
+
expect { described_class.new }.not_to raise_error
|
14
14
|
end
|
15
15
|
end # context
|
16
16
|
|
17
17
|
context 'Provided services:' do
|
18
|
-
it '
|
19
|
-
expect(
|
18
|
+
it 'knows that it is variable (has inflected forms)' do
|
19
|
+
expect(noun).not_to be_invariable
|
20
20
|
end
|
21
21
|
|
22
|
-
it '
|
22
|
+
it 'knows its feature names' do
|
23
23
|
expectations = %w(NUMBER COUNTABILITY)
|
24
24
|
expectations.each do |name|
|
25
|
-
expect(
|
25
|
+
expect(noun[name]).not_to be_nil
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end # context
|
@@ -10,22 +10,22 @@ module Zenlish
|
|
10
10
|
module WClasses
|
11
11
|
describe PersonalPronoun do
|
12
12
|
include Feature::FeatureStructDefBearer
|
13
|
-
subject {
|
13
|
+
subject(:pronoun) { described_class.new }
|
14
14
|
|
15
15
|
context 'Initialization:' do
|
16
|
-
it '
|
17
|
-
expect {
|
16
|
+
it 'is initialized without argument' do
|
17
|
+
expect { described_class.new }.not_to raise_error
|
18
18
|
end
|
19
19
|
|
20
|
-
it '
|
21
|
-
expect(
|
20
|
+
it 'knows that it is inflectable' do
|
21
|
+
expect(pronoun).not_to be_invariable
|
22
22
|
end
|
23
23
|
end # context
|
24
24
|
|
25
25
|
context 'Provided services:' do
|
26
26
|
def build_ppn(aBaseForm, aFeatureHash)
|
27
27
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
28
|
-
|
28
|
+
Zenlish::Lex::Lexeme.new(pronoun, entry, aFeatureHash)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_all_inflections(det_form, aFeatureHash, wforms)
|
@@ -34,34 +34,31 @@ module Zenlish
|
|
34
34
|
expect(inflected.sort).to eq(wforms.sort)
|
35
35
|
end
|
36
36
|
|
37
|
-
it '
|
38
|
-
expect(
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
42
|
-
expect(
|
37
|
+
it 'knows its feature definitions' do
|
38
|
+
expect(pronoun['NUMBER']).to be_a(Feature::FeatureDef)
|
39
|
+
expect(pronoun['PERSON']).to be_a(Feature::FeatureDef)
|
40
|
+
expect(pronoun['GENDER']).to be_a(Feature::FeatureDef)
|
41
|
+
expect(pronoun['CASE']).to be_a(Feature::FeatureDef)
|
42
|
+
expect(pronoun['PARADIGM'].default.val).to eq('ppn_1st_paradigm')
|
43
43
|
end
|
44
44
|
|
45
|
-
it '
|
45
|
+
it 'gives all word forms for the first person' do
|
46
46
|
feature_defs = { 'PERSON' => enumeration(:first),
|
47
|
-
'GENDER' => enumeration(:feminine, :masculine)
|
48
|
-
|
49
|
-
test_all_inflections('I', feature_defs, ['I', 'we', 'me', 'us'])
|
47
|
+
'GENDER' => enumeration(:feminine, :masculine) }
|
48
|
+
test_all_inflections('I', feature_defs, %w[I we me us])
|
50
49
|
end
|
51
50
|
|
52
|
-
it '
|
51
|
+
it 'gives all word forms for the second person' do
|
53
52
|
feature_defs = { 'PERSON' => enumeration(:second),
|
54
53
|
'GENDER' => enumeration(:feminine, :masculine),
|
55
|
-
'PARADIGM' => [identifier, 'ppn_2nd_paradigm']
|
56
|
-
}
|
54
|
+
'PARADIGM' => [identifier, 'ppn_2nd_paradigm'] }
|
57
55
|
test_all_inflections('you', feature_defs, ['you'])
|
58
56
|
end
|
59
57
|
|
60
|
-
it '
|
58
|
+
it 'gives all word forms for the third person' do
|
61
59
|
feature_defs = { 'PERSON' => enumeration(:third),
|
62
|
-
'PARADIGM' => [identifier, 'ppn_3rd_paradigm']
|
63
|
-
|
64
|
-
test_all_inflections('it', feature_defs, ['she', 'he', 'it', 'they', 'her', 'him', 'them'])
|
60
|
+
'PARADIGM' => [identifier, 'ppn_3rd_paradigm'] }
|
61
|
+
test_all_inflections('it', feature_defs, %w[she he it they her him them])
|
65
62
|
end
|
66
63
|
end # context
|
67
64
|
end # describe
|
@@ -10,60 +10,57 @@ module Zenlish
|
|
10
10
|
module WClasses
|
11
11
|
describe PossessiveDeterminer do
|
12
12
|
include Feature::FeatureStructDefBearer
|
13
|
-
subject {
|
13
|
+
subject(:determiner) { described_class.new }
|
14
14
|
|
15
15
|
context 'Initialization:' do
|
16
|
-
it '
|
17
|
-
expect {
|
16
|
+
it 'is initialized without argument' do
|
17
|
+
expect { described_class.new }.not_to raise_error
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
21
|
-
context 'Provided services:' do
|
21
|
+
context 'Provided services:' do
|
22
22
|
def build_det(aBaseForm, aFeatureHash)
|
23
23
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
24
|
-
|
24
|
+
Zenlish::Lex::Lexeme.new(determiner, entry, aFeatureHash)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_all_inflections(det_form, aFeatureHash, wforms)
|
28
28
|
pronoun = build_det(det_form, aFeatureHash)
|
29
29
|
inflected = pronoun.all_inflections
|
30
30
|
expect(inflected.sort).to eq(wforms.sort)
|
31
|
-
end
|
31
|
+
end
|
32
32
|
|
33
|
-
it '
|
34
|
-
expect(
|
33
|
+
it 'knows that it is inflectable' do
|
34
|
+
expect(determiner).not_to be_invariable
|
35
35
|
end
|
36
36
|
|
37
|
-
it '
|
38
|
-
expect(
|
39
|
-
expect(
|
40
|
-
expect(
|
41
|
-
expect(
|
37
|
+
it 'knows its feature definitions' do
|
38
|
+
expect(determiner['NUMBER']).to be_a(Feature::FeatureDef)
|
39
|
+
expect(determiner['PERSON']).to be_a(Feature::FeatureDef)
|
40
|
+
expect(determiner['GENDER']).to be_a(Feature::FeatureDef)
|
41
|
+
expect(determiner['PARADIGM'].default.val).to eq('possdet_1st_paradigm')
|
42
42
|
end
|
43
|
-
|
44
|
-
it '
|
45
|
-
feature_defs = { 'PERSON' => enumeration(:first),
|
46
|
-
'GENDER' => enumeration(:feminine, :masculine)
|
47
|
-
|
48
|
-
test_all_inflections('my', feature_defs, ['my', 'our'])
|
43
|
+
|
44
|
+
it 'gives all word forms for the first person' do
|
45
|
+
feature_defs = { 'PERSON' => enumeration(:first),
|
46
|
+
'GENDER' => enumeration(:feminine, :masculine) }
|
47
|
+
test_all_inflections('my', feature_defs, %w[my our])
|
49
48
|
end
|
50
|
-
|
51
|
-
it '
|
52
|
-
feature_defs = { 'PERSON' => enumeration(:second),
|
49
|
+
|
50
|
+
it 'gives all word forms for the second person' do
|
51
|
+
feature_defs = { 'PERSON' => enumeration(:second),
|
53
52
|
'GENDER' => enumeration(:feminine, :masculine),
|
54
|
-
'PARADIGM' => [identifier, 'possdet_2nd_paradigm']
|
55
|
-
}
|
53
|
+
'PARADIGM' => [identifier, 'possdet_2nd_paradigm'] }
|
56
54
|
test_all_inflections('your', feature_defs, ['your'])
|
57
55
|
end
|
58
56
|
|
59
|
-
it '
|
60
|
-
feature_defs = { 'PERSON' => enumeration(:third),
|
61
|
-
'PARADIGM' => [identifier, 'possdet_3rd_paradigm']
|
62
|
-
|
63
|
-
|
64
|
-
end
|
57
|
+
it 'gives all word forms for the third person' do
|
58
|
+
feature_defs = { 'PERSON' => enumeration(:third),
|
59
|
+
'PARADIGM' => [identifier, 'possdet_3rd_paradigm'] }
|
60
|
+
test_all_inflections('its', feature_defs, %w[its her his their])
|
61
|
+
end
|
65
62
|
|
66
|
-
# it '
|
63
|
+
# it 'gives all word forms' do
|
67
64
|
# test_all_inflections('this', ['this', 'that', 'these', 'those'])
|
68
65
|
# end
|
69
66
|
end # context
|
@@ -6,17 +6,17 @@ require_relative '../../../lib/zenlish/wclasses/preposition' # Load the class un
|
|
6
6
|
module Zenlish
|
7
7
|
module WClasses
|
8
8
|
describe Preposition do
|
9
|
-
subject {
|
9
|
+
subject(:preposition) { described_class.new }
|
10
10
|
|
11
11
|
context 'Initialization:' do
|
12
|
-
it '
|
13
|
-
expect {
|
12
|
+
it 'is initialized without argument' do
|
13
|
+
expect { described_class.new }.not_to raise_error
|
14
14
|
end
|
15
15
|
end # context
|
16
16
|
|
17
17
|
context 'Provided services:' do
|
18
|
-
it '
|
19
|
-
expect(
|
18
|
+
it 'is invariable' do
|
19
|
+
expect(preposition).to be_invariable
|
20
20
|
end
|
21
21
|
end # context
|
22
22
|
end # describe
|
@@ -6,11 +6,11 @@ require_relative '../../../lib/zenlish/wclasses/proper_noun' # Load the class un
|
|
6
6
|
module Zenlish
|
7
7
|
module WClasses
|
8
8
|
describe ProperNoun do
|
9
|
-
subject {
|
9
|
+
subject { described_class.new }
|
10
10
|
|
11
11
|
context 'Initialization:' do
|
12
|
-
it '
|
13
|
-
expect {
|
12
|
+
it 'is initialized without argument' do
|
13
|
+
expect { described_class.new }.not_to raise_error
|
14
14
|
end
|
15
15
|
end # context
|
16
16
|
|
@@ -10,31 +10,25 @@ require_relative '../../../lib/zenlish/wclasses/regular_verb'
|
|
10
10
|
module Zenlish
|
11
11
|
module WClasses
|
12
12
|
describe RegularVerb do
|
13
|
-
subject {
|
13
|
+
subject(:regular_verb) { described_class.new }
|
14
14
|
|
15
15
|
context 'Initialization:' do
|
16
|
-
it '
|
17
|
-
expect {
|
16
|
+
it 'is initialized without argument' do
|
17
|
+
expect { described_class.new }.not_to raise_error
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
21
21
|
context 'Provided services:' do
|
22
|
-
it 'should know its inherited feature definitions' do
|
23
|
-
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
24
|
-
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
|
-
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
26
|
-
end
|
27
|
-
|
28
22
|
let(:present_1sg) { [:first, :singular, :present, nil] }
|
29
23
|
let(:present_3sg) { [:third, :singular, :present, nil] }
|
30
24
|
let(:present_1pl) { [:first, :plural, :present, nil] }
|
31
25
|
let(:progressive) { [nil, nil, :progressive, nil] }
|
32
26
|
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
33
|
-
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
34
|
-
|
27
|
+
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
28
|
+
|
35
29
|
def build_verb(aBaseForm)
|
36
30
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
37
|
-
|
31
|
+
Zenlish::Lex::Lexeme.new(regular_verb, entry)
|
38
32
|
end
|
39
33
|
|
40
34
|
def test_inflection_of(verb_form, pairs)
|
@@ -43,15 +37,21 @@ module Zenlish
|
|
43
37
|
expect(verb.inflect(constraints)).to eq(expected_form)
|
44
38
|
end
|
45
39
|
end
|
46
|
-
|
40
|
+
|
47
41
|
def test_all_inflections(verb_form, wforms)
|
48
42
|
verb = build_verb(verb_form)
|
49
43
|
inflected = verb.all_inflections
|
50
44
|
expect(inflected.sort).to eq(wforms.sort)
|
51
45
|
end
|
52
46
|
|
53
|
-
it '
|
54
|
-
|
47
|
+
it 'knows its inherited feature definitions' do
|
48
|
+
expect(regular_verb['NUMBER']).to be_a(Feature::FeatureDef)
|
49
|
+
expect(regular_verb['PERSON']).to be_a(Feature::FeatureDef)
|
50
|
+
expect(regular_verb['PARADIGM'].default.val).to eq('Regular_inflection')
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'knows how to inflect regular verbs' do
|
54
|
+
expectations1 = [
|
55
55
|
[present_1sg, 'exist'],
|
56
56
|
[present_3sg, 'exists'],
|
57
57
|
[present_1pl, 'exist'],
|
@@ -59,9 +59,9 @@ module Zenlish
|
|
59
59
|
[past_simple, 'existed'],
|
60
60
|
[past_participle, 'existed']
|
61
61
|
]
|
62
|
-
test_inflection_of('exist',
|
62
|
+
test_inflection_of('exist', expectations1)
|
63
63
|
|
64
|
-
|
64
|
+
expectations2 = [
|
65
65
|
[present_1sg, 'move'],
|
66
66
|
[present_3sg, 'moves'],
|
67
67
|
[present_1pl, 'move'],
|
@@ -69,9 +69,9 @@ module Zenlish
|
|
69
69
|
[past_simple, 'moved'],
|
70
70
|
[past_participle, 'moved']
|
71
71
|
]
|
72
|
-
test_inflection_of('move',
|
72
|
+
test_inflection_of('move', expectations2)
|
73
73
|
|
74
|
-
|
74
|
+
expectations3 = [
|
75
75
|
[present_1sg, 'try'],
|
76
76
|
[present_3sg, 'tries'],
|
77
77
|
[present_1pl, 'try'],
|
@@ -79,9 +79,9 @@ module Zenlish
|
|
79
79
|
[past_simple, 'tried'],
|
80
80
|
[past_participle, 'tried']
|
81
81
|
]
|
82
|
-
test_inflection_of('try',
|
82
|
+
test_inflection_of('try', expectations3)
|
83
83
|
|
84
|
-
|
84
|
+
expectations4 = [
|
85
85
|
[present_1sg, 'touch'],
|
86
86
|
[present_3sg, 'touches'],
|
87
87
|
[present_1pl, 'touch'],
|
@@ -89,9 +89,9 @@ module Zenlish
|
|
89
89
|
[past_simple, 'touched'],
|
90
90
|
[past_participle, 'touched']
|
91
91
|
]
|
92
|
-
test_inflection_of('touch',
|
92
|
+
test_inflection_of('touch', expectations4)
|
93
93
|
|
94
|
-
|
94
|
+
expectations5 = [
|
95
95
|
[present_1sg, 'die'],
|
96
96
|
[present_3sg, 'dies'],
|
97
97
|
[present_1pl, 'die'],
|
@@ -99,9 +99,9 @@ module Zenlish
|
|
99
99
|
[past_simple, 'died'],
|
100
100
|
[past_participle, 'died']
|
101
101
|
]
|
102
|
-
test_inflection_of('die',
|
102
|
+
test_inflection_of('die', expectations5)
|
103
103
|
|
104
|
-
|
104
|
+
expectations6 = [
|
105
105
|
[present_1sg, 'want'],
|
106
106
|
[present_3sg, 'wants'],
|
107
107
|
[present_1pl, 'want'],
|
@@ -109,13 +109,13 @@ module Zenlish
|
|
109
109
|
[past_simple, 'wanted'],
|
110
110
|
[past_participle, 'wanted']
|
111
111
|
]
|
112
|
-
test_inflection_of('want',
|
112
|
+
test_inflection_of('want', expectations6)
|
113
113
|
end
|
114
|
-
|
115
|
-
it '
|
116
|
-
test_all_inflections('die', [
|
114
|
+
|
115
|
+
it 'gives all word forms of a given verb' do
|
116
|
+
test_all_inflections('die', %w[die dies dying died])
|
117
117
|
end
|
118
118
|
end # context
|
119
119
|
end # describe
|
120
120
|
end # module
|
121
|
-
end # module
|
121
|
+
end # module
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
require_relative '../../../lib/zenlish/lex/lexical_entry'
|
5
|
+
require_relative '../../../lib/zenlish/lex/lexeme'
|
6
|
+
|
7
|
+
# Load the class under test
|
8
|
+
require_relative '../../../lib/zenlish/wclasses/regular_verb_want'
|
9
|
+
|
10
|
+
module Zenlish
|
11
|
+
module WClasses
|
12
|
+
describe RegularVerbWant do
|
13
|
+
subject(:the_verb) { described_class.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'is initialized without argument' do
|
17
|
+
expect { described_class.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
it 'knows its inherited feature definitions' do
|
23
|
+
expect(the_verb['NUMBER']).to be_a(Feature::FeatureDef)
|
24
|
+
expect(the_verb['PERSON']).to be_a(Feature::FeatureDef)
|
25
|
+
expect(the_verb['PARADIGM'].default.val).to eq('Regular_inflection')
|
26
|
+
end
|
27
|
+
end # context
|
28
|
+
end # describe
|
29
|
+
end # module
|
30
|
+
end # module
|
@@ -13,23 +13,23 @@ module Zenlish
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe Verb do
|
16
|
-
subject {
|
16
|
+
subject(:a_verb) { described_class.new }
|
17
17
|
|
18
18
|
context 'Initialization:' do
|
19
|
-
it '
|
20
|
-
expect {
|
19
|
+
it 'is initialized without argument' do
|
20
|
+
expect { described_class.new }.not_to raise_error
|
21
21
|
end
|
22
22
|
end # context
|
23
23
|
|
24
24
|
context 'Provided services:' do
|
25
|
-
it '
|
26
|
-
expect(
|
25
|
+
it 'knows that it has inflected forms' do
|
26
|
+
expect(a_verb).not_to be_invariable
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
30
|
-
expect(
|
31
|
-
expect(
|
32
|
-
expect(
|
29
|
+
it 'knows its feature definitions' do
|
30
|
+
expect(a_verb['NUMBER']).to be_a(Feature::FeatureDef)
|
31
|
+
expect(a_verb['PERSON']).to be_a(Feature::FeatureDef)
|
32
|
+
expect(a_verb['PARADIGM'].default.val).to eq('Regular_inflection')
|
33
33
|
end
|
34
34
|
end # context
|
35
35
|
end # describe
|
data/spec/zenlish_spec.rb
CHANGED
data/zenlish.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require
|
5
|
+
require 'zenlish/version'
|
4
6
|
|
5
7
|
# Implementation module
|
6
8
|
module PkgExtending
|
@@ -14,7 +16,7 @@ module PkgExtending
|
|
14
16
|
'Gemfile',
|
15
17
|
'Rakefile',
|
16
18
|
'CHANGELOG.md',
|
17
|
-
'CODE_OF_CONDUCT.md',
|
19
|
+
'CODE_OF_CONDUCT.md',
|
18
20
|
'LICENSE.txt',
|
19
21
|
'README.md',
|
20
22
|
'zenlish.gemspec',
|
@@ -34,29 +36,31 @@ module PkgExtending
|
|
34
36
|
end
|
35
37
|
end # module
|
36
38
|
|
37
|
-
|
38
39
|
Gem::Specification.new do |spec|
|
39
40
|
spec.name = 'zenlish'
|
40
41
|
spec.version = Zenlish::VERSION
|
41
42
|
spec.authors = ['Dimitri Geshef']
|
42
43
|
spec.email = ['famished.tiger@yahoo.com']
|
43
44
|
|
44
|
-
spec.summary =
|
45
|
-
spec.description =
|
46
|
-
spec.homepage =
|
45
|
+
spec.summary = 'A toolkit for the Zenlish language (a simplified English language).'
|
46
|
+
spec.description = 'A toolkit for the Zenlish language (a simplified English language).'
|
47
|
+
spec.homepage = 'https://github.com/famished-tiger/zenlish'
|
47
48
|
spec.license = 'MIT'
|
48
49
|
|
49
50
|
spec.bindir = 'exe'
|
50
51
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
51
|
-
spec.require_paths = [
|
52
|
-
|
52
|
+
spec.require_paths = ['lib']
|
53
|
+
|
53
54
|
PkgExtending.pkg_files(spec)
|
54
55
|
PkgExtending.pkg_documentation(spec)
|
55
|
-
|
56
|
+
|
57
|
+
spec.required_ruby_version = '>= 3.1.0'
|
58
|
+
spec.metadata = { 'rubygems_mfa_required' => 'true' }
|
59
|
+
|
56
60
|
# Runtime dependencies
|
57
|
-
spec.add_dependency 'rley', '~> 0.
|
61
|
+
spec.add_dependency 'rley', '~> 0.9', '>= 0.9.02'
|
58
62
|
|
59
|
-
spec.add_development_dependency
|
60
|
-
spec.add_development_dependency
|
61
|
-
spec.add_development_dependency
|
63
|
+
spec.add_development_dependency 'bundler', '~> 2.4', '>= 2.4.1'
|
64
|
+
spec.add_development_dependency 'rake', '~> 13'
|
65
|
+
spec.add_development_dependency 'rspec', '~> 3', '>= 3.10.0'
|
62
66
|
end
|