Commit 43391782 authored by Arne Köhn's avatar Arne Köhn

create tsets now works via the cui.

parent 758015e8
......@@ -86,10 +86,10 @@ sub process {
print STDERR "done reading $n sentences\n" if $verbose;
print STDERR "Wrting $numsentences sentences to trainfile...\n" if $verbose;
print {$trainfile} @sentences[0..$numsentences-1] if $verbose;
print $trainfile @sentences[0..$numsentences-1];
print STDERR "Wrting the other sentences to testfile...\n" if $verbose;
print {$testfile} @sentences[$numsentences..$n] if $verbose;
print $testfile @sentences[$numsentences..$n];
}
......
......@@ -9,6 +9,8 @@ use warnings;
use strict;
use Getopt::Long;
use Curses::UI;
# This imports POSTaggerEvaluator::NegraProcess
require 'negra-sentence-selector.pl';
my $corpus;
my $do_train;
......@@ -27,17 +29,15 @@ sub exit_dialog() {
);
die "FIXME: Shut things down properly" if $return;
}
my $menu_tsets = [
{ -label => 'create tsets'},
{ -label => 'create tsets', -value => \&create_tset},
{ -label => 'list tsets'},
];
my $menu_taggers = [
{ -label => 'train taggers'},
{ -label => 'evaluate taggers'}
{ -label => 'evaluate taggers', -value => "" }
];
......@@ -73,6 +73,7 @@ $cui->set_binding( \&exit_dialog , "\cQ");
# die "Nothing to do..."if not ($do_train or $do_evaluate);
# die "No tagger given" if not $tagger;
my %cfg;
# taken from http://docstore.mik.ua/orelly/perl/cookbook/ch08_17.htm
open CONFIG, "train-evaluate.conf";
......@@ -91,7 +92,10 @@ my $dbh = DBI->connect("dbi:SQLite:dbname=$cfg{'dbfile'}","","");
my @taggers;
@taggers=split(/,/,$cfg{'taggers'});
sub create_db() {
$dbh->do('CREATE TABLE IF NOT EXISTS tsets (id INTEGER PRIMARY KEY ASC, numtrain INTEGER, created_on DEFAULT CURRENT_TIMESTAMP, infoblob DEFAULT NULL');
}
sub train {
my $tagger = shift;
......@@ -104,15 +108,45 @@ sub get_or_restore_tset {
die "not yet implemented, should return the filenames for the test and train set";
}
sub create_tset {
my $name = shift;
my $size = shift;
}
sub list_testresults {
die "should return information about all tsets";
}
sub create_tset {
my $sizestr = $cui->question(-question=>'How many sentences for training?');
eval(my $size=int($sizestr)) or do
{
$cui->error(-message => 'You have to enter a number!');
return;
};
# I'm lazy here since we don't have race-conditions. Be warned if
# you copy-paste!
$dbh->do("INSERT INTO tsets (numtrain) VALUES ($size)");
my $rv = $dbh->last_insert_id('','','tsets','');
open my $cfile, $cfg{'corpus'};
# pwd inserts newlines, strip it!
my $pwd = `pwd`;
chomp $pwd;
`mkdir ${pwd}/tfiles/${rv}/`;
open my $train, ">", $pwd.'/tfiles/'.$rv.'/train';
open my $test, '>', $pwd.'/tfiles/'.$rv.'/test';
POSTaggerEvaluator::NegraProcess::process(1,
$cfile,
$train,
$test,
$size,
1,
0
);
close $test;
close $train;
}
$cui->mainloop;
__END__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment