Semantics with Negation |
Avril Kenney 6.863 final project 18 May 2010 |
Overview For this project, I extended the semantic system to include negation ('not' and 'no'). The existing system was unable to represent the truth values of statements, and therefore could not differentiate between knowing that a statement was false versus not knowing whether a statement was true or false; the inclusion of negation solves this problem. I also fixed/changed several other problems with the system, including determiners, names, prepositions, and passives. The code (.zip file) can be downloaded here. (Note: requires Python with nltk version 1.2 (later versions aren't compatible with the semantics system).) The adverb 'not' Statements and queries are both now allowed to include 'not', indicating the opposite of the positive statement. This was implemented by adding an optional 'Not' production to the beginning of VBARs, and adding a "truth" attribute for statements, which can be set to 'true' or 'false'. Hello. > did john see mary I don't know. > john did not see mary Okay. > did john see mary No. > who did john not see mary > who did not see mary john > john did not give mary fido Okay. > did john give fido to mary No. > who did john not give mary fido > did john not give mary fido Yes. > did john not not give mary fido No. The determiner 'no' Any noun phrase - subject, direct object, indirect object, or object of a preposition, in statements and in queries - can begin with 'no'. The meaning of this determiner is not exactly the same as in real English, because that would have required also implementing other determiners like 'every'. Instead, the system behaves as if there is exactly one instance of each NP (this also fits with its treatment of definiteness; see the following section), so quantifying an NP with 'no' is equivalent to negating the sentence. Hello. > john gave mary no dog Okay. > did john give mary a dog No. > what did john not give mary dog > who did john not give a dog to mary > who did john give no dog to mary > no man saw mary Okay. > did a man see mary No. Definiteness The idea of definiteness has been removed. In the original system, determiners specified definiteness, but this did not actually have any meaning, and so was not dealt with properly in interpreting statements and queries. A query with a definite NP would not match a statement with an indefinite NP, and vice-versa: Hello. > john saw a dog Okay. > did john see the dog No.Without discourse context, definiteness is pretty much meaningless anyway, so there is no reason to include it. Noun matching In the original system, facts specified different NPs differently (names with a "name" attribute, nouns with a "type" attribute). This caused all names to match against all non-name nouns: Hello. > john saw a dog Okay. > did john see mary Yes.This was changed such that all NPs use the "name" attribute, and matching works properly. There was also the word 'somebody' in the lexicon, which made just an Object with no attributes, so it would match against any Object: Hello. > john saw somebody Okay. > did john see mary Yes.This word was therefore changed to 'everybody' to reflect its actual meaning. Multiple answers In the original system, only a single answer could be given for a query, even if the system knew multiple answers: Hello. > john saw fido Okay. > john saw mary Okay. > who did john see mary > did john see fido Yes.The matching was modified so that if there are multiple answers, all of them will be shown, conjoined by 'and': Hello. > john saw mary Okay. > john saw fido Okay. > who did john see fido and mary(The word 'and' is only used in answers given by the system; it still is not allowed in user input.) Prepositional phrases In the original system, prepositional phrases could be handled in a limited number of locations, but not in other locations where it would make sense for them to be allowed: Hello. > john gave fido to mary in the park I don't understand. > john saw mary in the park Okay. > did john see mary in the park I don't understand. > where did john see mary in the parkA few more rules were added so that prepositional phrases are allowed in yes-no questions and in sentences with ditransitive verbs. Passives In the original system, the words 'is' and 'was' were present in the lexicon, but they were not actually usable. They could only be used to form passives, but passive sentences were incorrectly interpreted as active, and could not be used in queries: Hello. > john is a man I don't understand. > john is red I don't understand. > john is driven Okay. > is john driven I don't understand. > does john drive Yes.The existing rules were corrected to create the correct interpretation, and new rules were added to allow passive constructions in both yes-no questions and wh-questions: Hello. > john was driven by fido Okay. > who drove john fido > was john driven by fido Yes. > mary does not like john Okay. > who is john not liked by mary |