|
Source files for all programs used For Future Study:
Ambiguity Even though we defined the words "time" and "flies" as both nouns and verbs, when we gave the parser the sentence "time flies", it knew that "time" was a noun and "flies" was the verb describing the action taken by the noun, and that we did not mean anything else. This is because the rules in the grammar define the proper way to interpret words in a sentence. However, some sentences are ambiguous, in that there is more than one way to generate them using a certain grammar. This can make it difficult to determine the actual meaning of a sentence. For example, consider the sentence "The man kept the dog in the house". Given our latest grammar, two interpretations are actually possible: Generated by PROLOG, text reformatted for readability: ?- parse([the, man, kept, the, dog, in, the, house]). [S, [NP, [the, ART], [man,
NOUN]], Which might read as "(The man) (kept) (the dog in the house)", meaning "The man took ownership of the dog that was located in the house". But another interpretation that is equally valid is: Not Generated By PROLOG: [S, [NP, [the, ART], [man,
NOUN]], Note that in the above example, the prepositional phrase (PP) was part of the noun phrase (NP), but here it makes up a third component of the verb phrase. This sentence would be read as "(The man) (kept) (the dog) (in the house), or "The man forced the dog to remain in the house". And if the rule NP -> NP PP is removed from the grammar, this is the interpretation that is generated: Generated by PROLOG, text reformatted for readability: ?- parse([the, man, kept, the,
dog, in, the, house]). Unfortunately, forcing PROLOG to generate both interpretations when both rules were present proved to be a very difficult task. But it can be seen that when the aforementioned rule is removed, the sentence is still parsed, though with a different structure and meaning. There are various rules in the field of linguistics that say which interpretation humans favor even though both are grammatically valid. We can follow these rules to some degree by re-ordering our PROLOG clauses, though this may not be sufficient, as the parser did not explicitly choose one rule over another, rather it chose a rule that worked in a given situation, and only by denying it that rule in that particular situation did it choose the other rule at some point later on.
Number Agreement In our grammar, if we define "scares" as a verb and "mice" as a noun, we can generate the following sentence, which is not proper English: *�The mice scares the cat� Ivan Bratko's book presents a basic form of a grammar with features by introducing the feature of number agreement into a PROLOG parser. In this way, sentence([the, cat, scares, the, mice]). becomes sentence(singular, [the, cat, scares, the, mice]). and sentence(plural, [the, cats, scare, the, mice]). This has the effect of increasing the complexity of the entire grammar, and we have only added one feature...
Grammar With Features Conjugation of verbs, number agreement with nouns... A grammar with a sufficient number of features can powerfully generate or recognize a large number of sentences. Different types of nouns (mass nouns vs. count nouns) and number agreement conjugation of verbs are two examples of features that a grammar can recognize. In a grammar with features, words such as nouns include features such as whether they are singular or plural. Verbs describing these nouns would then have to be in agreement with existing features - for example, the word He is third-person singular, and the third-person singular form of the verb 'walk' is walks. In this representation, the word walks is the conjugated form of the verb walk possessing the features "third-person singular" and "present-tense". This might be represented as verb(walks, 3s, pres) to allow the parser to match a certain specific conjugation of a verb. These features are attributed to the sentence and then are passed down to its component NP's and VP's for matching individual words with the proper features. For example, a sentence with the features "3s" and "pres" could never produce an NP that matches "They" or "The dogs", nor could it produce a verb phrase matching the verbs "walked" (conjugated in the preterit) or "are walking" (conjugated in the present progressive).
|
|