spec/zenlish/parser/zparser_spec.rb in zenlish-0.1.20 vs spec/zenlish/parser/zparser_spec.rb in zenlish-0.1.21
- old
+ new
@@ -57,20 +57,22 @@
literal2var('big', 'big')
literal2var('big', 'bigger')
literal2var('body', 'body')
literal2var('but', 'but')
literal2var('can', 'can')
+ literal2var('cause', 'cause')
literal2var('cause', 'caused')
literal2var('cause', 'causes')
def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
literal2var('die', 'die')
literal2var('die', 'died')
literal2var('die', 'dies')
def do_ ; Lex::Literal.new('do', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
def do_aux ; Lex::Literal.new('do', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
def does ; Lex::Literal.new('does', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end
def does_aux ; Lex::Literal.new('does', get_lexeme('do', WClasses::AuxiliaryDo), 0) ; end
+ literal2var('each', 'each', '_')
literal2var('false', 'false', '_')
literal2var('far', 'far')
literal2var('far from', 'far_from')
literal2var('feel', 'feel')
literal2var('feel', 'feels')
@@ -177,10 +179,12 @@
literal2var('touch', 'touched')
literal2var('touch', 'touching')
literal2var('true', 'true', '_')
def two ; Lex::Literal.new('two', get_lexeme('two', WClasses::Cardinal), 0) ; end
def two_as_pronoun ; Lex::Literal.new('two', get_lexeme('two', WClasses::IndefinitePronoun), 0) ; end
+ literal2var('use', 'use')
+ literal2var('use', 'used')
literal2var('very', 'very')
literal2var('want', 'want')
literal2var('want', 'wants')
def was ; Lex::Literal.new('was', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
def were ; Lex::Literal.new('were', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end
@@ -211,16 +215,16 @@
literal.send(name, *args, &aBlock)
end
end
context 'Producing parse tree or forest:' do
- it 'should produce trees (for non ambiguous input)' do
- # OK, non-ambiguous sentence: "Lisa sees Tony."
- literals = [lisa, sees, tony, dot]
- result_type = Rley::PTree::ParseTree
- expect(subject.to_ptree(literals)).to be_kind_of(result_type)
- end
+ # it 'should produce trees (for non ambiguous input)' do
+ # # OK, non-ambiguous sentence: "Lisa sees Tony."
+ # literals = [lisa, sees, tony, dot]
+ # result_type = Rley::PTree::ParseTree
+ # expect(subject.to_pforest(literals)).to be_kind_of(result_type)
+ # end
it 'should produce forest' do
# Sentence: "Lisa sees Tony."
literals = [lisa, sees, tony, dot]
result_type = Rley::SPPF::ParseForest
@@ -232,33 +236,33 @@
it 'should parse sample sentences from lesson 1-A' do
# Sentence 1-01: "Tony sees Lisa."
# in absence of a tokenizer, we create a sequence of literals by hand...
# prox_tony = ZProxy.new(tony)
literals = [tony, sees, lisa, dot]
- expect { subject.to_ptree(literals) }.not_to raise_error
+ expect { subject.to_pforest(literals) }.not_to raise_error
# Sentence 1-02a: "Tony sees something."
sentence_literals = [tony, sees, something, dot]
- expect { subject.to_ptree(sentence_literals) }.not_to raise_error
+ expect { subject.to_pforest(sentence_literals) }.not_to raise_error
# Sentence 1-02b: "Lisa sees something."
sentence_literals = [lisa, sees, something, dot]
- expect { subject.to_ptree(sentence_literals) }.not_to raise_error
+ expect { subject.to_pforest(sentence_literals) }.not_to raise_error
# Sentence 1-03: "Tony sees this thing."
sentence_literals = [tony, sees, this, thing, dot]
- expect { subject.to_ptree(sentence_literals) }.not_to raise_error
+ expect { subject.to_pforest(sentence_literals) }.not_to raise_error
# Sentence 1-04: "Lisa sees the other thing."
sentence_literals = [lisa, sees, the, other, thing, dot]
- expect { subject.to_ptree(sentence_literals) }.not_to raise_error
+ expect { subject.to_pforest(sentence_literals) }.not_to raise_error
end
it 'should parse sample sentences from lesson 1-B' do
# Sentence 1-05a: "Lisa sees the same thing."
literals = [lisa, sees, the, same, thing, dot]
- expect { subject.to_ptree(literals) }.not_to raise_error
+ expect { subject.to_pforest(literals) }.not_to raise_error
# Sentence 1-05b: "Lisa sees the same thing as Tony sees."
literals = [lisa, sees, the, same, thing, as, tony, sees, dot]
# same is an adjective of equality comparison
# as is part of same ... as combination
@@ -972,11 +976,11 @@
]
expect { subject.to_pforest(literals) }.not_to raise_error
# Sentence 2-28a definiendum "X dies."
literals = [x_as_noun, dies, dot]
- expect { subject.to_ptree(literals) }.not_to raise_error
+ expect { subject.to_pforest(literals) }.not_to raise_error
# Sentence 2-28b definiens "Something happens to X in a moment.
# X is alive before this moment. X is not alive after this moment.
# [After this person lived for a long time, this person died."
literals = [ something, happens, to, x_as_noun, in_, a_as_art,
@@ -1260,11 +1264,50 @@
dot, tony, says, colon, quote, i_pronoun, can, see, the, animal,
that, you, hear, dot, quote, dot
]
expect { subject.to_pforest(literals) }.not_to raise_error
end
+
+ it 'should parse sample sentences from lesson 3-D' do
+ # Sentence 3-13a definiendum: 'You use this thing.'
+ literals = [you, use, this, thing, dot]
+ expect { subject.to_pforest(literals) }.not_to raise_error
+
+ # Sentence 3-13b definiens: You do something with this thing
+ # because you think this can cause something to happen that you want.
+ # [I used something big to cause people far from here to see me.]
+ literals = [ you, do_, something, with, this, thing, because, you,
+ think, this_as_pronoun, can, cause, something, to, happen,
+ that, you, want, dot,
+ i_pronoun, used, something, big, to, cause, people, far, from,
+ here_as_noun, to, see, me, dot
+ ]
+ expect { subject.to_pforest(literals) }.not_to raise_error
+
+ # Sentence 3-14a definiendum: 'You know X about each of these things.'
+ literals = [you, know, x_as_noun, about, each_, of, these, things, dot]
+ expect { subject.to_pforest(literals) }.not_to raise_error
+ end
=begin
TODO
+3-14. each, each of.
+[You know X about each of these things.] = There are two or more things. You think about all these things like this: If something is one of these things, then you know X about it.
+[Each person here said something to me.]
+
+3-15. exist, exists, to exist, existing, existed.
+[Someplace an X exists.] = Someplace there is an X, or someplace an X is alive.
+[This kind of thing did not exist before this time.]
+
+3-16. become, becomes, to become, becoming, became.
+[J became K.] = Something happened to J for some time. After this happened, K is something true you can know about J. But before this happened, K was not true.
+[These two animals were small before, but they became big.]
+
+There are some animals here.
+Each of these animals was small when it existed a short time.
+After a long time, each of these animals __________.
+became big
+became small
+used many words
Lesson 2.C
Xtra:
Tony knows Lisa has something, because Tony sees what Lisa has.