spec/zenlish/parser/zparser_spec.rb in zenlish-0.1.23 vs spec/zenlish/parser/zparser_spec.rb in zenlish-0.1.24

- old
+ new

@@ -1,241 +1,23 @@ # frozen_string_literal: true - require_relative '../../spec_helper' # Use the RSpec framework -require_relative '../../../lib/zenlish/lex/literal' -require_relative '../support/minimal_lexicon' +require_relative '../support/var2word' require_relative '../../../lib/zenlish/parser/zparser' # Load the class under test module Zenlish module Parser describe ZParser do + include Var2Word + subject { ZParser.new } context 'Initialization:' do it 'should be initialized without argument' do expect { ZParser.new }.not_to raise_error end end # context - def get_lexeme(aLemma, aWordClass = nil) - Zenlish::Lang::Dictionary.get_lexeme(aLemma, aWordClass) - end - - def self.literal2var(aLemma, aLiteral, aSuffix = '') - mth_name = aLiteral.downcase + aSuffix - define_method(mth_name.to_sym) do - Lex::Literal.new(aLiteral, get_lexeme(aLemma), 0) - end - end - - # In absence of a POS tagger/lemmatizer, we map input words - # to variables that themselves return Literal objects. - # For instance, next line will create a variable called 'alive' - literal2var('a', 'a', '_as_art') - literal2var('a', 'an') - literal2var('about', 'about') - literal2var('above', 'above') - def after_adverb ; Lex::Literal.new('after', get_lexeme('after', WClasses::Adverb), 0) ; end - def after_ ; Lex::Literal.new('after', get_lexeme('after', WClasses::SubordinatingConjunction), 0) ; end - literal2var('alive', 'alive') - literal2var('all', 'all') - def am ; Lex::Literal.new('am', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end - literal2var('and', 'and', '_') - literal2var('animal', 'animal') - literal2var('animal', 'animals') - literal2var('another', 'another') - def are ; Lex::Literal.new('are', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end - literal2var('as', 'as') - literal2var('at', 'at') - literal2var('bad', 'bad') - def be_ ; Lex::Literal.new('be', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end - literal2var('because', 'because') - literal2var('become', 'became') - literal2var('become', 'become') - literal2var('become', 'becomes') - def before_adverb ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adverb), 0) ; end - def before_as_adj ; Lex::Literal.new('before', get_lexeme('before', WClasses::Adjective), 0) ; end - def before ; Lex::Literal.new('before', get_lexeme('before', WClasses::SubordinatingConjunction), 0) ; end - literal2var('belong', 'belong') - literal2var('belong', 'belongs') - literal2var('below', 'below') - literal2var('big', 'big') - literal2var('big', 'bigger') - literal2var('body', 'body') - literal2var('but', 'but') - literal2var('can', 'can') - literal2var('cause', 'cause') - literal2var('cause', 'caused') - literal2var('cause', 'causes') - literal2var('contain', 'contain') - literal2var('contain', 'contains') - literal2var('container', 'container') - literal2var('container', 'containers') - def did ; Lex::Literal.new('did', get_lexeme('do', WClasses::IrregularVerbDo), 0) ; end - literal2var('die', 'die') - literal2var('die', 'died') - literal2var('die', 'dies') - literal2var('different', 'different') - 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', '_') - def each_ ; Lex::Literal.new('each', get_lexeme('each', WClasses::DistributiveDeterminer), 0) ; end - def each_as_pronoun ; Lex::Literal.new('each', get_lexeme('each', WClasses::Pronoun), 0) ; end - literal2var('exist', 'exist') - literal2var('exist', 'existed') - literal2var('exist', 'exists') - literal2var('false', 'false', '_') - literal2var('far', 'far') - literal2var('far from', 'far_from') - literal2var('feel', 'feel') - literal2var('feel', 'feels') - literal2var('feel', 'felt') - literal2var('for', 'for', '_') - literal2var('from', 'from') - literal2var('good', 'good') - literal2var('happen', 'happen') - literal2var('happen', 'happened') - literal2var('happen', 'happening') - literal2var('happen', 'happens') - literal2var('have', 'has') - literal2var('have', 'have') - literal2var('hear', 'hear') - literal2var('hear', 'heard') - literal2var('hear', 'hears') - def here ; Lex::Literal.new('here', get_lexeme('here', WClasses::Adverb), 0) ; end - def here_as_noun ; Lex::Literal.new('here', get_lexeme('here', WClasses::CommonNoun), 0) ; end - def i_pronoun ; Lex::Literal.new('I', get_lexeme('I'), 0) ; end - literal2var('if', 'if', '_') - literal2var('in', 'in', '_') - literal2var('inside', 'inside') - literal2var('it', 'it', '_') - literal2var('its', 'its') - literal2var('J', 'j', '_') - def is ; Lex::Literal.new('is', get_lexeme('be', WClasses::IrregularVerbBe), 0) ; end - def is_aux ; Lex::Literal.new('is', get_lexeme('be', WClasses::AuxiliaryBe), 0) ; end - literal2var('K', 'k', '_') - literal2var('kind', 'kind') - literal2var('kind', 'kinds') - literal2var('know', 'knew') - literal2var('know', 'know') - literal2var('know', 'knows') - literal2var('like', 'like') - literal2var('Lisa', 'Lisa') - literal2var('live', 'lived') - literal2var('living', 'living') - literal2var('long', 'long') - literal2var('make', 'made') - literal2var('make', 'make') - literal2var('many', 'many') - literal2var('maybe', 'maybe') - literal2var('me', 'me') - literal2var('moment', 'moment') - def more ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adjective), 0) ; end - def more_as_adverb ; Lex::Literal.new('more', get_lexeme('more', WClasses::Adverb), 0) ; end - literal2var('move', 'move') - literal2var('move', 'moved') - literal2var('move', 'moving') - literal2var('move', 'moves') - literal2var('much', 'much') - literal2var('my', 'my') - literal2var('near', 'near') - literal2var('near to', 'near_to') - literal2var('not', 'not', '_') - def now ; Lex::Literal.new('now', get_lexeme('now', WClasses::Adverb), 0) ; end - def now_as_noun ; Lex::Literal.new('now', get_lexeme('now', WClasses::CommonNoun), 0) ; end - literal2var('of', 'of') - literal2var('on', 'on') - def one ; Lex::Literal.new('one', get_lexeme('one', WClasses::Cardinal), 0) ; end - def one_as_adj ; Lex::Literal.new('one', get_lexeme('one', WClasses::Adjective), 0) ; end - def one_as_pronoun ; Lex::Literal.new('one', get_lexeme('one', WClasses::IndefinitePronoun), 0) ; end - literal2var('or', 'or', '_') - literal2var('other', 'other') - literal2var('part', 'part') - literal2var('part', 'parts') - literal2var('people', 'people') - literal2var('person', 'person') - literal2var('place', 'place') - def same ; Lex::Literal.new('same', get_lexeme('same', WClasses::Adjective), 0) ; end - def same_as_pronoun ; Lex::Literal.new('same', get_lexeme('same', WClasses::Pronoun), 0) ; end - literal2var('see', 'saw') - literal2var('short', 'short') - literal2var('side', 'side') - literal2var('small', 'small') - literal2var('small', 'smaller') - literal2var('some', 'some') - literal2var('say', 'say') - literal2var('say', 'said') - literal2var('say', 'says') - literal2var('see', 'see') - literal2var('see', 'sees') - literal2var('someone', 'someone') - literal2var('someplace', 'someplace') - literal2var('something', 'something') - literal2var('the', 'the') - literal2var('their', 'their') - literal2var('them', 'them') - literal2var('then', 'then', '_') - literal2var('they', 'they') - literal2var('than', 'than') - literal2var('that', 'that') - literal2var('there', 'there') - literal2var('thing', 'thing') - literal2var('thing', 'things') - literal2var('think', 'think') - literal2var('think', 'thinking') - literal2var('think', 'thinks') - def these ; Lex::Literal.new('these', get_lexeme('this', WClasses::DemonstrativeDeterminer), 0) ; end - def these_as_pronoun ; Lex::Literal.new('these', get_lexeme('this', WClasses::DemonstrativePronoun), 0) ; end - def this ; Lex::Literal.new('this', get_lexeme('this', WClasses::DemonstrativeDeterminer), 0) ; end - def this_as_pronoun ; Lex::Literal.new('this', get_lexeme('this', WClasses::DemonstrativePronoun), 0) ; end - literal2var('this one', 'this_one') - literal2var('time', 'time') - literal2var('to', 'to') - literal2var('Tony', 'Tony') - literal2var('touch', 'touch') - 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 - literal2var('what', 'what') - literal2var('when', 'when', '_') - literal2var('who', 'who') - literal2var('with', 'with') - literal2var('word', 'words') - def x_as_noun ; Lex::Literal.new('X', get_lexeme('X'), 0) ; end - literal2var('you', 'you') - literal2var('you', 'your') - - def colon ; Lex::Literal.new(':', get_lexeme(':'), 0) ; end - def comma ; Lex::Literal.new(',', get_lexeme(','), 0) ; end - def dot ; Lex::Literal.new('.', get_lexeme('.'), 0) ; end - def quote ; Lex::Literal.new('"', get_lexeme('"'), 0) ; end - - class ZProxy - attr_reader :literal - - def initialize(aTarget) - @literal = aTarget - end - - def method_missing(name, *args, &aBlock) - puts "#{literal.lexeme} about to receive #{name}" - $stdout.flush - 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 @@ -246,1195 +28,9 @@ # Sentence: "Lisa sees Tony." literals = [lisa, sees, tony, dot] result_type = Rley::SPPF::ParseForest expect(subject.to_pforest(literals)).to be_kind_of(result_type) end - end # context - - context 'Parsing lessons:' do - 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_pforest(literals) }.not_to raise_error - - # Sentence 1-02a: "Tony sees something." - sentence_literals = [tony, sees, something, dot] - 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_pforest(sentence_literals) }.not_to raise_error - - # Sentence 1-03: "Tony sees this thing." - sentence_literals = [tony, sees, this, thing, dot] - 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_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_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 - # it introduces a comparative clause - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-06: "Tony sees one thing." - literals = [tony, sees, one, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-07: "Lisa sees two things." - literals = [lisa, sees, two, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-08a: "Tony sees one person." - literals = [tony, sees, one, person, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-08b: "Lisa sees two people." - literals = [lisa, sees, two, people, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-05b: "Tony sees the same person as Lisa sees." - literals = [tony, sees, the, same, person, as, lisa, sees, dot] - # same is an adjective of equality comparison - # as is part of same ... as combination - # it introduces a comparative clause - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-C' do - # Sentence 1-09a: "Tony sees many things." - literals = [tony, sees, many, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-09b: "Lisa sees many people." - literals = [lisa, sees, many, people, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-10: "Tony is inside this thing." - literals = [tony, is, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-11: "Lisa is not inside this thing." - literals = [lisa, is, not_, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence: "Lisa does not see people inside the other thing." - literals = [lisa, does_aux, not_, see, people, inside, the, other, thing, dot] - # Ambiguous parse... - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-D' do - # Sentence 1-12a: "Some of these people are inside this thing." - literals = [some, of, these, people, are, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-12b: "Some of these people are not inside this thing." - literals = [some, of, these, people, are, not_, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-13: "All of these people are inside this thing." - literals = [all, of, these, people, are, not_, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-14a: "There are two people inside one of these things." - literals = [there, are, two, people, inside, one, of, these, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-14b: "There are not people inside the other thing." - literals = [there, are, not_, people, inside, the, other, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-15a: "There are many people inside this thing." - literals = [there, are, many, people, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-15b: "There are more people inside this thing." - literals = [there, are, more, people, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-15c: "There are more people inside the other thing - # than there are inside this thing." - literals = [there, are, more, people, inside, the, other, thing, - than, there, are, inside, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-E' do - # Sentence 1-16a: "Two of these things are alive." - literals = [two, of, these, things, are, alive, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-16b: "One of these things is not alive." - literals = [one, of, these, things, is, not_, alive, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-17a: "Tony sees some living things." - literals = [tony, sees, some, living, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-17b: "Two of these things are big." - literals = [two, of, these, things, are, big, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-17c: "One of these things is not big." - literals = [one, of, these, things, is, not_, big, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-18a: "Tony sees some living things." - literals = [tony, sees, some, living, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-18b: "One of these is big." - literals = [one, of, these_as_pronoun, is, big, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-18c: "Two of these are small." - literals = [two, of, these_as_pronoun, are, small, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-19a: "Tony sees one living thing." - literals = [tony, sees, one, living, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-19b: "This one is very big." - literals = [this_one, is, very, big, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence: "This thing is bigger than the other thing." - literals = [this, thing, is, bigger, than, the, other, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence: "This thing is smaller than the other thing." - literals = [this, thing, is, smaller, than, the, other, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-F' do - # Sentence 1-20a: "Tony sees some living things." - literals = [tony, sees, some, living, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-20b: "Two of these are the same kind of living thing." - literals = [these_as_pronoun, are, the, same, kind, of, living, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-20c: "One of these is not the same kind as the other two." - literals = [one, of, these_as_pronoun, is, not_, the, same, kind, - as, the, other, two_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-21a: "There is one person inside this thing." - literals = [there, is, one, person, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-21b: "If Tony is not inside this thing, then another person is inside." - literals = [if_, tony, is, not_, inside, this, thing, comma, then_, - another, person, is, inside, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-22a: "Tony is touching something." - literals = [tony, is_aux, touching, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-22b: "Lisa is touching Tony." - literals = [lisa, is_aux, touching, tony, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-23a: "Tony is far from Lisa." - literals = [tony, is, far, from, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-23b: "Lisa is far from Tony." - literals = [lisa, is, far, from, tony, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-23c: "Tony is not far from Lisa." - literals = [tony, is, far, from, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-24: "Tony is near to Lisa." - literals = [tony, is, near_to, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-G' do - # Sentence 1-25a: "Lisa is in this place." - literals = [lisa, is, in_, this, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-25b: "There are two other things in this place." - literals = [there, are, two, other, things, in_, this, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-25c: "Lisa is in the same place as these two other things." - literals = [lisa, is, in_, the, same, place, as, these, two, other, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-25d: "Tony is not in this place." - literals = [tony, is, not_, in_, this, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-25e: "Tony is in another place." - literals = [tony, is, in_, another, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-26a: "Lisa is inside this thing." - literals = [lisa, is, inside, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-26b: "Tony is above this thing." - literals = [tony, is, above, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-26c: "Tony is above lisa." - literals = [tony, is, above, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-27a: "Tony is on one side of this thing." - literals = [tony, is, on, one, side, of, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-27b: "Lisa is on the other side." - literals = [lisa, is, on, the, other, side, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-27c: "Tony is touching one side of this thing." - literals = [tony, is_aux, touching, one, side, of, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 1-H' do - # Sentence 1-28: "Tony hears something." - literals = [tony, hears, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-29a: "Tony says something." - literals = [tony, says, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-29b: "Tony says something to Lisa." - literals = [tony, says, something, to, lisa, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-29c: "Tony says something about this living thing." - literals = [tony, says, something, about, this, living, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-29d: 'Tony says: "This living thing is small."' - literals = [tony, says, colon, quote, this, living, thing, is, small, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-30a: "Tony says some words." - literals = [tony, says, some, words, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-30b: "Lisa says more words." - literals = [lisa, says, more, words, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-31a: 'Tony says: "There are two people inside this thing."' - literals = [tony, says, colon, quote, there, are, two, people, inside, - this, thing, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-31b: 'Lisa says: "There is one person inside this thing."' - literals = [lisa, says, colon, quote, there, is, one, person, inside, - this, thing, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-31c: "What Tony says is not true." - literals = [what, tony, says, is, not_, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 1-31d: "What Lisa says is true." - literals = [what, lisa, says, is, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-A' do - # Sentence 2-01a: "This thing is like two of the other things." - literals = [this, thing, is, like, two, of, the, other, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-01b: "One of these things is not like the other things." - literals = [one, of, these, things, is, not_, like, the, other, things, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-02a: "Lisa has something." - literals = [lisa, has, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-02b: "Tony has another thing." - literals = [tony, has, another, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-02c: "Lisa does not have the same kind of thing as Tony has." - literals = [lisa, does_aux, not_, have, the, same, kind, of, thing, as, tony, has, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-03a: "Lisa is touching part of this thing." - literals = [lisa, is_aux, touching, part, of, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-03b: "Tony is touching the other part." - literals = [tony, is_aux, touching, the, other, part, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-Ax: "What Tony has is like what Lisa has." - literals = [what, tony, has, is, like, what, lisa, has, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-B' do - # Sentence 2-04a: "Lisa does something." - literals = [lisa, does, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-04b: "Lisa does something with this thing." - literals = [lisa, does, something, with, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-04c: "Lisa does something to Tony." - literals = [lisa, does, something, to, tony, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-04d: "Lisa does something to Tony with this thing." - literals = [lisa, does, something, to, tony, with, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-05a: "Something happens." - literals = [something, happens, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-05b: "Something happens to Lisa." - literals = [something, happens, to, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-06a: "Tony does something." - literals = [tony, does, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-06b: "Something happens to Lisa because of this." - literals = [something, happens, to, lisa, because, of, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-06c: "Something happens to Lisa because Tony does this." - literals = [something, happens, to, lisa, because, tony, does, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-06: "Something happens to this living thing." - literals = [something, happens, to, this, living, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-C' do - # Sentence 2-07a: "Lisa thinks Tony is inside this thing." - literals = [lisa, thinks, tony, is, inside, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-07b: "Lisa thinks something about Tony." - literals = [lisa, thinks, something, about, tony, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-08a: "Tony knows Lisa is inside this thing, because Tony sees Lisa inside." - literals = [tony, knows, lisa, is, inside, this, thing, comma, - because, tony, sees, lisa, inside, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-08b: "Tony knows something about Lisa." - literals = [tony, knows, something, about, lisa, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-09a: "Tony wants this thing." - literals = [tony, wants, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-09b: "Tony wants to have this thing." - literals = [tony, wants, to, have, this, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-10a: "Tony wants to do something." - literals = [tony, wants, to, do_, something, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-10b: "Lisa wants to do the same thing." - literals = [lisa, wants, to, do_, the, same, thing, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-10c: "Tony can do this." - literals = [tony, can, do_, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-10d: "This is not something Lisa can do." - literals = [this_as_pronoun, is, not_, something, lisa, can, do_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-10e: "Lisa cannot do this." - literals = [lisa, can, not_, do_, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-D' do - # Sentence 2-11a: "This person does something bad." - literals = [this, person, does, something, bad, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-11b: "This person does something bad for Tony." - literals = [this, person, does, something, bad, for_, tony, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-12a: "Tony does something good." - literals = [tony, does, something, good, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-12b: "Tony does something good for Lisa." - literals = [tony, does, something, good, for_, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-13a: "Tony feels something." - literals = [tony, feels, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-13b: "This does not feel good for Tony." - literals = [this_as_pronoun, does_aux, not_, feel, good, for_, tony, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-13b: "This feels bad for Tony." - literals = [this_as_pronoun, feels, bad, for_, tony, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-Dx: "Lisa thinks about something bad happening to this - # living thing. Thinking about this feels bad for Lisa." - literals = [lisa, thinks, about, something, bad, happening, to, this, - living, thing, dot, - #thinking, about, this_as_pronoun, feels, bad, - #for_, lisa, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-E' do - # Sentence 2-14a: "Lisa says something at this time." - literals = [lisa, says, something, at, this, time, dot] - # Ambiguous parse - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-14b: "Tony is not in this place at this time." - literals = [tony, is, not_, in_, this, place, at, this, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-15a: "At one time, Tony does something to this thing." - literals = [at, one, time, comma, tony, does, something, to, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-15b: "At another time, Lisa says something." - literals = [at, another, time, comma, lisa, says, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-15c: "Tony does something to this thing before Lisa says something." - literals = [tony, does, something, to, this, thing, before, lisa, says, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-16a: "Lisa does something for a long time." - literals = [lisa, does, something, for_, a_as_art, long, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-17a: "Tony does something for a short time." - literals = [tony, does, something, for_, a_as_art, short, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-17a: "Tony does not do this for a long time." - literals = [tony, does_aux, not_, do_, this_as_pronoun, for_, a_as_art, long, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-18a: "Lisa sees something move." - literals = [lisa, sees, something, move, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-18a: "Lisa moves near to this thing." - literals = [lisa, moves, near_to, this, thing, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-E-Xa: "A short time before, Tony was far from Lisa." - # Case of a time adverbial adjunct that is put in front position. - literals = [a_as_art, short, time, before_adverb, comma, tony, was, far, from, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-E-Xa: "At this time, Tony is near to Lisa" - literals = [at, this, time, comma, tony, is, near_to, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-E-Xa: "Tony is near to Lisa because Tony moved" - # Case of a time adverbial adjunct that is put in front position. - literals = [tony, is, near_to, lisa, because, tony, moved, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-F' do - # Sentence 2-19a: 'Tony says: "I did X.".' - literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19a definiendum: 'Tony says: "I did X.".' - literals = [tony, says, colon, quote, i_pronoun, did, x_as_noun, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19a definiens: 'Tony says something about Tony. Tony says: Tony did X.' - literals = [tony, says, something, about, tony, dot, - tony, says, colon, tony, did, x_as_noun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19a: 'Tony says: "I see Lisa.".' - literals = [tony, says, colon, quote, i_pronoun, see, lisa, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19b definiendum: 'Lisa says: "X happened to me.".' - literals = [lisa, says, colon, quote, x_as_noun, happened, to, me, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19b definiens: 'Lisa says something about Lisa. Lisa says: X happened to Lisa.' - literals = [lisa, says, something, about, lisa, dot, - lisa, says, colon, x_as_noun, happened, to, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-19c: 'Lisa says: "Tony sees me."' - literals = [lisa, says, colon, quote, tony, sees, me, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-20a definiendum: 'Tony says to Lisa: "I can see you.".' - literals = [tony, says, to, lisa, colon, quote, i_pronoun, can, see, you, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-20a definiens: 'Tony says something about Lisa. - # Tony says this to Lisa. Tony says: Tony can see Lisa.' - literals = [tony, says, something, about, lisa, dot, - tony, says, this_as_pronoun, to, lisa, dot, - tony, says, colon, tony, can, see, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-20b: "I know you have something good." - literals = [i_pronoun, know, you, have, something, good, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-20c: "I want you to do something good for me." - literals = [i_pronoun, want, you, to, do_, something, good, for_, me, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-21a definiendum: 'Tony says: "X happens here.".' - literals = [tony, says, colon, quote, x_as_noun, happens, here, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-21a definiens: "Tony is in a place. Tony says: X happens in this place." - literals = [tony, is, in_, a_as_art, place, dot, - tony, says, colon, x_as_noun, happens, in_, this, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-21b: "Many people were here at one time." - literals = [many, people, were, here, at, one, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-22a definiendum: 'Lisa says: "X happens now.".' - literals = [lisa, says, colon, quote, x_as_noun, happens, now, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-22a definiens: 'Lisa says something at a time. - # Lisa says: X happens at this same time.' - literals = [lisa, says, something, at, a_as_art, time, dot, - lisa, says, colon, x_as_noun, happens, at, this, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-22b: "There are not many people here now." - literals = [there, are, not_, many, people, here, now , dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-Fa: "Lisa says to Tony: "I can see many living things here."." - literals = [lisa, says, to, tony, colon, quote, i_pronoun, - can, see, many, living, things, here, dot, quote, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-G' do - # Sentence 2-23a definiendum: 'Someone does X.' - literals = [someone, does, x_as_noun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-23a definiens: 'Something does X. This something can - # think like people think. This something can be one person.' - literals = [something, does, x_as_noun, dot, - this, something, can, think, like, people, think, dot, - this, something, can, be_, a_as_art, person, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-23b: Someone said something to Tony. - literals = [someone, said, something, to, tony, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-23c definiendum: 'J knows who did K.' - literals = [j_, knows, who, did, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-23c definiens: J thinks about someone. - # J knows this someone did K. - literals = [j_, thinks, about, someone, dot, - j_, knows, this, someone, did, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-23d: Tony knows who said something. - literals = [tony, knows, who, said, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-24a definiendum: 'J happens after K happens.' - literals = [j_, happens, after_, k_, happens, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-24a definiens: K happens before J happens. - literals = [k_, happens, before, j_, happens, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-24b: After you do something for a long time, - # you can know much more about this. - literals = [after_, you, do_, something, for_, a_as_art, long, time, - comma, you, can, know, much, more_as_adverb, about, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-25a definiendum: 'X is true for some time.' - literals = [x_as_noun, is, true_, for_, some, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-25a definiens: X is true at a time. - # Some parts of this one time happen before other parts. - # Some parts of this one time happen after other parts. - # X is true at all parts of this one time. - literals = [x_as_noun, is, true_, at, a_as_art, time, dot, - some, parts, of, this, one, time, happen, before_adverb, other, parts, dot, - some, parts, of, this, one, time, happen, after_adverb, other, parts, dot, - x_as_noun, is, true_, at, all, parts, of, this, one, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-25b: After I moved for some time, - # I was near the other side of this place. - literals = [after_, i_pronoun, moved, for_, some, time, - comma, i_pronoun, was, near, the, other, side, of, this, place, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-26a definiendum: 'X happens in a moment.' - literals = [x_as_noun, happens, in_, a_as_art, moment, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-26a definiens: X happens for one very short time. - # There are not parts of this very short time when one part - # happens before other parts. - literals = [x_as_noun, happens, for_, one, very, short, time, dot, - there, are, not_, parts, of, this, very, short, time, when_, - one, part, happens, before_adverb, other, part, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-26b: In a moment, I knew something here was not good. - # 'here' is adverb that modifies the 'knew' verb - literals = [in_, a_as_art, moment, comma, i_pronoun, knew, something, - here, was, not_, good, dot ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-Gx: Tony is inside this thing for some time. - # Lisa says: "I want to know who is inside this thing.". - # Tony hears Lisa. Because of this, Tony says: "I am inside.". - # Tony says this after Tony hears Lisa. - literals = [tony, is, inside, this, thing, for_, some, time, dot, - lisa, says, colon, quote, i_pronoun, want, to, know, who, is, - inside, this, thing, dot, quote, dot, tony, hears, lisa, dot, - because, of, this_as_pronoun, comma, tony, says, colon, - quote, i_pronoun, am, inside, dot, quote, dot, - tony, says, this_as_pronoun, after_, tony, hears, lisa, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 2-H' do - # Sentence 2-27a definiendum: 'X is the body of this person.' - literals = [x_as_noun, is, the, body, of, this, person, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-27b "Parts of this person can touch other things. - # Parts of this person can touch other parts inside this person. - # X is all of these parts of this person." - # [One part of the body of this person felt very bad.] - literals = [ parts, of, this, person, can, touch, other, things, dot, - parts, of, this, person, can, touch, other, parts, inside, - this, person, dot, - x_as_noun, is, all, of, these, parts, of, this, person, dot, - one, part, of, the, body, of, this, person, felt, very, bad, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-28a definiendum "X dies." - literals = [x_as_noun, dies, dot] - 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, - moment, dot, - x_as_noun, is, alive, before_adverb, this, moment, dot, - x_as_noun, is, not_, alive, after_adverb, this, moment, dot, - after_, this, person, lived, for_, a_as_art, long, time, comma, - this, person, died, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-29a definiendum "You think maybe X is true." - literals = [you, think, maybe, x_as_noun, is, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-29b definiens "You think something like X - # can be true. You do not know X is true. - # You do not know X is not true. - # [Maybe some people far from here can see me.]" - literals = [ you, do_aux, not_, know, x_as_noun, is, true_, dot, - you, do_aux, not_, know, x_as_noun, is, not_, true_, dot, - maybe, some, people, far_from, here_as_noun, can, see, me, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-30a definiendum "J is below K." - literals = [j_, is, below, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-30b definiens "K is above J. - # [I am touching this thing below me.] - literals = [ j_, is, below, k_, dot, - i_pronoun, am, touching, this, thing, below, me, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 2-H extra "Someone sees this thing. - # The body of this thing is not moving. - # Maybe this thing is dead." - literals = [ someone, sees, thing, dot, - the, body, of, this, thing, is_aux, not_, moving, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 3-A' do - # Sentence 3-01a definiendum: 'J happens to something that does K.' - literals = [j_, happens, to, something, that, does, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-01b definiens: 'J happens to something. - # This same something does K. - # [Tony has something that Lisa wants.]' - literals = [j_, happens, to, something, dot, - this, same, thing, does, k_, dot, - tony, has, something, that, lisa, wants, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-02a definiendum: 'J is true, and K is true.' - literals = [j_, is, true_, comma, and_, k_, is, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-02b definiens: 'These two things are true: J is true. - # K is true.' - # [Lisa sees Tony, and Tony sees Lisa.]' - literals = [these, two, things, are, true_, colon, j_, is, true_, dot, - k_, is, true_, dot, - lisa, sees, tony, comma, and_, tony, sees, lisa, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-02c definiendum: 'J and K do X.' - literals = [j_, and_, k_, do_, x_as_noun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-02d definiens: 'These two things do X. - # J is one that does this. - # K is another that does this.' - # [Tony and Lisa want to see me.] - # [I see Tony and Lisa.]' - literals = [these, two, things, do_, x_as_noun, dot, - j_, is, one_as_adj, that, does, this_as_pronoun, dot, - k_, is, another, that, does, this_as_pronoun, dot, - tony, and_, lisa, want, to, see, me, dot, - i_pronoun, see, tony, and_, lisa, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-03a definiendum: 'J is true, or K is true.' - literals = [j_, is, true_, comma, or_, k_, is, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-03b definiens: 'If J is not true, then K is true. - # [Tony saw me, or Lisa heard me.] - literals = [if_, j_, is, not_, true_, comma, - then_, k_, is, true_, dot, - tony, saw, me, comma, or_, lisa, heard, me, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-03c definiendum: 'J or K does this.' - literals = [j_, or_, k_, does, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-03d definiendum: 'If J does not do this, then K does this.' - literals = [if_, j_, does_aux, not_, do_, this_as_pronoun, comma, - then_, k_, does, this_as_pronoun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-03e: '[Lisa or Tony said something.] - # [This belongs to Tony or Lisa.]' - literals = [lisa, or_, tony, said, something, dot, - this_as_pronoun, belongs, to, tony, or_, lisa, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-04a definiendum: 'It does something.' - literals = [it_, does, something, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-04b definiens: 'This thing does something.' - # [I touched this thing, and it moved.] - literals = [this, thing, does, something, dot, - i_pronoun, touched, this, thing, comma, and_, it_, moved, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-04c definiendum: 'They do something.' - literals = [they, does, something, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-04d definiens: 'These things or people do something.' - # [Something happens to them.] = Something happens to these things or people. - literals = [ these, things, or_, people, do_, something, dot, - something, happens, to, them, dot, - something, happens, to, these, things, or_, people, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 3-B' do - # Sentence 3-05a definiendum: 'This is its X.' - literals = [this_as_pronoun, is, its, x_as_noun, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-05b definiens: 'This X belongs to it. - # [I saw this thing and touched some of its parts.] - # [These things are their things.] = These things belong to them. - literals = [this, x_as_noun, belongs, to, it_, dot, - i_pronoun, saw, this, thing, and_, touched, some, of, its, parts, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-05c definiendum: 'These things are their things.' - literals = [these, things, are, their, things, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-05d definiens: 'These things belong to them. - literals = [these, things, belong, to, them, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-06a definiendum: 'This is your X.' - literals = [this_as_pronoun, is, your, x_as_noun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-06b definien: 'This X belongs to you. - # [You feel something touching your body.] - literals = [this, x_as_noun, belongs, to, you, dot, - you, feel, something, touching, your, body, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-07a definiendum: 'This is my X.' - literals = [this_as_pronoun, is, my, x_as_noun, dot, - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-07b definiens: 'This X belongs to me. - # [I do not want you to touch my body.] - literals = [this, x_as_noun, belongs, to, me, dot, - i_pronoun, do_aux, not_, want, to, touch, my, body, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-08a definiendum: 'There is an X here.' - literals = [there, is, an, x_as_noun, here, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-08b definiens: 'X is some kind of thing. - # There is one of this kind of thing here. - # This is not one that you said something about a short time before now. - # [I did not know there was a person in this place.] - literals = [x_as_noun, is, some, kind, of, thing, dot, - there, is, one, of, this, kind, of, thing, here, dot, - this_as_pronoun, is, not_, one_as_adj, that, you, said, something, - about, a_as_art, short, time, before_as_adj, now_as_noun, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-Bxa 'Lisa sees a living thing that is very big. - # Lisa says: "I see one living thing. Its body is bigger than my body.", dot - literals = [ - lisa, sees, a_as_art, living, thing, that, is, very, big, dot, - lisa, says, colon, quote, i_pronoun, see, one, living, thing, dot, - its, body, is, bigger, than, my, body, dot, quote, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 3-C' do - # Sentence 3-09a definiendum: 'Something happens to the X.' - literals = [something, happens, to, the, x_as_noun, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-09b definiens: Something happens to X. - # This is the same X that someone said something about a short time before, - # or there is not another thing that is the same kind as X. - # [I saw two people here before, and now I do not see the people.] - literals = [something, happens, to, x_as_noun, dot, - this_as_pronoun, is, the, same, x_as_noun, that, someone, said, something, about, - a_as_art, short, time, before_as_adj, comma, - or_, there, is, not_, another, thing, that, is, the, same, kind, - as, x_as_noun, dot, - i_pronoun, saw, two, people, here, before_adverb, comma, - and_, now, i_pronoun, do_aux, not_, see, the, people, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-10a definiendum: 'X is an animal.' - literals = [x_as_noun, is, an, animal, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-10b definiens: There are many kinds of living things - # that can feel and can move when they want. X is one of these. - # [The animal moved when someone touched its body.] - literals = [ there, are, many, kinds, of, living, things, - that, can, feel, and_, can, move, when_, they, want, dot, - x_as_noun, is, one, of, these_as_pronoun, dot, - the, animal, moved, when_, someone, touched, its, body, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-11a definiendum: 'J causes K to happen.' - literals = [j_, causes, k_, to, happen, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-11b definiens: K happens because J happens - # or because J does something. - # [Someone bad caused these people to die.] - literals = [ k_, happens, because, j_, happens, - or_, because, j_, does, something, dot, - something, bad, caused, these, people, to, die, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-12a definiendum: 'J is true, but K is not true.' - literals = [j_, is, true_, comma, but, k_, is, not_, true_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-12b definiens: You say J is true. - # Maybe when some people hear J is true, - # they think K is true because of this. - # You want them to know K is not true, and you say this. - # [I hear Tony, but I do not see Tony.] - literals = [ maybe, when_, some, people, hear, j_, is, true_, comma, - they, think, k_, is, true_, because, of, this_as_pronoun, dot, - you, want, them, to, know, k_, is, not_, true_, comma, - and_, you, say, this_as_pronoun, dot, - i_pronoun, hear, tony, comma, but, i_pronoun, do_aux, not_, see, lisa, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-C Xtra Lisa says: "I can hear an animal, but I do not see it." - # Tony says: "I can see the animal that you hear.". - literals = [ lisa, says, colon, quote, i_pronoun, can, hear, an, - animal, comma, but, i_pronoun, do_aux, not_, see, it_, dot, quote, - 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 - - # Sentence 3-14b definiens: 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.] - # 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 = [ there, are, two, or_, more, things, dot, - you, think, about, all, these, things, like, this_as_pronoun, colon, - if_, something, is, one, of, these, things, comma, - then_, you, know, x_as_noun, about, it_, dot, - each_, person, here, said, something, to, me, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-15a definiendum: 'Someplace an X exists.' - literals = [someplace, an, x_as_noun, exists, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-15b definiens: Someplace there is an X, - # or someplace an X is alive. - # [This kind of thing did not exist before this time.] - literals = [ someplace, there, is, an, x_as_noun, comma, - or_, someplace, an, x_as_noun, is, alive, dot, - this, kind, of, thing, did, not_, exist, before, this, time, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-16a definiendum: 'J became K.' - literals = [j_, became, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-16b definiens: 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.] - literals = [ something, happened, to, j_, for_, some, time, dot, - after_, this_as_pronoun, happened, comma, k_, is, something, true_, - you, can, know, about, j_, dot, - these, two, animals, were, small, before_adverb, comma, - but, they, became, big, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-Dx: 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. - literals = [there, are, some, animal, here, dot, - each_, of, these, animals, was, small, when_, it_, - existed, a_as_art, short, time, dot, - after_, a_as_art, long, time, comma, each_, of, these, animals, - became, big, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end - - it 'should parse sample sentences from lesson 3-E' do - # Sentence 3-17a definiendum: 'These things are different.' - literals = [things, are, different, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-17b definiens: These things are not the same. - # [I want this kind of thing, but you want something different.] - literals = [ these, things, are, not_, the, same_as_pronoun, dot, - i_pronoun, want, this, kind, of, thing, comma, - but, you, want, something, different, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-18a definiendum: 'J made K.' - literals = [j_, made, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-18b definiens: J did something to some things - # and caused them to become parts of one different - # kind of thing that was not here before. - # K is this thing that now exists because of this. - # [I used many small things to make this big thing.] - # [J made K happen.] = J caused K to happen. - literals = [ j_, did, something, to, some, things, and_, - caused, them, to, become, parts, of, one, different, kind, of, - thing, that, was, not_, here, before_adverb, dot, - k_, is, this, thing, that, now, exists, because, of, this_as_pronoun, dot, - i_pronoun, used, many, small, things, to, make, this, big, thing, dot, - j_, made, k_, happen, dot, - j_, caused, k_, to, happen, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-19a definiendum: 'J contains K.' - literals = [j_, contains, k_, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-19b definiens: K is inside J. - # [I made something to contain all these small things.] - # [Your body contains many parts.] - literals = [ k_, is, inside, j_, dot, - i_pronoun, made, something, to, contain, all, these, small, things, dot, - your, body, contains, many, parts, dot, - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-20a definiendum: 'X is a container.' - literals = [x_as_noun, is, a_as_art, container, dot] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-20b definiens: X is something that people make because - # they want to use it to contain other things. - # [There are two things inside this container.] - literals = [ x_as_noun, is, something, that, people, make, because, - they, want, to, use, it_, to, contain, other, things, dot, - there, are, two, things, inside, this, container, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - - # Sentence 3-Fxtra: Someone made these containers. - # Each contains a different kind of animal. - literals = [someone, made, these, containers, dot, - each_as_pronoun, contains, a_as_art, different, kind, of, animal, dot - ] - expect { subject.to_pforest(literals) }.not_to raise_error - end -=begin -TODO - -Lesson 2.C - - Xtra: - Tony knows Lisa has something, because Tony sees what Lisa has. - Tony thinks about what Lisa has, because Tony want to have the same kind of thing. -=end end # context end # describe end # module end # module