| CIT
591 Language
Translation Notes Fall 2005, David Matuszek |
In the assignment I said:
Write a class
LanguageTranslatorwhich the GUI will call (approximately) as follows:
LanguageTranslator translator =
new LanguageTranslator(fromLanguage, toLanguage);
String translation = translator.translate(someText);
Notice that the translator object (of type LanguageTranslator)
has all the information it needs to translate a String. It does not need
to know what language the string is in, or what language it is translating to.
It has an array of "fromLanguage" words, a corresponding array of
"toLanguage" words, and a RuleSet object containing methods
to do word rearrangement.
If your translator.translate method needs to know what language
it is translating from, or what language it is translating to, you are not using
interfaces correctly.
In the assignment I said:
Any word that is not found [in the dictionary] should be left "as is", untranslated.
Since you don't know the part of speech of such words, assume that they are
not of type NOUN, VERB, or ADJ.
I didn't have time before class to include my "stub" class LanguageTranslator.java
in the .zip file. If you still need it, you can download it from
this link.
Do yourself a favor. Go to the Java API and look through the list of methods
in the java.lang.String class (and maybe the java.lang.Character
class as well). You can probably find some methods here to simplify the String
processing in this assignment.