Homework 3
Due Thurs Nov 11, 18:00
Exercise: (10 points)
Write a progam called RuleBasedPosGuesser that guesses the part of
speech of a word based on the language
and some rules that
apply to the language.
Input / Output overview:
- The input to your program will be the language and a word (read
these from the keyboard).
- The output of your program will be the word and its part of
speech (NOUN, VERB, ADJ).
Input:
- Language: Two languages will be handled by your program - English
and German
- If the user wants English, they can enter "english" or
"englisch" (any combination of upper- and lowercase letters)
- If the user wants German, they can enter "german" or "deutsch"
(any combination of upper- and lowercase letters)
- Word:
- The user can type any word on a line by itself
Processing:
- Use the following rules to try to determine the part of speech of
the input word:
- English:
- a word that ends with "ing" or "ed" is often a verb (walking, walked)
- a word that ends in "ly" is often an adjective (friendly, costly)
- German:
- a word that ends with "heit", "keit", or "ung" is often a noun (Kindheit,
Dankbarkeit, Sammlung)
- a word that ends with "lich" is often an adjective (ehrlich,
peinlich)
- a word that ends with "en" is often a verb (fahren, trinken)
Output:
- print the word and the part of speech (or "unknown" if you are
unable to guess)
Optional:
- Use enumerations for the language and/or the part of speech
- Use a switch statement in your code
- Add additional rules, or impove the rules given (for example, in
German, words that end in "en" are more likely to be nouns than verbs
if they start with a capital letter)
- To find out if a character is upper- or lowercase, use the
method Character.isUpperCase(someCharacter) or
Character.isLowerCase(someCharacter)
- Character.isUpperCase('A') returns true
- Character.isLowerCase('B') returns false
- Try adding another language if you know one
Sample Input/Output:
language:
|
input word:
|
output:
|
English
|
walked
|
walked [pos: VERB]
|
|
hiking
|
hiking [pos: VERB]
|
|
ugly
|
ugly [pos: ADJ]
|
|
dog
|
dog [pos: unknown]
|
German
|
Dunkelheit
|
Dunkelheit [pos: NOUN]
|
|
Planung
|
Planung [pos: NOUN]
|
|
ehrlich
|
ehrlich [pos: ADJ]
|
|
schreiben
|
schreiben [pos: VERB]
|
|
Hunger
|
Hunger [pos: unknown]
|
Submit the following file to Anne (javaiscl (at googlemail.com)):
RuleBasedPosGuesser.java