Skip to content

Commit

Permalink
predict case patterns of verbs using not Goi-taikei but a probabilist…
Browse files Browse the repository at this point in the history
…ic model.
  • Loading branch information
ryu-i committed Mar 29, 2007
1 parent 9b9b995 commit 75ee2da
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 31 deletions.
7 changes: 7 additions & 0 deletions resolveZero/script/NCVTool.pm
Expand Up @@ -32,11 +32,16 @@ sub new {
type => 'newswire',
prob => 'MI',
model => 'n1000',
pat => 'ncv',
@_,
);
my $self = {};
bless $self, $class;

opendir 'DIR', $model_dir{$scorer_params{type}};
my @file = grep /$scorer_params{model}/, readdir DIR;
closedir DIR;

my $model_path = $model_dir{$scorer_params{type}}.'/'.$scorer_params{model};
my $model_prob = $scorer_params{prob};
if ($model_prob eq 'chi2') {
Expand All @@ -45,6 +50,8 @@ sub new {
}
die "Cannot find models in $model_path" if ! -e $model_path.'.pz.da';
my ($pid, $out, $in);
$scorer = 'scorer -u 2 -m Pos -p ' if ($scorer_params{pat} eq 'cv');

$pid = open2 $out, $in, "$scorer $model_prob -d $model_path";

$self->{pid} = $pid;
Expand Down
27 changes: 27 additions & 0 deletions resolveZero/script/predictCasePattern.pl
@@ -0,0 +1,27 @@
#!/usr/bin/env perl

use strict;
use warnings;

use FindBin qw($Bin);
unshift @INC, $Bin;
use NCVTool;
my $ncvtool = new NCVTool(model=>'n50', pat=>'cv');

sub predicat_case_pattern {
my $pred = shift; # Bunsetsu
my @type = ('GA');
if ($pred->PRED) {
my %case = ( '¤ò'=>'WO', '¤Ë'=>'NI' );
for my $case (keys %case) {
my $q = $case.':'.$pred->PRED;
my $score = $ncvtool->get_score($q);
push @type, $case{$case} if ($score and $score > 0) ;
}
} else {
@type = ('GA', 'WO', 'NI') if ($pred->HEAD_POS =~ /^Æ°»ì/);
}
return @type;
}

1;
33 changes: 2 additions & 31 deletions resolveZero/script/resolveZero.pl
Expand Up @@ -31,23 +31,7 @@ BEGIN
require 'centerList.pl';
require 'extractFeatures.pl';
require 'cab.pl';

use FindBin qw($Bin);
my $v2type = $Bin.'/../../dict/db/v2type.db';
my %db;
{
no strict "subs";
if (eval "require BerkeleyDB; 1") {
tie %db, 'BerkeleyDB::Hash',
-Filename => $v2type,
-Flags => DB_RDONLY,
-Mode => 0444
or die "Cannot open $v2type:$!";
} elsif (eval "require DB_File; 1") {
tie %db, 'DB_File', $v2type, O_RDONLY, 0644
or die "Cannot open $v2type:$!";
}
}
require 'predictCasePattern.pl';

my $rootPath = $scriptPath; $rootPath =~ s|[^/]+/$||;

Expand Down Expand Up @@ -120,30 +104,17 @@ sub resolve_zero {
}
if ($b->PRED) {
my $pred = $b;
my @type = ();
if ($db{$b->PRED}) {
@type = split ' ', $db{$b->PRED};
} else {
if ($b->HEAD_POS =~ /^動詞/) {
@type = ('GA', 'WO', 'NI');
} else {
@type = ('GA');
}
}
my @type = &predicat_case_pattern($pred);
for my $type (@type) {
# print STDERR 'intra ant', "\t", $type, "\n";
my $intra_ant = &identify_antecedent_intra_bact($pred, $s, $type, $cl, $mRef->{intra}->{ant}->{$type});
# print STDERR 'intra ana', "\n";
my $intra_score = 0;
if ($intra_ant) {
$intra_score = &detemine_anaphoricity_intra_bact($s, $pred, $intra_ant, $type, $cl, $mRef->{intra}->{ana}->{$type});
}
if ($intra_score > $intraParam{$type}) {
$pred->{$type} = $intra_ant;
} else {
# print STDERR 'inter ant', "\n";
my $inter_ant = &identify_antecedent_inter_bact($pred, $s, $t, $type, $cl, $mRef->{inter}->{ant}->{$type});
# print STDERR 'inter ana', "\n";
my $inter_score = 0;
if ($inter_ant) {
$inter_score = &detemine_anaphoricity_inter_bact($s, $pred, $inter_ant, $type, $cl, $mRef->{inter}->{ana}->{$type});
Expand Down

0 comments on commit 75ee2da

Please sign in to comment.