Does Python compete with Java?

Graham Fawcett graham__fawcett at hotmail.com
Thu Apr 15 00:19:14 EDT 2004


Jakub Fast <kfast at poczta.onet.pl> wrote in message news:<mailman.585.1081876373.20120.python-list at python.org>...
> I've been pondering using python+NLTK to teach a computational semantics 
> class this summer (precisely because i think the basics of python would 
> be easy for the students to learn quickly, and, class aside, that 
> learning them actually might turn out useful for whatever they want to 
> do in the future -- more useful than, say, prolog) and nothing can beat 
> the intuitive appeal of
> 
> S ==> (NP and VP) or VP
> 
> over CFGProduction(S, NP, VP), CFGProduction(S, VP) for specifying your 
> simple cfg, dcg or ebnf rules if you're completely new to programming 
> and have just been given a programming assignment :)

Using a domain-oriented mini-language (parsed from within Python) is a
simple way to "extend" Python syntax.

An new instance of a DgcGrammar class, for example, could represent a
new, empty grammar; it could have an eval() method which could parse a
string of DGC rules to be added to itself: e.g.,

   g = DcgGrammar()
   g.eval('s --> np,vp. np --> det,n. ...').

Perhaps not what you had in mind; but personally, I think the
separation of syntaxes enforced by the method call is a a benefit. You
get Prolog (kind of) and Python both, without having to force one to
imitate the other.

There are Python tools for generating parsers from EBNF grammars, for
example, which could be used to whip up a domain-language parser in a
jiffy.

And, of course, your students get the added benefit of having the
parser's source code available -- for reuse, Python instruction and
light bedtime reading!

(On another note, I seem to recall there's a Prolog implementation in
Python somehwere; perhaps there's some reusable DGC-related code
there.)

Just two cents,

-- Graham



More information about the Python-list mailing list