w2v-server: add getWord API function for checking word presence
diff --git a/w2v-server.pl b/w2v-server.pl
index 3b736c7..dbe179a 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -247,6 +247,30 @@
$self->render(data => getSimilarProfilesCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
};
+any '*/getWord' => sub {
+ my $self = shift;
+ my $w = $self->param("w");
+ my $rank = getWord($w);
+ my $status = 200;
+ if ($rank <= 0) {
+ $rank = -1;
+ $status = 404;
+ }
+ $self->render(data => encode_json({word => $w, frequencyRank => $rank}), format => 'json', status => $status);
+};
+
+any '/getWord' => sub {
+ my $self = shift;
+ my $w = $self->param("w");
+ my $rank = getWord($w);
+ my $status = 200;
+ if ($rank <= 0) {
+ $rank = -1;
+ $status = 404;
+ }
+ $self->render(data => encode_json({word => $w, frequencyRank => $rank}), format => 'json', status => $status);
+};
+
any '/getSimilarity' => sub {
my $self = shift;
my $w1 = $self->param("w1");