English plurals
A first attempt
Here
is a start at building a system for pluralising English words.
Run it by typing
plural followed by some singular form of a noun, e.g. plural
"cat. Don't forget the quotes.
to plural :noun
if sibilant.end? :noun [op suffix :noun "es] [op suffix :noun "s]
end
to sibilant.end? :word
if member? last :word [s z x] [op "true]
if and ( last :word ) = "h not ( last bl :word ) = "t [op "true]
op "false
end
to suffix :stem :affix
op word :stem :affix
end
Sibilant.end?
does not really perform appropriately.
It outputs "true if the input ends in s
or z or h (as long as the h
is not preceded by t).
Some normal words therefore give it problems. Which?
And can you edit sibilant.end? to deal with these cases
correctly?
Plural as it stands does not handle correctly
the plurals of words like daisy which end in y. Can
you modify the procedure to take care of this problem? You will need to define
a predicate consonant? and you might find it useful to take
advantage of its companion called
vowel?. You could perhaps also create a predicate ends.in.y?,
but this would be less generally useful.
In the end,
there are, of course, exceptions which are best treated by listing them. One
well-known and amusing way to handle these is to set up for every such case
a variable which has the singular form as its name and the plural form as its value.
For example make "ox "oxen. With variables like
this in place, we now edit
plural so that it checks first to see if the word to be pluralised
is a variable name and if so outputs the corresponding variable value without
further ado:
to plural :noun
if name? :noun [op thing :noun]
if sibilant.end? :noun [op suffix :noun "es] [op suffix :noun "s]
end
The
way the pluraliser now handles exceptions presupposes that all
processing of words is from singular to plural. Assume that the system was required
to convert not only singulars
to plurals but also, on occasions, plurals to singulars. In these circumstances,
how could the information about exceptions be more conveniently stored?
French
dictionaries and articles
If you
are unhappy with the fake version of entry, and would like it
to output a range of words rather than a single word, one alternative is to rewrite
the procedure using a series of conditional instructions each based on a test like :word
= "fromage.
Whenever a particular test returns "true, the dictionary
entry of the corresponding word should be output. Notice tthat this tactic
effectively means building the dictionary into the definition of entry
rather than treating it as a separate data structure, as we originally
proposed.
(Look here if you can't work out how to do this. But please
experiment first!)
There are, of course, yet other ways to implement the
dictionary in the first place.
For example, each word could be set up independently (using make)
as the name of a variable, the value of which is its complete dictionary
entry.
E.g. make "fromage [[category noun]
[gender masculine] [means cheese]]
Can you write a version
of entry (assuming it still takes a word as input) which is adapted
to this new arrangement?
How would you improve the treatment of French
articles provided earlier
in this section so that you could handle the fact that there are some French words
like herbe 'grass' which behave as though they begin with vowels
- l'herbe - while others (fewer) like hibou 'owl'
behave as though they begin with consonants - le hibou?
Suppose
- to take a different line again - that a bilingual
dictionary is handled as a list of word pairs [[book livre][pen stylo]
... ]. Define a predicate
correct.translation? which takes two inputs :word1
:word2 and makes use of member? to output "true
when :word1 is the English equivalent of
the French :word2 E.g. correct.translation?
"book "livre should output "true
and correct.translation? "book "stylo
should output "false.
What does your version of correct.translation?
do with correct.translation "livre "book?
If it bothers you, can you see how to correct the problem?
Ron Brasington
Department of Linguistic Science
The University of
Reading
Reading
UK
E-mail: ron.brasington@rdg.ac.uk