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

From: John Fry (john@johnfry.org)
Date: Sun Apr 16 2006 - 07:25:24 MET DST

  • Next message: Victor Kapustin: "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



    This archive was generated by hypermail 2b29 : Sun Apr 16 2006 - 07:26:22 MET DST