w2v-server: add rest/json api (?json=1)
diff --git a/w2v-server.pl b/w2v-server.pl
index 127c779..df93317 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -76,6 +76,7 @@
   my $som=$c->param('som') || 0;
 	my $searchBaseVocabFirst=$c->param('sbf') || 0;
   my $sort=$c->param('sort') || 0;
+  my $json=$c->param('json') || 0;
   my $res;
 	my @lists;
 	my @collocations;
@@ -93,7 +94,11 @@
 		}
 	}
 	$word =~ s/ *\| */ | /g;
-	$c->render(template=>"index", word=>$word, no_nbs=>$no_nbs, no_iterations => $no_iterations, epsilon=> $epsilon, perplexity=> $perplexity, show_som=>$som, searchBaseVocabFirst=>$searchBaseVocabFirst, sort=>$sort, training_args=>$training_args, mergedEnd=> $mergedEnd, marked=>\%marked, lists=> \@lists, collocators=> $res->{syntagmatic});
+  if($json) {
+    return $c->render(json => {word => $word, list => \@lists, collocators=>$res->{syntagmatic}});
+  } else {
+    $c->render(template=>"index", word=>$word, no_nbs=>$no_nbs, no_iterations => $no_iterations, epsilon=> $epsilon, perplexity=> $perplexity, show_som=>$som, searchBaseVocabFirst=>$searchBaseVocabFirst, sort=>$sort, training_args=>$training_args, mergedEnd=> $mergedEnd, marked=>\%marked, lists=> \@lists, collocators=> $res->{syntagmatic});
+  }
 };
 
 $daemon->run; # app->start;