From: gherman at my-dejanews.com (Dinu C. Gherman)
Date: Thu, 22 Apr 1999 11:52:33 GMT
Subject: Project for newbie
References: <70alf7.qc6.ln@loopback>
Message-ID: <7fn2i0$7ql$1@nnrp1.dejanews.com>
Content-Length: 7024
X-UID: 114
In article <70alf7.qc6.ln at loopback>, morph at softhome.net wrote:
>
> I've read my way through the tutorial, and am now stuck - where do I go
> from here? I want to learn how to use Python, but don't have any
> pressing projects at the moment - can anyone suggest a program I should
> have a go at writing, to help me learn the language further?
What about this little problem, assuming you're
interested in internet programming and keen to get
familiar with the Python XML module...? ;-)
Have fun,
Dinu
Context:
The Altavista babelfish returns the following result
page (see appendix below) after issuing this request:
"translate 'water' from English to French"
on that WWW page:
http://babelfish.altavista.com
Some quick testing reveales that you can do the same
with just typing the following (wrapped) URL in your
browser:
http://babelfish.altavista.com/cgi-bin/translate?
doit=done&urltext=water&lp=en_fr
Exercise 1:
Write a program babelfish.py calling the Altavista
Babelfish over the WWW (using httplib, say) and parse
its HTML output using your favorite HTML/XML parser
(suggestion: use the XML module written by the Python
XML-SIG) in order to extract the result and print it
nicely in a terminal window like this:
darwin> python babelfish.py water en_fr
l'eau
darwin>
Exercise 2:
Improve your program by allowing multiple words to
be translated in a row, like this (you'll have to
send multiple requests as Babelfish will try to
treat your words as a sentence):
darwin> python babelfish.py spam eggs en_fr
spam
oeufs
darwin>
Appendix: Sample Babelfish output
(see context description)
AltaVista: Translations
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own