RE: [Corpora-List] Perl reader for Treebank parse trees?

From: Victor Kapustin (victor.kapustin@gmail.com)
Date: Sun Apr 16 2006 - 08:22:22 MET DST

  • Next message: Victor Kapustin: "RE: [Corpora-List] Perl reader for Treebank parse trees?"

    > -----Original Message-----
    > From: owner-corpora@lists.uib.no
    > [mailto:owner-corpora@lists.uib.no] On Behalf Of John Fry
    > Sent: Sunday, April 16, 2006 9:25 AM
    > To: Steven Bird
    > Cc: Philip Resnik; CORPORA@uib.no
    > Subject: Re: [Corpora-List] Perl reader for Treebank parse trees?
    >
    > "Steven Bird" <sb@csse.unimelb.edu.au> writes:
    >
    > > For those still wedded to Perl for NLP, consider the following Perl
    > > program to find all words in a text ending in "ing". Note the
    > > 'magic', the bits of syntax like <>, (split), my, $, =~,
    > which reduces
    > > readability:
    > >
    > > while (<>) {
    > > foreach my $word (split) {
    > > if ($word =~ /ing$/) {
    > > print "$word\n";
    > > }
    > > }
    > > }
    > >
    > > Here's the Python version, which contains far less magic:
    > >
    > > import sys
    > > for line in sys.stdin.readlines():
    > > for word in line.split():
    > > if word.endswith('ing'):
    > > print word
    >
    > #!/usr/bin/ruby
    > puts scan(/\w+ing/) while gets
    >
    Unbeateable!
    Perl magic equivalent:
    #!/usr/bin/perl
    grep {print "$_\n" if /ing$/ } split while (<>) ;



    This archive was generated by hypermail 2b29 : Sun Apr 16 2006 - 08:21:34 MET DST