derecovecs: allow word string and index number in API calls
diff --git a/w2v-server.c b/w2v-server.c
index cc8734c..3a8092c 100644
--- a/w2v-server.c
+++ b/w2v-server.c
@@ -534,6 +534,13 @@
   return (wl);
 }
 
+long getWordNumber(char *word) {
+  wordlist *wl = getTargetWords(word, 0);
+  if(wl->length > 0)
+    return(wl->wordi[0]);
+  return(0);
+}
+
 float get_distance(long b, long c) {
   long a;
   float dist = 0;
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 {