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
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
require_relative '../../../lib/zenlish/lang/dictionary'
|
5
|
+
|
6
|
+
# Load the class under test
|
7
|
+
require_relative '../../../lib/zenlish/lang/lemmatizer'
|
8
|
+
|
9
|
+
module Zenlish
|
10
|
+
module Lang
|
11
|
+
describe Lemmatizer do
|
12
|
+
subject { Lemmatizer.new(Dictionary) }
|
13
|
+
|
14
|
+
context 'Initialization:' do
|
15
|
+
it 'should be initialized with a lexicon argument' do
|
16
|
+
expect { Lemmatizer.new(Dictionary) }.not_to raise_error
|
17
|
+
end
|
18
|
+
end # context
|
19
|
+
|
20
|
+
context 'Provided services:' do
|
21
|
+
it 'should retrieve an unambiguous word form' do
|
22
|
+
# Coordinator
|
23
|
+
found = subject.lemmatize('and')
|
24
|
+
expect(found).to be_kind_of(Lex::Lexeme)
|
25
|
+
expect(found.lemma).to eq('and')
|
26
|
+
expect(found.wclass).to be_kind_of(WClasses::Coordinator)
|
27
|
+
|
28
|
+
# Common noun
|
29
|
+
found = subject.lemmatize('surfaces')
|
30
|
+
expect(found).to be_kind_of(Lex::Lexeme)
|
31
|
+
expect(found.lemma).to eq('surface')
|
32
|
+
expect(found.wclass).to be_kind_of(WClasses::CommonNoun)
|
33
|
+
|
34
|
+
# Verb
|
35
|
+
found = subject.lemmatize('seeing')
|
36
|
+
expect(found).to be_kind_of(Lex::Lexeme)
|
37
|
+
expect(found.lemma).to eq('see')
|
38
|
+
expect(found.wclass).to be_kind_of(WClasses::IrregularVerb)
|
39
|
+
end
|
40
|
+
end # context
|
41
|
+
end # describe
|
42
|
+
end # module
|
43
|
+
end # module
|
@@ -4,7 +4,7 @@ require_relative '../../spec_helper' # Use the RSpec framework
|
|
4
4
|
require_relative '../../../lib/zenlish/lang/zenlish_grammar' # Load the class under test
|
5
5
|
|
6
6
|
module Zenlish
|
7
|
-
module
|
7
|
+
module Lang
|
8
8
|
describe ZenlishGrammar do
|
9
9
|
subject { ZenlishGrammar }
|
10
10
|
|
@@ -18,4 +18,4 @@ module Zenlish
|
|
18
18
|
end # context
|
19
19
|
end # describe
|
20
20
|
end # module
|
21
|
-
end # module
|
21
|
+
end # module
|
@@ -10,24 +10,25 @@ module Zenlish
|
|
10
10
|
module Lex
|
11
11
|
describe Lexeme do
|
12
12
|
include Feature::FeatureStructDefBearer
|
13
|
-
|
13
|
+
|
14
14
|
let(:a_wclass) { WClasses::CommonNoun.new }
|
15
15
|
let(:a_lemma) { 'people' }
|
16
16
|
let(:an_entry) { LexicalEntry.new(a_lemma) }
|
17
|
-
let(:a_feat_struct_def)
|
18
|
-
{ 'NUMBER' => enumeration(:plural)
|
19
|
-
|
17
|
+
let(:a_feat_struct_def) do
|
18
|
+
{ 'NUMBER' => enumeration(:plural),
|
19
|
+
'PARADIGM' => [identifier, 'Plural_only'] }
|
20
|
+
end
|
20
21
|
|
21
|
-
subject { Lexeme.new(a_wclass, an_entry)
|
22
|
+
subject { Lexeme.new(a_wclass, an_entry) }
|
22
23
|
|
23
24
|
context 'Initialization:' do
|
24
25
|
it 'could be initialized with a word class and a lexical entry' do
|
25
26
|
expect { Lexeme.new(a_wclass, an_entry) }.not_to raise_error
|
26
27
|
end
|
27
|
-
|
28
|
+
|
28
29
|
it 'could be initialized with a w. class, lexical ent., feature hash' do
|
29
30
|
expect { Lexeme.new(a_wclass, an_entry, a_feat_struct_def) }.not_to raise_error
|
30
|
-
end
|
31
|
+
end
|
31
32
|
|
32
33
|
it 'should know its word class' do
|
33
34
|
expect(subject.wclass).to eq(a_wclass)
|
@@ -39,20 +40,24 @@ module Zenlish
|
|
39
40
|
end # context
|
40
41
|
|
41
42
|
context 'Provided services:' do
|
43
|
+
subject { Lexeme.new(a_wclass, an_entry, a_feat_struct_def) }
|
42
44
|
it 'should know its lemma' do
|
43
45
|
expect(subject.lemma).to eq(a_lemma)
|
44
46
|
end
|
45
|
-
|
47
|
+
|
46
48
|
it 'should know its own feature defs' do
|
47
|
-
instance =
|
49
|
+
instance = Lexeme.new(a_wclass, an_entry, a_feat_struct_def)
|
48
50
|
expect(instance['NUMBER'].default.val).to eq(:plural)
|
49
51
|
end
|
50
|
-
|
52
|
+
|
51
53
|
it 'should know its inflection paradigm' do
|
52
54
|
expect(subject.paradigm).to be_kind_of(Inflect::InflectionTable)
|
53
55
|
end
|
56
|
+
|
57
|
+
it 'should know all its inflections' do
|
58
|
+
expect(subject.all_inflections).to eq(['people'])
|
59
|
+
end
|
54
60
|
end # context
|
55
61
|
end # describe
|
56
62
|
end # module
|
57
63
|
end # module
|
58
|
-
|
@@ -32,7 +32,6 @@ module Zenlish
|
|
32
32
|
end # context
|
33
33
|
|
34
34
|
context 'Provided services:' do
|
35
|
-
|
36
35
|
it 'should accept links with lexeme(s)' do
|
37
36
|
subject.add_lexeme(sample_lexeme1)
|
38
37
|
expect(subject.lexemes).to eq([sample_lexeme1])
|
@@ -43,4 +42,4 @@ module Zenlish
|
|
43
42
|
end # context
|
44
43
|
end # describe
|
45
44
|
end # module
|
46
|
-
end # module
|
45
|
+
end # module
|
@@ -12,7 +12,8 @@ module Zenlish
|
|
12
12
|
describe Lexicon do
|
13
13
|
def create_entry(aLemma, aWordClass)
|
14
14
|
entry = Zenlish::Lex::LexicalEntry.new(aLemma)
|
15
|
-
lexeme =
|
15
|
+
# lexeme =
|
16
|
+
Zenlish::Lex::Lexeme.new(aWordClass, entry)
|
16
17
|
entry
|
17
18
|
end
|
18
19
|
|
@@ -72,24 +73,24 @@ module Zenlish
|
|
72
73
|
expect(subject.entries).to eq([sample_entry, distinct_entry, similar_entry])
|
73
74
|
expect(subject.lemma2entry['other']).to eq([sample_entry, similar_entry])
|
74
75
|
end
|
75
|
-
|
76
|
+
|
76
77
|
it 'should retrieve the lexeme of an entry with unique lemma' do
|
77
78
|
subject.add_entry(sample_entry)
|
78
|
-
subject.add_entry(distinct_entry)
|
79
|
+
subject.add_entry(distinct_entry)
|
79
80
|
subject.add_entry(similar_entry)
|
80
|
-
|
81
|
+
|
81
82
|
lexeme = subject.get_lexeme('hope')
|
82
83
|
expect(lexeme.wclass).to be_kind_of(Zenlish::WClasses::IrregularVerb)
|
83
84
|
end
|
84
|
-
|
85
|
+
|
85
86
|
it 'should retrieve the lexeme of an entry with duplicate lemma' do
|
86
87
|
subject.add_entry(sample_entry)
|
87
|
-
subject.add_entry(distinct_entry)
|
88
|
+
subject.add_entry(distinct_entry)
|
88
89
|
subject.add_entry(similar_entry)
|
89
|
-
|
90
|
+
|
90
91
|
lexeme = subject.get_lexeme('other', Zenlish::WClasses::Pronoun)
|
91
92
|
expect(lexeme).to be_kind_of(Zenlish::Lex::Lexeme)
|
92
|
-
end
|
93
|
+
end
|
93
94
|
|
94
95
|
it 'should complain when retrieving an non-existing entry' do
|
95
96
|
subject.add_entry(sample_entry)
|
@@ -8,12 +8,12 @@ require_relative '../../../lib/zenlish/lex/literal' # Load the class under test
|
|
8
8
|
|
9
9
|
module Zenlish
|
10
10
|
module Lex
|
11
|
-
describe
|
11
|
+
describe Literal do
|
12
12
|
let(:sample_wclass) { WClasses::CommonNoun.new }
|
13
13
|
let(:sample_lemma) { 'thing' }
|
14
14
|
let(:sample_entry) { LexicalEntry.new(sample_lemma) }
|
15
15
|
let(:sample_position) { double('position') }
|
16
|
-
let(:sample_lexeme) { Lexeme.new(sample_wclass, sample_entry)
|
16
|
+
let(:sample_lexeme) { Lexeme.new(sample_wclass, sample_entry) }
|
17
17
|
|
18
18
|
subject { Literal.new('things', sample_lexeme, sample_position) }
|
19
19
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative '../../spec_helper' # Use the RSpec framework
|
4
|
+
require_relative '../../../lib/zenlish/wclasses/all_word_classes'
|
5
|
+
require_relative '../../../lib/zenlish/lex/lexical_entry'
|
6
|
+
require_relative '../../../lib/zenlish/lex/lexeme'
|
7
|
+
|
8
|
+
# Load the class under test
|
9
|
+
require_relative '../../../lib/zenlish/lexer/lexer'
|
10
|
+
|
11
|
+
module Zenlish
|
12
|
+
module Lexer
|
13
|
+
describe Lexer do
|
14
|
+
# let(:sample_wclass) { WClasses::CommonNoun.new }
|
15
|
+
# let(:sample_lemma) { 'thing' }
|
16
|
+
# let(:sample_entry) { LexicalEntry.new(sample_lemma) }
|
17
|
+
# let(:sample_position) { double('position') }
|
18
|
+
# let(:sample_lexeme) { Lexeme.new(sample_wclass, sample_entry) }
|
19
|
+
let(:sample_sentence) { 'Tony sees Lisa.' }
|
20
|
+
|
21
|
+
subject { Lexer.new(sample_sentence) }
|
22
|
+
|
23
|
+
context 'Initialization:' do
|
24
|
+
it 'should be initialized with Zenlish text' do
|
25
|
+
expect { Lexer.new(sample_sentence) }.not_to raise_error
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should its scanner object' do
|
29
|
+
expect(subject.scanner).not_to be_nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should have an initial position' do
|
33
|
+
expect(subject.lineno).to eq(1)
|
34
|
+
expect(subject.line_start).to eq(0)
|
35
|
+
end
|
36
|
+
end # context
|
37
|
+
|
38
|
+
context 'Provided services:' do
|
39
|
+
it 'should return a sequence of literals' do
|
40
|
+
tokens = subject.tokens
|
41
|
+
expect(tokens.size).to eq(4)
|
42
|
+
expect(tokens[0].lexeme).to eq('Tony')
|
43
|
+
expect(tokens[0].terminal).to eq('WORD')
|
44
|
+
expect(tokens[1].lexeme).to eq('sees')
|
45
|
+
expect(tokens[2].lexeme).to eq('Lisa')
|
46
|
+
expect(tokens[3].lexeme).to eq('.')
|
47
|
+
expect(tokens[3].terminal).to eq('Period')
|
48
|
+
end
|
49
|
+
end # context
|
50
|
+
end # describe
|
51
|
+
end # module
|
52
|
+
end # module
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative '../../spec_helper' # Use the RSpec framework
|
3
4
|
require_relative '../support/var2word'
|
4
5
|
require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test
|
@@ -14,7 +15,6 @@ module Zenlish
|
|
14
15
|
it 'should parse sample sentences from lesson 1-A' do
|
15
16
|
# Sentence 1-01: "Tony sees Lisa."
|
16
17
|
# in absence of a tokenizer, we create a sequence of literals by hand...
|
17
|
-
# prox_tony = ZProxy.new(tony)
|
18
18
|
literals = [tony, sees, lisa, dot]
|
19
19
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
20
20
|
|
@@ -126,7 +126,7 @@ module Zenlish
|
|
126
126
|
# Sentence 1-15c: "There are more people inside the other thing
|
127
127
|
# than there are inside this thing."
|
128
128
|
literals = [there, are, more, people, inside, the, other, thing,
|
129
|
-
|
129
|
+
than, there, are, inside, this, thing, dot]
|
130
130
|
# Ambiguous parse
|
131
131
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
132
132
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require_relative '../../spec_helper' # Use the RSpec framework
|
3
4
|
require_relative '../support/var2word'
|
4
5
|
require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test
|
@@ -180,10 +181,9 @@ module Zenlish
|
|
180
181
|
# Sentence 2-Dx: "Lisa thinks about something bad happening to this
|
181
182
|
# living thing. Thinking about this feels bad for Lisa."
|
182
183
|
literals = [lisa, thinks, about, something, bad, happening, to, this,
|
183
|
-
living, thing, dot
|
184
|
-
#thinking, about, this_as_pronoun, feels, bad,
|
185
|
-
#for_, lisa, dot
|
186
|
-
]
|
184
|
+
living, thing, dot]
|
185
|
+
# thinking, about, this_as_pronoun, feels, bad,
|
186
|
+
# for_, lisa, dot]
|
187
187
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
188
188
|
end
|
189
189
|
|
@@ -255,7 +255,7 @@ module Zenlish
|
|
255
255
|
|
256
256
|
# Sentence 2-19a definiens: 'Tony says something about Tony. Tony says: Tony did X.'
|
257
257
|
literals = [tony, says, something, about, tony, dot,
|
258
|
-
|
258
|
+
tony, says, colon, tony, did, x_as_noun, dot]
|
259
259
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
260
260
|
|
261
261
|
# Sentence 2-19a: 'Tony says: "I see Lisa.".'
|
@@ -268,7 +268,7 @@ module Zenlish
|
|
268
268
|
|
269
269
|
# Sentence 2-19b definiens: 'Lisa says something about Lisa. Lisa says: X happened to Lisa.'
|
270
270
|
literals = [lisa, says, something, about, lisa, dot,
|
271
|
-
|
271
|
+
lisa, says, colon, x_as_noun, happened, to, lisa, dot]
|
272
272
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
273
273
|
|
274
274
|
# Sentence 2-19c: 'Lisa says: "Tony sees me."'
|
@@ -282,8 +282,8 @@ module Zenlish
|
|
282
282
|
# Sentence 2-20a definiens: 'Tony says something about Lisa.
|
283
283
|
# Tony says this to Lisa. Tony says: Tony can see Lisa.'
|
284
284
|
literals = [tony, says, something, about, lisa, dot,
|
285
|
-
|
286
|
-
|
285
|
+
tony, says, this_as_pronoun, to, lisa, dot,
|
286
|
+
tony, says, colon, tony, can, see, lisa, dot]
|
287
287
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
288
288
|
|
289
289
|
# Sentence 2-20b: "I know you have something good."
|
@@ -300,7 +300,7 @@ module Zenlish
|
|
300
300
|
|
301
301
|
# Sentence 2-21a definiens: "Tony is in a place. Tony says: X happens in this place."
|
302
302
|
literals = [tony, is, in_, a_as_art, place, dot,
|
303
|
-
|
303
|
+
tony, says, colon, x_as_noun, happens, in_, this, place, dot]
|
304
304
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
305
305
|
|
306
306
|
# Sentence 2-21b: "Many people were here at one time."
|
@@ -314,16 +314,16 @@ module Zenlish
|
|
314
314
|
# Sentence 2-22a definiens: 'Lisa says something at a time.
|
315
315
|
# Lisa says: X happens at this same time.'
|
316
316
|
literals = [lisa, says, something, at, a_as_art, time, dot,
|
317
|
-
|
317
|
+
lisa, says, colon, x_as_noun, happens, at, this, time, dot]
|
318
318
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
319
319
|
|
320
320
|
# Sentence 2-22b: "There are not many people here now."
|
321
|
-
literals = [there, are, not_, many, people, here, now
|
321
|
+
literals = [there, are, not_, many, people, here, now, dot]
|
322
322
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
323
323
|
|
324
324
|
# Sentence 2-Fa: "Lisa says to Tony: "I can see many living things here."."
|
325
325
|
literals = [lisa, says, to, tony, colon, quote, i_pronoun,
|
326
|
-
|
326
|
+
can, see, many, living, things, here, dot, quote, dot]
|
327
327
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
328
328
|
end
|
329
329
|
|
@@ -335,8 +335,8 @@ module Zenlish
|
|
335
335
|
# Sentence 2-23a definiens: 'Something does X. This something can
|
336
336
|
# think like people think. This something can be one person.'
|
337
337
|
literals = [something, does, x_as_noun, dot,
|
338
|
-
|
339
|
-
|
338
|
+
this, something, can, think, like, people, think, dot,
|
339
|
+
this, something, can, be_, a_as_art, person, dot]
|
340
340
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
341
341
|
|
342
342
|
# Sentence 2-23b: Someone said something to Tony.
|
@@ -406,7 +406,7 @@ module Zenlish
|
|
406
406
|
# Sentence 2-26b: In a moment, I knew something here was not good.
|
407
407
|
# 'here' is adverb that modifies the 'knew' verb
|
408
408
|
literals = [in_, a_as_art, moment, comma, i_pronoun, knew, something,
|
409
|
-
|
409
|
+
here, was, not_, good, dot]
|
410
410
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
411
411
|
|
412
412
|
# Sentence 2-Gx: Tony is inside this thing for some time.
|
@@ -415,7 +415,7 @@ module Zenlish
|
|
415
415
|
# Tony says this after Tony hears Lisa.
|
416
416
|
literals = [tony, is, inside, this, thing, for_, some, time, dot,
|
417
417
|
lisa, says, colon, quote, i_pronoun, want, to, know, who, is,
|
418
|
-
inside, this, thing, dot, quote, dot,
|
418
|
+
inside, this, thing, dot, quote, dot, tony, hears, lisa, dot,
|
419
419
|
because, of, this_as_pronoun, comma, tony, says, colon,
|
420
420
|
quote, i_pronoun, am, inside, dot, quote, dot,
|
421
421
|
tony, says, this_as_pronoun, after_, tony, hears, lisa, dot]
|
@@ -431,12 +431,11 @@ module Zenlish
|
|
431
431
|
# Parts of this person can touch other parts inside this person.
|
432
432
|
# X is all of these parts of this person."
|
433
433
|
# [One part of the body of this person felt very bad.]
|
434
|
-
literals = [
|
434
|
+
literals = [parts, of, this, person, can, touch, other, things, dot,
|
435
435
|
parts, of, this, person, can, touch, other, parts, inside,
|
436
|
-
|
436
|
+
this, person, dot,
|
437
437
|
x_as_noun, is, all, of, these, parts, of, this, person, dot,
|
438
|
-
one, part, of, the, body, of, this, person, felt, very, bad, dot
|
439
|
-
]
|
438
|
+
one, part, of, the, body, of, this, person, felt, very, bad, dot]
|
440
439
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
441
440
|
|
442
441
|
# Sentence 2-28a definiendum "X dies."
|
@@ -446,13 +445,12 @@ module Zenlish
|
|
446
445
|
# Sentence 2-28b definiens "Something happens to X in a moment.
|
447
446
|
# X is alive before this moment. X is not alive after this moment.
|
448
447
|
# [After this person lived for a long time, this person died."
|
449
|
-
literals = [
|
450
|
-
|
448
|
+
literals = [something, happens, to, x_as_noun, in_, a_as_art,
|
449
|
+
moment, dot,
|
451
450
|
x_as_noun, is, alive, before_adverb, this, moment, dot,
|
452
451
|
x_as_noun, is, not_, alive, after_adverb, this, moment, dot,
|
453
452
|
after_, this, person, lived, for_, a_as_art, long, time, comma,
|
454
|
-
|
455
|
-
]
|
453
|
+
this, person, died, dot]
|
456
454
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
457
455
|
|
458
456
|
# Sentence 2-29a definiendum "You think maybe X is true."
|
@@ -463,10 +461,9 @@ module Zenlish
|
|
463
461
|
# can be true. You do not know X is true.
|
464
462
|
# You do not know X is not true.
|
465
463
|
# [Maybe some people far from here can see me.]"
|
466
|
-
literals = [
|
464
|
+
literals = [you, do_aux, not_, know, x_as_noun, is, true_, dot,
|
467
465
|
you, do_aux, not_, know, x_as_noun, is, not_, true_, dot,
|
468
|
-
maybe, some, people, far_from, here_as_noun, can, see, me, dot
|
469
|
-
]
|
466
|
+
maybe, some, people, far_from, here_as_noun, can, see, me, dot]
|
470
467
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
471
468
|
|
472
469
|
# Sentence 2-30a definiendum "J is below K."
|
@@ -475,17 +472,15 @@ module Zenlish
|
|
475
472
|
|
476
473
|
# Sentence 2-30b definiens "K is above J.
|
477
474
|
# [I am touching this thing below me.]
|
478
|
-
literals = [
|
479
|
-
i_pronoun, am, touching, this, thing, below, me, dot
|
480
|
-
]
|
475
|
+
literals = [j_, is, below, k_, dot,
|
476
|
+
i_pronoun, am, touching, this, thing, below, me, dot]
|
481
477
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
482
478
|
|
483
479
|
# Sentence 2-H extra "Someone sees this thing.
|
484
480
|
# The body of this thing is not moving.
|
485
481
|
# Maybe this thing is dead."
|
486
|
-
literals = [
|
487
|
-
the, body, of, this, thing, is_aux, not_, moving, dot
|
488
|
-
]
|
482
|
+
literals = [someone, sees, thing, dot,
|
483
|
+
the, body, of, this, thing, is_aux, not_, moving, dot]
|
489
484
|
expect { subject.to_pforest(literals) }.not_to raise_error
|
490
485
|
end
|
491
486
|
=begin
|
@@ -493,9 +488,9 @@ TODO
|
|
493
488
|
|
494
489
|
Lesson 2.C
|
495
490
|
|
496
|
-
|
497
|
-
|
498
|
-
|
491
|
+
Xtra:
|
492
|
+
Tony knows Lisa has something, because Tony sees what Lisa has.
|
493
|
+
Tony thinks about what Lisa has, because Tony want to have the same kind of thing.
|
499
494
|
=end
|
500
495
|
end # context
|
501
496
|
end # describe
|