[Corpora-List] Perl reader for Treebank parse trees?
John Fry
john at johnfry.org
Sun Apr 16 05:25:24 UTC 2006
"Steven Bird" <sb at 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
More information about the Corpora
mailing list