Download PROLOG Family Knowledge Base Assignment 2004

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Georgian grammar wikipedia , lookup

Macedonian grammar wikipedia , lookup

Modern Greek grammar wikipedia , lookup

Old English grammar wikipedia , lookup

English clause syntax wikipedia , lookup

Old Norse morphology wikipedia , lookup

Ojibwe grammar wikipedia , lookup

Navajo grammar wikipedia , lookup

Lithuanian grammar wikipedia , lookup

Portuguese grammar wikipedia , lookup

Preposition and postposition wikipedia , lookup

Modern Hebrew grammar wikipedia , lookup

Swedish grammar wikipedia , lookup

Udmurt grammar wikipedia , lookup

Inflection wikipedia , lookup

Kannada grammar wikipedia , lookup

Serbo-Croatian grammar wikipedia , lookup

Malay grammar wikipedia , lookup

Compound (linguistics) wikipedia , lookup

Italian grammar wikipedia , lookup

Icelandic grammar wikipedia , lookup

Old Irish grammar wikipedia , lookup

Chinese grammar wikipedia , lookup

Romanian grammar wikipedia , lookup

Arabic grammar wikipedia , lookup

Romanian nouns wikipedia , lookup

Zulu grammar wikipedia , lookup

Ancient Greek grammar wikipedia , lookup

Spanish grammar wikipedia , lookup

Scottish Gaelic grammar wikipedia , lookup

Latin syntax wikipedia , lookup

Esperanto grammar wikipedia , lookup

French grammar wikipedia , lookup

Yiddish grammar wikipedia , lookup

Determiner phrase wikipedia , lookup

English grammar wikipedia , lookup

Polish grammar wikipedia , lookup

Pipil grammar wikipedia , lookup

