EXAMPLE OF ATTRIBUTE GRAMMAR

advertisement
ATTRIBUTE GRAMMAR EXAMPLE 2
In various circumstances, such e.g. those involved in trading, or shopping, or the
operating theatre, only restricted subsets of language are, for the most part,
employed. We consider here, as an example, the problem of producing a
translator from English to Italian of a small subset of English.
The set of possible English sentences in this example can be described by the
regular expression:
The (student | teacher) is a (tall | short) (man | woman).
Two such sentences are;
The student is a tall man
and
The student is a tall woman
Possible Italian translations of these sentences are respectively:
il studente è un uomo alto
and
la studentessa è una donna alta
(The “un” and “una” may in practice be omitted)
As can be seen from the example, there are different male and female Italian
words for: “the”, “a”, “student”, “teacher”, “tall”, “short”
The choice of whether to use the masculine or feminine form depends in this
example on the last word of the sentences involved.
In translating e.g. “the teacher is a tall woman” we only discover which gender
attribute should be used for “teacher”, “is”, “tall” when we get to the last word in
the sentence. Google, and other translation programs, translates this sentence
using the masculine form for those three words (but will correctly use the
feminine form if the sentence starts with a identifiable feminine subject, such as
“The woman is a tall person”)
Another example is “The student is a short person with a large beard”. Here
again the gender attributes of the above three words depends on the last word
“beard”. Here is an associated grammar for a small subset of English, whose
sentences we wish to be to translate into Italian using correct gender attributes.
sentence → article subject object-clause preposition-clause
subject → teacher | student
article → the | a
object-clause → verb article adjective person-object
preposition-clause → with article adjective feature-object |
verb → is | was
person-object → man | woman | person
adjective → small | large | tall | short
feature-object → beard | bosom
Consider the syntax tree for: The teacher is a small person with a beard
sentence
article subject
the
teacher
object-clause
verb article adjective person-object
is
a
tall
person
preposition-clause
with article adjective feature-object
a
beard
The gender attribute of the symbols in the above syntax tree is determined by
application of the following selection of rules:
1. The gender attribute of “beard” is masculine.
2. The gender-attribute of “feature-object” is given by the gender of the feature
(beard or bosom) involved as it’s child in the tree
3. The gender attribute of “preposition-clause” is given by the gender attribute
of its feature object child.
4. The gender-attribute of the object-clause (in the above tree) is given by its
sibling preposition-clause.
5. The gender attribute of the children of object-clause (verb article adjective
person-object is given by the gender-attribute of the object-clause (their
parent)
6. The gender-attribute of “person” is given by the gender attribute of it’s parent
“person-object”
7. The gender-attributes of the “subject” and the preceding article are given by
their sibling “object-clause”
As you can see gender-attribute is both a synthesized attribute (as shown by
points 2 and 3) and an inherited attribute (as shown by points 4 – 7).
Download