Vous êtes sur la page 1sur 4

Faculty of Computers and Information Technology Year:2013-2014 (Spring Semester)

Course Name: Language Engineering Midterm Exam (10-4-2014)


Course code: ITF 306 Time allowed: 1.5 hrs.
Instructor: Dr. Azza Taha Marks: 20
Model Answer
Question 1: Choose the correct answer: (5 Marks)
1. Two grammars are equivalent if they
a. Generate the same language.
b. Have the same number of production rules.
c. Have the same set of non-terminals.
d. Have equivalent set of terminals and non-terminals.
2. Which of the following rules is NOT a correct context-free grammar rule, where the set of non-
terminals is {A, B}, and the set of terminals is {a, b}:
a. A a c. A a | bA
b. A d. None of the previous
3. One problem of the top-down search is the left recursion.
a. True b. False
4. Syntactic knowledge concerns how
a. Words are constructed from more basic meaning units called morphemes .
b. Sentences are used in different situations and how use affects the interpretation of the
sentence .
c. Words can be put together to form correct sentences.
d. The immediately preceding sentences affect the interpretation of the next sentence.
5. Pragmatic knowledge concerns how
a. Words are constructed from more basic meaning units called morphemes .
b. Sentences are used in different situations and how use affects the interpretation of the
sentence .
c. Words can be put together to form correct sentences.
d. The immediately preceding sentences affect the interpretation of the next sentence.
6. is the study of the structure and the forms of a word.
a. Phonetics c. Syntax
b. Morphology d. Semantics
7. A statement is ungrammatical if
a. It has more than one parse tree.
b. It cannot be derived from a given grammar.
c. Some part of a sentence is ambiguous.
d. None of the above.
8. Structural ambiguity occurs when
a. A grammar assigns more than one possible parse to a sentence.
b. Some part of a sentence is ambiguous.
c. All of the above.
d. None of the above.
9. Top-down search is also called
a. Bottom-up search c. Bottom-down search
b. Goal-directed search. d. Data-directed search.

Page 1 of 4
10. Given that the set of terminals is {x, y} and A is nonterminal, which of the following words is
correctly generated from the CFG: Ax| yA
a. xyyy c. yxyxy
b. yyyx d. xyy

Question 2: (5 Marks)
1. Give regular expression to express each of the following:
a. The set of all lower case alphabetic strings ending in letters ing.
Answer:
Algebraic Notation
(a+b++z)* ing
Perl Notation
[a-z] [a-z]*ing
b. The set of all upper case alphabetic strings with letter a as a third letter.
Answer:
Algebraic Notation
(A+B++Z) (A+B++Z) a (A+B++Z)*
Perl Notation
[A-Z] [A-Z] a [A-Z]*
c. The set {can, car, cat}
Answer:
Algebraic Notation
ca(n+r+t) or can+car+cat
Perl Notation
ca[n r t] or ca(n| r| t)

2. Define finite state transducers (FST), then design a FST that takes the lexical form:
box +N +PL
and produces the intermediate form box ^s#

Answer:

A finite state transducer (FST) is a type of finite automaton, it accepts input and produces output, if
consists formally from the following:

1. Q: finite set of states q0, , qn


2. : input alphabet
3. : output alphabet
4. q0 Q is the start state
5. F Q is the set of final states
6. : Q x * 2 is the transition function
7. : Q x * 2 is the output function
Page 2 of 4
Question 3: (10 Marks)
1. What is the difference between Inflectional and derivational morphology; illustrate your
answer with examples?

Answer: see Chapter 3 of the text book. (3 Marks)

2. Consider the following Probabilistic CFG :

S NP VP [1.0] ProperNoun Adel [ 0.2]


VP VP PP [ 0.9] ProperNoun Maged [ 0.2]
VP Verb NP [ 0.1] ProperNoun town [ 0.6]
NP NP PP [ 0.5] Verb saw [1.0]
NP ProperNoun[ 0.5] Preposition in [1.0]
PP Preposition NP[ 1.0]

1. Describe the 4 parts of this grammar.


Answer: (2 Marks)
a. S is the start state
b. The set of Variables or non-terminals is:
{S, NP, VP, PP, Verb, ProperNoun, Preposition}
c. The set of terminals is:
{Adel, Maged, town, saw, in}
d. The rules are given in the question.

2. Give a parse tree for the sentence:


Adel saw Maged in town.
Answer: (3 Marks)

Page 3 of 4
S

NP VP

ProperNoun VP PP

Adel Verb NP Preposition NP

saw ProperNoun in ProperNoun

Maged Town

3. What is the highest probability for any parse tree of this sentence under this Probabilistic CFG?
Answer: (2 Marks)

The probability of the parse tree given above is:

1* 0.5 * .9 * 0.2 *0.1 *1.0 *1.0 *.5 *1.0 *.5 *.2 *0.6 = 0.0027

There is also the following parse tree:


S

NP VP

ProperNoun Verb NP

Adel saw NP PP

ProperNoun Preposition NP

Maged in ProperNoun

Town
The probability of this tree is: 1 * 0.5 * 0.2 *.1 * 1.0 * 0.5 * 0.5 *0.2 *1.0 *1.0 *.5 *.6 = 0.00015
The first parse tree is of the highest probability.

Page 4 of 4

Vous aimerez peut-être aussi