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
@@ -3,10 +3,17 @@
|
|
3
3
|
require_relative '../../spec_helper' # Use the RSpec framework
|
4
4
|
|
5
5
|
# Load the class under test
|
6
|
-
require_relative '../../../lib/zenlish/wclasses/lexical_verb'
|
6
|
+
require_relative '../../../lib/zenlish/wclasses/lexical_verb'
|
7
7
|
|
8
8
|
module Zenlish
|
9
9
|
module WClasses
|
10
|
+
class LexicalVerb
|
11
|
+
# Do limited monkeypatching, just for testing purposes
|
12
|
+
def init_paradigms
|
13
|
+
# Empty method
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
10
17
|
describe LexicalVerb do
|
11
18
|
subject { LexicalVerb.new }
|
12
19
|
|
@@ -20,7 +27,7 @@ module Zenlish
|
|
20
27
|
it 'should know its inherited feature definitions' do
|
21
28
|
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
22
29
|
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
23
|
-
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
30
|
+
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
24
31
|
end
|
25
32
|
end # context
|
26
33
|
end # describe
|
@@ -0,0 +1,50 @@
|
|
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/modal_verb_can'
|
9
|
+
|
10
|
+
module Zenlish
|
11
|
+
module WClasses
|
12
|
+
describe ModalVerbCan do
|
13
|
+
subject { ModalVerbCan.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { ModalVerbCan.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
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('Verb_can_inflection')
|
26
|
+
end
|
27
|
+
|
28
|
+
def build_verb(aBaseForm)
|
29
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
30
|
+
Zenlish::Lex::Lexeme.new(subject, entry)
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_inflection_of(verb_form, pairs)
|
34
|
+
verb = build_verb(verb_form)
|
35
|
+
pairs.each do |(time, expected_form)|
|
36
|
+
expect(verb.inflect([time])).to eq(expected_form)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should know how to inflect modal verb can' do
|
41
|
+
expectations1 = [
|
42
|
+
[:present, 'can'],
|
43
|
+
[:past_simple, 'could']
|
44
|
+
]
|
45
|
+
test_inflection_of('can', expectations1)
|
46
|
+
end
|
47
|
+
end # context
|
48
|
+
end # describe
|
49
|
+
end # module
|
50
|
+
end # module
|
@@ -0,0 +1,66 @@
|
|
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
|
+
require_relative '../../../lib/zenlish/feature/feature_struct_def_bearer'
|
7
|
+
require_relative '../../../lib/zenlish/wclasses/personal_pronoun' # Load the class under test
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module WClasses
|
11
|
+
describe PersonalPronoun do
|
12
|
+
include Feature::FeatureStructDefBearer
|
13
|
+
subject { PersonalPronoun.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { PersonalPronoun.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should know that it is inflectable' do
|
21
|
+
expect(subject).not_to be_invariable
|
22
|
+
end
|
23
|
+
end # context
|
24
|
+
|
25
|
+
context 'Provided services:' do
|
26
|
+
def build_ppn(aBaseForm, aFeatureHash)
|
27
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
28
|
+
Zenlish::Lex::Lexeme.new(subject, entry, aFeatureHash)
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_all_inflections(det_form, aFeatureHash, wforms)
|
32
|
+
pronoun = build_ppn(det_form, aFeatureHash)
|
33
|
+
inflected = pronoun.all_inflections
|
34
|
+
expect(inflected.sort).to eq(wforms.sort)
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should know its feature definitions' do
|
38
|
+
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
39
|
+
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
40
|
+
expect(subject['GENDER']).to be_kind_of(Feature::FeatureDef)
|
41
|
+
expect(subject['CASE']).to be_kind_of(Feature::FeatureDef)
|
42
|
+
expect(subject['PARADIGM'].default.val).to eq('ppn_1st_paradigm')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should give all word forms for the first person' do
|
46
|
+
feature_defs = { 'PERSON' => enumeration(:first),
|
47
|
+
'GENDER' => enumeration(:feminine, :masculine) }
|
48
|
+
test_all_inflections('I', feature_defs, %w[I we me us])
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should give all word forms for the second person' do
|
52
|
+
feature_defs = { 'PERSON' => enumeration(:second),
|
53
|
+
'GENDER' => enumeration(:feminine, :masculine),
|
54
|
+
'PARADIGM' => [identifier, 'ppn_2nd_paradigm'] }
|
55
|
+
test_all_inflections('you', feature_defs, ['you'])
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should give all word forms for the third person' do
|
59
|
+
feature_defs = { 'PERSON' => enumeration(:third),
|
60
|
+
'PARADIGM' => [identifier, 'ppn_3rd_paradigm'] }
|
61
|
+
test_all_inflections('it', feature_defs, %w[she he it they her him them])
|
62
|
+
end
|
63
|
+
end # context
|
64
|
+
end # describe
|
65
|
+
end # module
|
66
|
+
end # module
|
@@ -0,0 +1,69 @@
|
|
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
|
+
require_relative '../../../lib/zenlish/feature/feature_struct_def_bearer'
|
7
|
+
require_relative '../../../lib/zenlish/wclasses/possessive_determiner' # Load the class under test
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module WClasses
|
11
|
+
describe PossessiveDeterminer do
|
12
|
+
include Feature::FeatureStructDefBearer
|
13
|
+
subject { PossessiveDeterminer.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { PossessiveDeterminer.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
21
|
+
context 'Provided services:' do
|
22
|
+
def build_det(aBaseForm, aFeatureHash)
|
23
|
+
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
24
|
+
Zenlish::Lex::Lexeme.new(subject, entry, aFeatureHash)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_all_inflections(det_form, aFeatureHash, wforms)
|
28
|
+
pronoun = build_det(det_form, aFeatureHash)
|
29
|
+
inflected = pronoun.all_inflections
|
30
|
+
expect(inflected.sort).to eq(wforms.sort)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'should know that it is inflectable' do
|
34
|
+
expect(subject).not_to be_invariable
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should know its feature definitions' do
|
38
|
+
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
39
|
+
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
40
|
+
expect(subject['GENDER']).to be_kind_of(Feature::FeatureDef)
|
41
|
+
expect(subject['PARADIGM'].default.val).to eq('possdet_1st_paradigm')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should give 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])
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'should give all word forms for the second person' do
|
51
|
+
feature_defs = { 'PERSON' => enumeration(:second),
|
52
|
+
'GENDER' => enumeration(:feminine, :masculine),
|
53
|
+
'PARADIGM' => [identifier, 'possdet_2nd_paradigm'] }
|
54
|
+
test_all_inflections('your', feature_defs, ['your'])
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should give 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
|
62
|
+
|
63
|
+
# it 'should give all word forms' do
|
64
|
+
# test_all_inflections('this', ['this', 'that', 'these', 'those'])
|
65
|
+
# end
|
66
|
+
end # context
|
67
|
+
end # describe
|
68
|
+
end # module
|
69
|
+
end # module
|
@@ -24,17 +24,17 @@ module Zenlish
|
|
24
24
|
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
25
|
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
let(:present_1sg) { [:first, :singular, :present, nil] }
|
29
29
|
let(:present_3sg) { [:third, :singular, :present, nil] }
|
30
30
|
let(:present_1pl) { [:first, :plural, :present, nil] }
|
31
31
|
let(:progressive) { [nil, nil, :progressive, nil] }
|
32
32
|
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
33
|
-
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
34
|
-
|
33
|
+
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
34
|
+
|
35
35
|
def build_verb(aBaseForm)
|
36
36
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
37
|
-
|
37
|
+
Zenlish::Lex::Lexeme.new(subject, entry)
|
38
38
|
end
|
39
39
|
|
40
40
|
def test_inflection_of(verb_form, pairs)
|
@@ -44,8 +44,14 @@ module Zenlish
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def test_all_inflections(verb_form, wforms)
|
48
|
+
verb = build_verb(verb_form)
|
49
|
+
inflected = verb.all_inflections
|
50
|
+
expect(inflected.sort).to eq(wforms.sort)
|
51
|
+
end
|
52
|
+
|
47
53
|
it 'should know how to inflect regular verbs' do
|
48
|
-
|
54
|
+
expectations1 = [
|
49
55
|
[present_1sg, 'exist'],
|
50
56
|
[present_3sg, 'exists'],
|
51
57
|
[present_1pl, 'exist'],
|
@@ -53,9 +59,9 @@ module Zenlish
|
|
53
59
|
[past_simple, 'existed'],
|
54
60
|
[past_participle, 'existed']
|
55
61
|
]
|
56
|
-
test_inflection_of('exist',
|
62
|
+
test_inflection_of('exist', expectations1)
|
57
63
|
|
58
|
-
|
64
|
+
expectations2 = [
|
59
65
|
[present_1sg, 'move'],
|
60
66
|
[present_3sg, 'moves'],
|
61
67
|
[present_1pl, 'move'],
|
@@ -63,9 +69,9 @@ module Zenlish
|
|
63
69
|
[past_simple, 'moved'],
|
64
70
|
[past_participle, 'moved']
|
65
71
|
]
|
66
|
-
test_inflection_of('move',
|
72
|
+
test_inflection_of('move', expectations2)
|
67
73
|
|
68
|
-
|
74
|
+
expectations3 = [
|
69
75
|
[present_1sg, 'try'],
|
70
76
|
[present_3sg, 'tries'],
|
71
77
|
[present_1pl, 'try'],
|
@@ -73,9 +79,9 @@ module Zenlish
|
|
73
79
|
[past_simple, 'tried'],
|
74
80
|
[past_participle, 'tried']
|
75
81
|
]
|
76
|
-
test_inflection_of('try',
|
82
|
+
test_inflection_of('try', expectations3)
|
77
83
|
|
78
|
-
|
84
|
+
expectations4 = [
|
79
85
|
[present_1sg, 'touch'],
|
80
86
|
[present_3sg, 'touches'],
|
81
87
|
[present_1pl, 'touch'],
|
@@ -83,9 +89,9 @@ module Zenlish
|
|
83
89
|
[past_simple, 'touched'],
|
84
90
|
[past_participle, 'touched']
|
85
91
|
]
|
86
|
-
test_inflection_of('touch',
|
92
|
+
test_inflection_of('touch', expectations4)
|
87
93
|
|
88
|
-
|
94
|
+
expectations5 = [
|
89
95
|
[present_1sg, 'die'],
|
90
96
|
[present_3sg, 'dies'],
|
91
97
|
[present_1pl, 'die'],
|
@@ -93,9 +99,23 @@ module Zenlish
|
|
93
99
|
[past_simple, 'died'],
|
94
100
|
[past_participle, 'died']
|
95
101
|
]
|
96
|
-
test_inflection_of('die',
|
102
|
+
test_inflection_of('die', expectations5)
|
103
|
+
|
104
|
+
expectations6 = [
|
105
|
+
[present_1sg, 'want'],
|
106
|
+
[present_3sg, 'wants'],
|
107
|
+
[present_1pl, 'want'],
|
108
|
+
[progressive, 'wanting'],
|
109
|
+
[past_simple, 'wanted'],
|
110
|
+
[past_participle, 'wanted']
|
111
|
+
]
|
112
|
+
test_inflection_of('want', expectations6)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'should give all word forms of a given verb' do
|
116
|
+
test_all_inflections('die', %w[die dies dying died])
|
97
117
|
end
|
98
118
|
end # context
|
99
119
|
end # describe
|
100
120
|
end # module
|
101
|
-
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 { RegularVerbWant.new }
|
14
|
+
|
15
|
+
context 'Initialization:' do
|
16
|
+
it 'should be initialized without argument' do
|
17
|
+
expect { RegularVerbWant.new }.not_to raise_error
|
18
|
+
end
|
19
|
+
end # context
|
20
|
+
|
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
|
+
end # context
|
28
|
+
end # describe
|
29
|
+
end # module
|
30
|
+
end # module
|
@@ -5,6 +5,13 @@ require_relative '../../../lib/zenlish/wclasses/verb' # Load the class under tes
|
|
5
5
|
|
6
6
|
module Zenlish
|
7
7
|
module WClasses
|
8
|
+
class Verb
|
9
|
+
# Do limited monkeypatching, just for testing purposes
|
10
|
+
def init_paradigms
|
11
|
+
# Empty method
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
8
15
|
describe Verb do
|
9
16
|
subject { Verb.new }
|
10
17
|
|
@@ -18,11 +25,11 @@ module Zenlish
|
|
18
25
|
it 'should know that it has inflected forms' do
|
19
26
|
expect(subject).not_to be_invariable
|
20
27
|
end
|
21
|
-
|
28
|
+
|
22
29
|
it 'should know its feature definitions' do
|
23
30
|
expect(subject['NUMBER']).to be_kind_of(Feature::FeatureDef)
|
24
31
|
expect(subject['PERSON']).to be_kind_of(Feature::FeatureDef)
|
25
|
-
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
32
|
+
expect(subject['PARADIGM'].default.val).to eq('Regular_inflection')
|
26
33
|
end
|
27
34
|
end # context
|
28
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,30 @@ 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 = '>= 2.5.0'
|
58
|
+
|
56
59
|
# Runtime dependencies
|
57
|
-
spec.add_dependency 'rley', '~> 0.
|
60
|
+
spec.add_dependency 'rley', '~> 0.8.03'
|
58
61
|
|
59
|
-
spec.add_development_dependency
|
60
|
-
spec.add_development_dependency
|
61
|
-
spec.add_development_dependency
|
62
|
+
spec.add_development_dependency 'bundler', '~> 2.0'
|
63
|
+
spec.add_development_dependency 'rake', '~> 12.0'
|
64
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
62
65
|
end
|