Transcript
Martin Lesner 19627033
Artificial Intelligence 210CSC306
PROLOG Natural Language Grammar Assignment 2004
Question 1
The Grammar
compound_sentence --> sentence(_), conjunction, sentence(_).
/* it permits linking two main clauses by 'and' or 'but' (e) */
sentence(N) --> noun_phrase(N), verb_phrase(N).
noun_phrase(N) --> determiner(N), noun(N).
noun_phrase(plural) --> noun(plural).
/* it permits a plural noun without a determiner (a) */
noun_phrase(N) --> determiner(N), adjective(N), noun(N).
/* it permits a noun preceded by an adjective (b,c) */
noun_phrase(plural) --> adjective(plural), noun(plural).
/* it permits a plural noun preceded by an adjective without a determiner (b,c) */
verb_phrase(N) --> verb(N).
verb_phrase(N) --> verb(N), noun_phrase(_).
verb_phrase(N) --> verb(N), adverb.
/* it permits a verb without an object followed by an adverb (d) */
verb_phrase(N) --> verb(N), noun_phrase(_), adverb.
/* it permits a verb with an object followed by an adverb (d) */
determiner(singular) --> [a].
determiner(singular) --> [an].
determiner(singular) --> [that].
determiner(plural) --> [those]. /* it is a plural form of that */
determiner(_) --> [the].
adjective(_) --> [gigantic].
adjective(_) --> [irksome].
adjective(_) --> [macroscopic].
adjective(plural) --> [many].
adjective(_) --> [microscopic].
adjective(_) --> [pleasant].
adjective(plural) --> [several].
adjective(_) --> [slow].
adjective(_) --> [stout].
/* it permits a plural noun preceded by adjective 'many' (c) */
/* it permits a plural noun preceded by adjective 'several' (c) */
/* in the adjective form stout can mean brave and arduous ... */
noun(singular) --> [bloke].
noun(plural) --> [blokes].
noun(singular) --> [digger].
noun(plural) --> [diggers].
noun(singular) --> [instrumentalist].
noun(plural) --> [instrumentalists].
noun(singular) --> [knife].
/* in the noun form a knife means a bit */
1
Martin Lesner 19627033
Artificial Intelligence 210CSC306
noun(plural) --> [knives].
noun(singular) --> [skyscraper].
noun(plural) --> [skyscrapers].
noun(singular) --> [spanner].
noun(plural) --> [spanners].
noun(singular) --> [spoon].
/* in the noun form a spoon means kind of dishes */
noun(plural) --> [spoons].
noun(singular) --> [stick].
/* in the noun form a stick means a rod */
noun(plural) --> [sticks].
noun(singular) --> [stout].
/* in the noun form a stout can mean 'a black beer' */
noun(plural) --> [stouts].
noun(singular) --> [vocalist].
noun(plural) --> [vocalists].
noun(singular) --> [whistle]. /* in the noun form a whistle means a fife or a pipe */
noun(plural) --> [whistles].
verb(singular) --> [adores].
verb(plural) --> [adore].
verb(singular) --> [knifes].
verb(plural) --> [knife].
verb(singular) --> [reviles].
verb(plural) --> [revile].
verb(singular) --> [spoons].
verb(plural) --> [spoon].
verb(singular) --> [sticks].
verb(plural) --> [stick].
verb(singular) --> [warbles].
verb(plural) --> [warble].
verb(singular) --> [whistles].
verb(plural) --> [whistle].
/* in the verb form to knife means something like to jab by knife */
/* in the verb form to spoon means to angle or spoon up */
/* in the verb form to stick means to push down, to prick */
/* in the verb form to whistle means something like to sing */
adverb --> [illogically].
adverb --> [inordinately].
adverb --> [lamentably].
adverb --> [regrettably].
conjunction --> [and].
conjunction --> [but].
The Rules
These rules give examples for testing my changes in the grammar. The rules without commentaries are
accepted.
question_1a(N) :- phrase(noun_phrase(N),[diggers]).
question_2a(N) :- phrase(noun_phrase(N),[digger]). /* rejected */
question_1b(N) :- phrase(noun_phrase(N),[the,irksome,vocalists]).
question_2b(N) :- phrase(noun_phrase(N),[irksome,vocalists]).
question_3b(N) :- phrase(noun_phrase(N),[a,irksome,vocalist]).
2
Martin Lesner 19627033
Artificial Intelligence 210CSC306
question_1c(N) :- phrase(noun_phrase(N),[many,blokes]).
question_2c(N) :- phrase(noun_phrase(N),[the,several,blokes]).
question_3c(N) :- phrase(noun_phrase(N),[a,many,bloke]).
/* rejected */
question_4c(N) :- phrase(noun_phrase(N),[the,several,bloke]). /* rejected */
question_1d(N) :- phrase(verb_phrase(N),[adores,the,instrumentalist,illogically]).
question_2d(N) :- phrase(verb_phrase(N),[adore,illogically]).
question_1e :phrase(compound_sentence,[vocalists,adore,the,instrumentalists,and,the,bloke,reviles,the,skyscraper]).
question_2e :phrase(compound_sentence,[a,vocalist,adores,instrumentalists,but,the,blokes,revile,skyscrapers]).
Question 2
Query a)
phrase(noun_phrase(N),[an,irksome,instrumentalist,adores,
the,spoons,inordinately]).
PROLOG answers ‘no’, because the noun_phrase doesn’t contain the verb_phrase in the end of rule (or after
the noun). Here the verb_phrase means this word order: adores the spoons inordinately. The first three words
(an irksome instrumentalist) are well for singular noun phrase. This example would be successful for phrase
sentence in singular form.
Query b)
phrase(verb_phrase(N),[reviles,the,spoons,a,lot]).
PROLOG answers ‘no’. The word order reviles the spoons is correct, because there is the verb (reviles) in
singular form followed by noun_phrase (the spoons) in plural form. The noun_phrase can be followed by
adverb, but here is the problem with rest [a, lot]. There isn’t this very terminal symbol of phrase adverb in
knowledge base.
Query c)
phrase(sentence(N),[that,stout,bloke,warbles,lamentably]).
PROLOG answers ‘N = singular’. This word order corresponds to sentence in singular form. The phrase
sentence contains the noun_phrase (that stout bloke) followed by verb_phrase (warbles lamentably). The
noun_phrase can contain determiner (that) followed by adjective (stout) followed by noun (bloke) and the
verb_phrase can contain verb (warbles) followed by adverb (lamentably). Because all words are in singular
form the phrase is successful and PROLOG gives ‘singular’.
Query d)
phrase(noun_phrase(N),[an,irksome,instrumentalist,adores,
the,spoons,inordinately],Rest).
PROLOG answers ‘N=singular, Rest=[adores,the,spoons,inordinately]’
The third argument (Rest) of predicate phrase returns any words left over after the non-terminal in the first
argument (noun_phrase) has been extracted. The noun_phrase contains determiner (an) followed by adjective
(irksome) followed by noun (instrumentalist). So list of words occurring after word order an irksome
instrumentalist will be inserted to the variable Rest. All words of noun phrase are in singular form so PROLOG
gives variable N=singular.
3
Martin Lesner 19627033
Artificial Intelligence 210CSC306
Query e)
phrase(sentence(N),[those,stout,bloke,warble]).
PROLOG answers ‘no’. The word order those stout bloke corresponds to the noun_phrase and word warble
corresponds to the verb_phrase. There is a difference among the determiner (those) which is in the plural form,
noun (bloke) which is in the singular form and verb (warble) which is in the plural form.
Query f)
phrase(sentence(N),[those,slow,skyscrapers,warble,
that,microscopic,instrumentalist]).
PROLOG answers ‘N=plural’. The sentence consists of noun_phrase (those slow skyscrapers) which is in
the plural form followed by verb_phrase (warble that microscopic instrumentalist) where the verb warble is in
the plural form, as well. The noun_phrase consist of determiner (those) followed by adjective (slow) followed
by noun (skyscrapers). The verb_phrase consists of the verb (warble) followed by noun_phrase (that
microscopic instrumentalist) etc. Everything fits.
Query g)
phrase(sentence(N),[a,vocalist,adores,several,
pleasant,instrumentalists]).
PROLOG answers ‘no’. The word order appears to be correct. There is the accord singular form of the noun
phrase and of the verb phrase. However there is a problem in noun_phrase (several pleasant instrumentalists)
nested in verb phrase. PROLOG expects a determiner followed by an adjective followed by a noun, but the
word several doesn’t occur in knowledge base of the determiners.
Query h)
phrase(sentence(N),[a,gigantic,knife,sticks,
illogically,into,the,spoon]).
PROLOG answers ‘no’. The word order a gigantic knife sticks illogically corresponds to noun_phrase
(a gigantic knife) followed by verb_phrase (sticks illogically), both in singular form. However there is a
problem with rest of words (into the spoon) which corresponds to nothing (it’s redundant).
Query i)
phrase(compound_sentence,[the,digger,adores,the,skyscraper,and,
regrettably,the,vocalists,knife,the,instrumentalist]).
PROLOG answers ‘no’. The compound sentence is a link two sentences by ‘and’ or ‘but’. The first sentence is
correct (the word order before linking word ‘and’). However the second sentence is wrong, there is a problem
with word regrettably which occurs in knowledge base as adverb. No sentence can start with adverb. This
compound sentence would be correct without this adjective.
Query j)
phrase(verb(N),[spanner]).
PROLOG answers ‘no’. The word spanner doesn’t occur in knowledge base as verb in plural or singular form.
It occurs as noun in singular form.
4
Martin Lesner 19627033
Artificial Intelligence 210CSC306
Question 3
The main shortcoming is that this grammar doesn’t consider meaning the words. So we can obtain the
nonsensical sentences like some examples listed above, which are correct for this grammar. It hasn’t a sense of
the real word. It misses some links with meaning among the words. It only considers categorization of words
like verb, noun, etc. which is good for correct grammar but it misses some additional information about
meaning of words.
The next thing is that this grammar doesn’t contain the rules for more complex grammar. I thing it
misses some rules for use the tenses, passive, etc.
5