derecovecs: allow word string and index number in API calls
diff --git a/w2v-server.pl b/w2v-server.pl
index f85748a..ae53f87 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -111,6 +111,15 @@
return $_;
}
+sub getWord {
+ ($_) = @_;
+ if ($_ =~ /^\d+/) {
+ return $_;
+ } else {
+ return getWordNumber($_);
+ }
+}
+
sub getClassicCollocatorsCached {
my ($c, $word) = @_;
my $s2 = "";
@@ -177,12 +186,12 @@
any '*/getClassicCollocators' => sub {
my $self = shift;
- $self->render(data => getClassicCollocatorsCached($self, $self->param("w") ? $self->param("w") : $self->req->json), format=>'json');
+ $self->render(data => getClassicCollocatorsCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
};
any '/getClassicCollocators' => sub {
my $self = shift;
- $self->render(data => getClassicCollocatorsCached($self, $self->param("w") ? $self->param("w") : $self->req->json), format=>'json');
+ $self->render(data => getClassicCollocatorsCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
};
any '/getBiggestVocabDistances' => sub {
@@ -215,12 +224,12 @@
any '*/getSimilarProfiles' => sub {
my $self = shift;
- $self->render(data => getSimilarProfilesCached($self, $self->param("w") ? $self->param("w") : $self->req->json), format=>'json');
+ $self->render(data => getSimilarProfilesCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
};
any '/getSimilarProfiles' => sub {
my $self = shift;
- $self->render(data => getSimilarProfilesCached($self, $self->param("w") ? $self->param("w") : $self->req->json), format=>'json');
+ $self->render(data => getSimilarProfilesCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');
};
any '/getSimilarity' => sub {