> -----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
>
Taking punctuation into acount:
#!/usr/bin/perl
map {print "$_\n" } m/\b\w*ing\b/g while(<>) ;
Real magic!
This archive was generated by hypermail 2b29 : Sun Apr 16 2006 - 08:38:07 MET DST