zenlish 0.2.06 → 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 +48 -275
- data/CHANGELOG.md +8 -0
- data/LICENSE.txt +1 -1
- data/lib/zenlish/feature/feature_struct_def.rb +0 -2
- data/lib/zenlish/inflect/output_expression.rb +4 -0
- data/lib/zenlish/version.rb +1 -1
- data/lib/zenlish/wclasses/irregular_verb_extension.rb +0 -1
- data/lib/zenlish.rb +3 -3
- data/spec/zenlish/feature/boolean_domain_spec.rb +14 -14
- data/spec/zenlish/feature/boolean_value_spec.rb +6 -5
- data/spec/zenlish/feature/enumeration_domain_spec.rb +16 -16
- data/spec/zenlish/feature/feature_def_spec.rb +15 -14
- data/spec/zenlish/feature/feature_spec.rb +16 -16
- data/spec/zenlish/feature/feature_struct_def_bearer_spec.rb +16 -16
- data/spec/zenlish/feature/feature_struct_def_spec.rb +23 -23
- data/spec/zenlish/feature/identifier_domain_spec.rb +12 -12
- data/spec/zenlish/feature/identifier_value_spec.rb +6 -5
- data/spec/zenlish/feature/symbol_value_spec.rb +6 -5
- data/spec/zenlish/inflect/concatenation_spec.rb +8 -8
- data/spec/zenlish/inflect/equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/feature_heading_spec.rb +14 -13
- data/spec/zenlish/inflect/formal_argument_spec.rb +5 -5
- data/spec/zenlish/inflect/function_call_spec.rb +8 -9
- data/spec/zenlish/inflect/inflection_rule_spec.rb +20 -20
- data/spec/zenlish/inflect/inflection_table_builder_spec.rb +37 -37
- data/spec/zenlish/inflect/inflection_table_spec.rb +33 -32
- data/spec/zenlish/inflect/input_asis_spec.rb +10 -9
- data/spec/zenlish/inflect/literal_asis_spec.rb +7 -7
- data/spec/zenlish/inflect/matches_pattern_spec.rb +15 -14
- data/spec/zenlish/inflect/membership_spec.rb +16 -15
- data/spec/zenlish/inflect/method_heading_spec.rb +12 -11
- data/spec/zenlish/inflect/not_equals_literal_spec.rb +17 -16
- data/spec/zenlish/inflect/substitution_spec.rb +9 -10
- data/spec/zenlish/inflect/unconditionally_true_spec.rb +7 -5
- data/spec/zenlish/lang/dictionary_spec.rb +17 -19
- data/spec/zenlish/lang/lemmatizer_spec.rb +23 -23
- data/spec/zenlish/lang/zenlish_grammar_spec.rb +3 -3
- data/spec/zenlish/lex/empty_lexicon_factory_spec.rb +8 -8
- data/spec/zenlish/lex/lexeme_spec.rb +18 -18
- data/spec/zenlish/lex/lexical_entry_spec.rb +14 -13
- data/spec/zenlish/lex/lexicon_spec.rb +44 -43
- data/spec/zenlish/lex/literal_spec.rb +6 -6
- data/spec/zenlish/lexer/lexer_spec.rb +10 -10
- data/spec/zenlish/parser/lesson1_spec.rb +79 -79
- data/spec/zenlish/parser/lesson2_spec.rb +102 -102
- data/spec/zenlish/parser/lesson3_spec.rb +89 -89
- data/spec/zenlish/parser/zparser_spec.rb +6 -6
- data/spec/zenlish/support/var2word.rb +0 -2
- data/spec/zenlish/trie/base_trie_node_spec.rb +11 -11
- data/spec/zenlish/trie/trie_spec.rb +46 -46
- data/spec/zenlish/wclasses/common_noun_spec.rb +9 -9
- data/spec/zenlish/wclasses/demonstrative_determiner_spec.rb +11 -11
- data/spec/zenlish/wclasses/irregular_verb_can_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_extension_spec.rb +10 -10
- data/spec/zenlish/wclasses/irregular_verb_spec.rb +19 -19
- data/spec/zenlish/wclasses/lexical_verb_spec.rb +7 -7
- data/spec/zenlish/wclasses/modal_verb_can_spec.rb +9 -9
- data/spec/zenlish/wclasses/noun_spec.rb +7 -7
- data/spec/zenlish/wclasses/personal_pronoun_spec.rb +15 -15
- data/spec/zenlish/wclasses/possessive_determiner_spec.rb +15 -15
- 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 +12 -12
- data/spec/zenlish/wclasses/regular_verb_want_spec.rb +7 -7
- data/spec/zenlish/wclasses/verb_spec.rb +9 -9
- data/spec/zenlish_spec.rb +1 -1
- data/zenlish.gemspec +6 -5
- metadata +32 -16
@@ -6,100 +6,100 @@ require_relative '../../../lib/zenlish/trie/trie' # Load the class under test
|
|
6
6
|
module Zenlish
|
7
7
|
module Trie
|
8
8
|
describe Trie do
|
9
|
-
subject {
|
9
|
+
subject(:trie) { 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
|
|
16
|
-
it '
|
17
|
-
expect(
|
16
|
+
it 'is a leaf node at start' do
|
17
|
+
expect(trie.root).to be_a(TrieRoot)
|
18
18
|
end
|
19
19
|
end # context
|
20
20
|
|
21
21
|
context 'Provided services:' do
|
22
|
-
it '
|
23
|
-
expect {
|
24
|
-
expect(
|
25
|
-
expect(
|
26
|
-
expect(
|
22
|
+
it 'accepts the addition of one single node' do
|
23
|
+
expect { trie.add('a', 'OK') }.not_to raise_error
|
24
|
+
expect(trie.root).to include('a')
|
25
|
+
expect(trie.root.succ['a']).to be_a(TrieNode)
|
26
|
+
expect(trie.root.succ['a'].value).to eq('OK')
|
27
27
|
end
|
28
28
|
|
29
|
-
it '
|
30
|
-
expect {
|
31
|
-
expect(
|
32
|
-
expect(
|
29
|
+
it 'accepts the addition of a node string' do
|
30
|
+
expect { trie.add('abc', 'OK') }.not_to raise_error
|
31
|
+
expect(trie.root).to include('a')
|
32
|
+
expect(trie.root).not_to include('b')
|
33
33
|
|
34
|
-
node_a =
|
35
|
-
expect(node_a).to
|
34
|
+
node_a = trie.root.succ['a']
|
35
|
+
expect(node_a).to be_a(TrieNode)
|
36
36
|
expect(node_a.value).to be_nil
|
37
|
-
expect(node_a.include
|
38
|
-
expect(node_a.include
|
37
|
+
expect(node_a).to include('b')
|
38
|
+
expect(node_a).not_to include('c')
|
39
39
|
|
40
40
|
node_b = node_a.succ['b']
|
41
|
-
expect(node_b).to
|
41
|
+
expect(node_b).to be_a(TrieNode)
|
42
42
|
expect(node_b.value).to be_nil
|
43
|
-
expect(node_b.include
|
43
|
+
expect(node_b).to include('c')
|
44
44
|
|
45
45
|
node_c = node_b.succ['c']
|
46
|
-
expect(node_c).to
|
46
|
+
expect(node_c).to be_a(TrieNode)
|
47
47
|
expect(node_c.value).to eq('OK')
|
48
48
|
expect(node_c).to be_leaf
|
49
49
|
end
|
50
50
|
|
51
|
-
it '
|
52
|
-
|
53
|
-
expect {
|
54
|
-
root =
|
55
|
-
expect(root.include
|
56
|
-
expect(root.include
|
51
|
+
it 'accepts the addition of multiple node strings' do
|
52
|
+
trie.add('abc', 'ABC')
|
53
|
+
expect { trie.add('abe', 'ABE') }.not_to raise_error
|
54
|
+
root = trie.root
|
55
|
+
expect(root).to include('a')
|
56
|
+
expect(root).not_to include('b')
|
57
57
|
|
58
58
|
node_a = root.succ['a']
|
59
59
|
|
60
60
|
node_b = node_a.succ['b']
|
61
|
-
expect(node_b).to
|
61
|
+
expect(node_b).to be_a(TrieNode)
|
62
62
|
expect(node_b.value).to be_nil
|
63
|
-
expect(node_b.include
|
64
|
-
expect(node_b.include
|
63
|
+
expect(node_b).to include('c')
|
64
|
+
expect(node_b).to include('e')
|
65
65
|
|
66
66
|
node_c = node_b.succ['c']
|
67
|
-
expect(node_c).to
|
67
|
+
expect(node_c).to be_a(TrieNode)
|
68
68
|
expect(node_c.value).to eq('ABC')
|
69
69
|
expect(node_c).to be_leaf
|
70
70
|
|
71
71
|
node_e = node_b.succ['e']
|
72
|
-
expect(node_e).to
|
72
|
+
expect(node_e).to be_a(TrieNode)
|
73
73
|
expect(node_e.value).to eq('ABE')
|
74
74
|
expect(node_e).to be_leaf
|
75
75
|
end
|
76
76
|
|
77
|
-
it '
|
78
|
-
|
79
|
-
|
80
|
-
|
77
|
+
it 'retrieves the node matching a given string' do
|
78
|
+
trie.add('abc', 'ABC')
|
79
|
+
trie.add('hello', 'WORLD')
|
80
|
+
trie.add('hellene', 'GREEK')
|
81
81
|
|
82
|
-
hello_node =
|
82
|
+
hello_node = trie.search('hello')
|
83
83
|
expect(hello_node.key).to eq('o')
|
84
84
|
expect(hello_node.value).to eq('WORLD')
|
85
|
-
hellish =
|
85
|
+
hellish = trie.search('hell')
|
86
86
|
expect(hellish.key).to eq('l')
|
87
87
|
expect(hellish.value).to be_nil
|
88
|
-
expect(
|
89
|
-
hellene_node =
|
88
|
+
expect(trie.search('greeting')).to be_nil
|
89
|
+
hellene_node = trie.search('hellene')
|
90
90
|
expect(hellene_node.key).to eq('e')
|
91
91
|
expect(hellene_node.value).to eq('GREEK')
|
92
|
-
expect(
|
92
|
+
expect(trie.search('hellenes')).to be_nil
|
93
93
|
end
|
94
94
|
|
95
|
-
it '
|
96
|
-
|
97
|
-
|
95
|
+
it 'accepts the addition of "synonyms"' do
|
96
|
+
trie.add('abd', 'first')
|
97
|
+
trie.add('abduce', 'ABDUCE')
|
98
98
|
|
99
|
-
abd_node =
|
99
|
+
abd_node = trie.search('abd')
|
100
100
|
expect(abd_node.value).to eq('first')
|
101
101
|
|
102
|
-
|
102
|
+
trie.add('abd', 'second')
|
103
103
|
expect(abd_node.value).to eq(%w[first second])
|
104
104
|
end
|
105
105
|
end # context
|
@@ -7,24 +7,24 @@ require_relative '../../../lib/zenlish/wclasses/common_noun' # Load the class un
|
|
7
7
|
module Zenlish
|
8
8
|
module WClasses
|
9
9
|
describe CommonNoun do
|
10
|
-
subject {
|
10
|
+
subject(:noun) { described_class.new }
|
11
11
|
|
12
12
|
context 'Initialization:' do
|
13
|
-
it '
|
14
|
-
expect {
|
13
|
+
it 'is initialized without argument' do
|
14
|
+
expect { described_class.new }.not_to raise_error
|
15
15
|
end
|
16
16
|
end # context
|
17
17
|
|
18
18
|
context 'Provided services:' do
|
19
|
-
it '
|
20
|
-
expect(
|
19
|
+
it 'provides a default inflection paradigm' do
|
20
|
+
expect(noun.paradigm).not_to be_nil
|
21
21
|
end
|
22
22
|
|
23
|
-
it '
|
23
|
+
it 'supports the pluralization of common nouns' do
|
24
24
|
samples = %w[animal body people]
|
25
25
|
lexemes = []
|
26
26
|
Lang::Dictionary.entries.each do |ent|
|
27
|
-
lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(
|
27
|
+
lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(described_class) }
|
28
28
|
if lexm && samples.include?(ent.lemma)
|
29
29
|
lexemes.concat(lexm)
|
30
30
|
end
|
@@ -38,11 +38,11 @@ module Zenlish
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
-
it '
|
41
|
+
it 'knows all its inflections' do
|
42
42
|
samples = %w[animal body people]
|
43
43
|
lexemes = []
|
44
44
|
Lang::Dictionary.entries.each do |ent|
|
45
|
-
lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(
|
45
|
+
lexm = ent.lexemes.select { |lx| lx.wclass.kind_of?(described_class) }
|
46
46
|
if lexm && samples.include?(ent.lemma)
|
47
47
|
lexemes.concat(lexm)
|
48
48
|
end
|
@@ -8,18 +8,18 @@ require_relative '../../../lib/zenlish/wclasses/demonstrative_determiner' # Load
|
|
8
8
|
module Zenlish
|
9
9
|
module WClasses
|
10
10
|
describe DemonstrativeDeterminer do
|
11
|
-
subject {
|
11
|
+
subject(:determiner) { described_class.new }
|
12
12
|
|
13
13
|
context 'Initialization:' do
|
14
|
-
it '
|
15
|
-
expect {
|
14
|
+
it 'is initialized without argument' do
|
15
|
+
expect { described_class.new }.not_to raise_error
|
16
16
|
end
|
17
17
|
end # context
|
18
18
|
|
19
19
|
context 'Provided services:' do
|
20
20
|
def build_det(aBaseForm)
|
21
21
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
22
|
-
Zenlish::Lex::Lexeme.new(
|
22
|
+
Zenlish::Lex::Lexeme.new(determiner, entry)
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_all_inflections(det_form, wforms)
|
@@ -28,17 +28,17 @@ module Zenlish
|
|
28
28
|
expect(inflected.sort).to eq(wforms.sort)
|
29
29
|
end
|
30
30
|
|
31
|
-
it '
|
32
|
-
expect(
|
31
|
+
it 'knows that it is inflectable' do
|
32
|
+
expect(determiner).not_to be_invariable
|
33
33
|
end
|
34
34
|
|
35
|
-
it '
|
36
|
-
expect(
|
37
|
-
expect(
|
38
|
-
expect(
|
35
|
+
it 'knows its feature definitions' do
|
36
|
+
expect(determiner['NUMBER']).to be_a(Feature::FeatureDef)
|
37
|
+
expect(determiner['DISTANCE']).to be_a(Feature::FeatureDef)
|
38
|
+
expect(determiner['PARADIGM'].default.val).to eq('Demonstrative_det_paradigm')
|
39
39
|
end
|
40
40
|
|
41
|
-
it '
|
41
|
+
it 'gives all word forms' do
|
42
42
|
test_all_inflections('this', %w[this that these those])
|
43
43
|
end
|
44
44
|
end # context
|
@@ -10,24 +10,24 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb_can'
|
|
10
10
|
module Zenlish
|
11
11
|
module WClasses
|
12
12
|
describe IrregularVerbCan do
|
13
|
-
subject {
|
13
|
+
subject(:irreg_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(irreg_can['NUMBER']).to be_a(Feature::FeatureDef)
|
24
|
+
expect(irreg_can['PERSON']).to be_a(Feature::FeatureDef)
|
25
|
+
expect(irreg_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
|
-
Zenlish::Lex::Lexeme.new(
|
30
|
+
Zenlish::Lex::Lexeme.new(irreg_can, entry)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_inflection_of(verb_form, pairs)
|
@@ -43,7 +43,7 @@ module Zenlish
|
|
43
43
|
expect(inflected.sort).to eq(wforms.sort)
|
44
44
|
end
|
45
45
|
|
46
|
-
it '
|
46
|
+
it 'knows how to inflect modal verb can' do
|
47
47
|
expectations1 = [
|
48
48
|
[:present, 'can'],
|
49
49
|
[:past_simple, 'could']
|
@@ -51,7 +51,7 @@ module Zenlish
|
|
51
51
|
test_inflection_of('can', expectations1)
|
52
52
|
end
|
53
53
|
|
54
|
-
it '
|
54
|
+
it 'gives all word forms of a given verb' do
|
55
55
|
test_all_inflections('can', %w[can could])
|
56
56
|
end
|
57
57
|
end # context
|
@@ -8,28 +8,28 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb_extension'
|
|
8
8
|
module Zenlish
|
9
9
|
module WClasses
|
10
10
|
describe IrregularVerbExtension do
|
11
|
-
subject do
|
11
|
+
subject(:verb) do
|
12
12
|
obj = Object.new
|
13
|
-
obj.extend(
|
13
|
+
obj.extend(described_class)
|
14
14
|
obj.init_extension(obj)
|
15
15
|
obj
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'Initialization:' do
|
19
|
-
it '
|
20
|
-
expect { Object.new.extend(
|
19
|
+
it 'allows mix-in with a host object' do
|
20
|
+
expect { Object.new.extend(described_class) }.not_to raise_error
|
21
21
|
end
|
22
22
|
|
23
|
-
it '
|
24
|
-
expect(
|
23
|
+
it 'injects an instance variable' do
|
24
|
+
expect(verb.instance_variable_get(:@forms)).to be_a(Array)
|
25
25
|
end
|
26
26
|
end # context
|
27
27
|
|
28
28
|
context 'Provided services:' do
|
29
|
-
it '
|
30
|
-
|
31
|
-
expect(
|
32
|
-
expect(
|
29
|
+
it 'provides a write accessor' do
|
30
|
+
verb.forms past_simple: 'chose', past_participle: 'chosen'
|
31
|
+
expect(verb.past_simple).to eq('chose')
|
32
|
+
expect(verb.past_participle).to eq('chosen')
|
33
33
|
end
|
34
34
|
end # context
|
35
35
|
end # describe
|
@@ -10,31 +10,18 @@ require_relative '../../../lib/zenlish/wclasses/irregular_verb'
|
|
10
10
|
module Zenlish
|
11
11
|
module WClasses
|
12
12
|
describe IrregularVerb do
|
13
|
-
subject {
|
13
|
+
subject(: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('Irregular_inflection')
|
26
|
-
end
|
27
|
-
|
28
|
-
let(:present_1sg) { [:first, :singular, :present, nil] }
|
29
|
-
let(:present_3sg) { [:third, :singular, :present, nil] }
|
30
|
-
let(:present_1pl) { [:first, :plural, :present, nil] }
|
31
|
-
let(:progressive) { [nil, nil, :progressive, nil] }
|
32
|
-
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
33
|
-
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
34
|
-
|
35
22
|
def build_verb(aBaseForm, p_simple, p_participle)
|
36
23
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
37
|
-
lexeme = Zenlish::Lex::Lexeme.new(
|
24
|
+
lexeme = Zenlish::Lex::Lexeme.new(verb, entry)
|
38
25
|
lexeme.forms past_simple: p_simple, past_participle: p_participle
|
39
26
|
lexeme
|
40
27
|
end
|
@@ -52,7 +39,20 @@ module Zenlish
|
|
52
39
|
expect(inflected.sort).to eq(wforms.sort)
|
53
40
|
end
|
54
41
|
|
55
|
-
|
42
|
+
let(:present_1sg) { [:first, :singular, :present, nil] }
|
43
|
+
let(:present_3sg) { [:third, :singular, :present, nil] }
|
44
|
+
let(:present_1pl) { [:first, :plural, :present, nil] }
|
45
|
+
let(:progressive) { [nil, nil, :progressive, nil] }
|
46
|
+
let(:past_simple) { [nil, nil, :past_simple, nil] }
|
47
|
+
let(:past_participle) { [nil, nil, :past_participle, nil] }
|
48
|
+
|
49
|
+
it 'knows its inherited feature definitions' do
|
50
|
+
expect(verb['NUMBER']).to be_a(Feature::FeatureDef)
|
51
|
+
expect(verb['PERSON']).to be_a(Feature::FeatureDef)
|
52
|
+
expect(verb['PARADIGM'].default.val).to eq('Irregular_inflection')
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'knows how to inflect irregular verbs' do
|
56
56
|
expectations1 = [
|
57
57
|
[present_1sg, 'see'],
|
58
58
|
[present_3sg, 'sees'],
|
@@ -74,7 +74,7 @@ module Zenlish
|
|
74
74
|
test_inflection_of('make', 'made', 'made', expectations2)
|
75
75
|
end
|
76
76
|
|
77
|
-
it '
|
77
|
+
it 'gives all word forms of a given verb' do
|
78
78
|
test_all_inflections('see', 'saw', 'seen', %w[see sees seeing saw seen])
|
79
79
|
end
|
80
80
|
end # context
|
@@ -15,19 +15,19 @@ module Zenlish
|
|
15
15
|
end
|
16
16
|
|
17
17
|
describe LexicalVerb do
|
18
|
-
subject {
|
18
|
+
subject(:verb) { described_class.new }
|
19
19
|
|
20
20
|
context 'Initialization:' do
|
21
|
-
it '
|
22
|
-
expect {
|
21
|
+
it 'is initialized without argument' do
|
22
|
+
expect { described_class.new }.not_to raise_error
|
23
23
|
end
|
24
24
|
end # context
|
25
25
|
|
26
26
|
context 'Provided services:' do
|
27
|
-
it '
|
28
|
-
expect(
|
29
|
-
expect(
|
30
|
-
expect(
|
27
|
+
it 'knows its inherited feature definitions' do
|
28
|
+
expect(verb['NUMBER']).to be_a(Feature::FeatureDef)
|
29
|
+
expect(verb['PERSON']).to be_a(Feature::FeatureDef)
|
30
|
+
expect(verb['PARADIGM'].default.val).to eq('Regular_inflection')
|
31
31
|
end
|
32
32
|
end # context
|
33
33
|
end # describe
|
@@ -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
|
-
Zenlish::Lex::Lexeme.new(
|
30
|
+
Zenlish::Lex::Lexeme.new(modal_can, entry)
|
31
31
|
end
|
32
32
|
|
33
33
|
def test_inflection_of(verb_form, pairs)
|
@@ -37,7 +37,7 @@ module Zenlish
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
it '
|
40
|
+
it 'knows how to inflect modal verb can' do
|
41
41
|
expectations1 = [
|
42
42
|
[:present, 'can'],
|
43
43
|
[:past_simple, 'could']
|
@@ -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
|
-
Zenlish::Lex::Lexeme.new(
|
28
|
+
Zenlish::Lex::Lexeme.new(pronoun, entry, aFeatureHash)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_all_inflections(det_form, aFeatureHash, wforms)
|
@@ -34,28 +34,28 @@ 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
47
|
'GENDER' => enumeration(:feminine, :masculine) }
|
48
48
|
test_all_inflections('I', feature_defs, %w[I we me us])
|
49
49
|
end
|
50
50
|
|
51
|
-
it '
|
51
|
+
it 'gives all word forms for the second person' do
|
52
52
|
feature_defs = { 'PERSON' => enumeration(:second),
|
53
53
|
'GENDER' => enumeration(:feminine, :masculine),
|
54
54
|
'PARADIGM' => [identifier, 'ppn_2nd_paradigm'] }
|
55
55
|
test_all_inflections('you', feature_defs, ['you'])
|
56
56
|
end
|
57
57
|
|
58
|
-
it '
|
58
|
+
it 'gives all word forms for the third person' do
|
59
59
|
feature_defs = { 'PERSON' => enumeration(:third),
|
60
60
|
'PARADIGM' => [identifier, 'ppn_3rd_paradigm'] }
|
61
61
|
test_all_inflections('it', feature_defs, %w[she he it they her him them])
|
@@ -10,18 +10,18 @@ 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
21
|
context 'Provided services:' do
|
22
22
|
def build_det(aBaseForm, aFeatureHash)
|
23
23
|
entry = Zenlish::Lex::LexicalEntry.new(aBaseForm)
|
24
|
-
Zenlish::Lex::Lexeme.new(
|
24
|
+
Zenlish::Lex::Lexeme.new(determiner, entry, aFeatureHash)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_all_inflections(det_form, aFeatureHash, wforms)
|
@@ -30,37 +30,37 @@ module Zenlish
|
|
30
30
|
expect(inflected.sort).to eq(wforms.sort)
|
31
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
43
|
|
44
|
-
it '
|
44
|
+
it 'gives all word forms for the first person' do
|
45
45
|
feature_defs = { 'PERSON' => enumeration(:first),
|
46
46
|
'GENDER' => enumeration(:feminine, :masculine) }
|
47
47
|
test_all_inflections('my', feature_defs, %w[my our])
|
48
48
|
end
|
49
49
|
|
50
|
-
it '
|
50
|
+
it 'gives all word forms for the second person' do
|
51
51
|
feature_defs = { 'PERSON' => enumeration(:second),
|
52
52
|
'GENDER' => enumeration(:feminine, :masculine),
|
53
53
|
'PARADIGM' => [identifier, 'possdet_2nd_paradigm'] }
|
54
54
|
test_all_inflections('your', feature_defs, ['your'])
|
55
55
|
end
|
56
56
|
|
57
|
-
it '
|
57
|
+
it 'gives all word forms for the third person' do
|
58
58
|
feature_defs = { 'PERSON' => enumeration(:third),
|
59
59
|
'PARADIGM' => [identifier, 'possdet_3rd_paradigm'] }
|
60
60
|
test_all_inflections('its', feature_defs, %w[its her his their])
|
61
61
|
end
|
62
62
|
|
63
|
-
# it '
|
63
|
+
# it 'gives all word forms' do
|
64
64
|
# test_all_inflections('this', ['this', 'that', 'these', 'those'])
|
65
65
|
# end
|
66
66
|
end # context
|