derekovecs: handle nan, inf and NA
diff --git a/w2v-server.pl b/w2v-server.pl
index 527c7ce..8bf0f14 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -125,6 +125,7 @@
if(!$cccache{$word}) {
$c->app->log->info("Getting classic collocates of $word.");
$cccache{$word} = getClassicCollocators($word);
+ $cccache{$word} =~ s/:(-?)(nan|inf)/:"${1}${2}"/g;
} else {
$c->app->log->info("Getting classic collocates for $word from cache.");
}
@@ -144,7 +145,7 @@
}
foreach my $i (@{$d1->{collocates}}) {
my $w = $i->{word};
- $i->{delta} = $i->{ld} - (defined $d2ld{$w} ? $d2ld{$w} : -5);
+ $i->{delta} = $i->{ld} - (defined $d2ld{$w} ? $d2ld{$w} : 0);
}
return(encode_json($d1));
} else {