diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-12 19:40:19 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-05-12 19:40:19 +0300 |
commit | 0cd62488bf3967b399aa96de0999f4fd36632200 (patch) | |
tree | aabb52859053a44be79ff92aa0e1b3a717668a9d | |
parent | abfc0671a3de76b755549c1f8fac4fa11bb85d2c (diff) |
morfessor wrapper
-rwxr-xr-x | scripts/training/wrappers/morfessor-wrapper.perl | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/training/wrappers/morfessor-wrapper.perl b/scripts/training/wrappers/morfessor-wrapper.perl index 5f6c86d8d..b0debe38c 100755 --- a/scripts/training/wrappers/morfessor-wrapper.perl +++ b/scripts/training/wrappers/morfessor-wrapper.perl @@ -6,9 +6,11 @@ use Getopt::Long "GetOptions"; my $MORF_DIR; my $MODEL; +my $TMPDIR = "."; -GetOptions('morfessor-dir=s' => \$MORF_DIR, - 'model=s' => \$MODEL); +GetOptions("morfessor-dir=s" => \$MORF_DIR, + "model=s" => \$MODEL, + "tmpdir=s" => \$TMPDIR); die("Must provide --model=s argument") if (!defined($MODEL)); @@ -18,20 +20,22 @@ if (defined($MORF_DIR)) { $cmd .= "PYTHONPATH=$MORF_DIR $MORF_DIR/scripts/"; } -my $TMP_FILE = "/tmp/morf.$$"; +my $TMPFILE = "$TMPDIR/morf.$$"; $cmd .= "morfessor-segment " ."-L $MODEL " ."--output-format \"{analysis} \" " ."--output-format-separator \" \" " ."--output-newlines " ."/dev/stdin " - ."| sed 's/ \$//' > $TMP_FILE"; + ."| sed 's/ \$//' > $TMPFILE"; print STDERR "Executing: $cmd\n"; `$cmd`; -open(FILE, $TMP_FILE) or die("Can't open file $TMP_FILE"); +open(FILE, $TMPFILE) or die("Can't open file $TMPFILE"); while (my $line = <FILE>) { print "$line"; } close(FILE); + +unlink($TMPFILE); |