Skip to content

Instantly share code, notes, and snippets.

@benui-dev
Created April 9, 2012 06:29
Show Gist options
  • Select an option

  • Save benui-dev/2341946 to your computer and use it in GitHub Desktop.

Select an option

Save benui-dev/2341946 to your computer and use it in GitHub Desktop.
Reading KNP data from a file
# Iterate through pre-parsed KNP output stored in a file. Useful for processing a batch of
# sentences offline, and then dealing with them later.
use strict;
use warnings;
use KNP::File;
# File is the result of "juman | knp -tab > knp.out"
my $knp_file = new KNP::File( file => $ARGV[0], encoding => 'utf-8' )
or die "Couldn't make KNP from file $!";
while (my $knp = $knp_file->each()) {
# Normal KNP object in $knp
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment