w2v-server: new param csv for csv-output
diff --git a/w2v-server.pl b/w2v-server.pl
index a0e9e49..a956b22 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -91,6 +91,7 @@
my $som=$c->param('som') || 0;
my $searchBaseVocabFirst=$c->param('sbf') || 0;
my $sort=$c->param('sort') || 0;
+ my $csv=$c->param('csv') || 0;
my $json=$c->param('json') || 0;
my $cutoff=$c->param('cutoff') || 1000000;
my $dedupe=$c->param('dedupe') || 0;
@@ -119,6 +120,18 @@
$word =~ s/ *\| */ | /g;
if($json) {
return $c->render(json => {word => $word, list => \@lists, collocators=>$res->{syntagmatic}});
+ } elsif($csv) {
+ my $csv_data="";
+ for (my $i=0; $i <= $no_nbs; $i++) {
+ $csv_data .= $res->{paradigmatic}->[$i]->{word} . ", ";
+ }
+ for (my $i=0; $i < $no_nbs; $i++) {
+ $csv_data .= $res->{syntagmatic}->[$i]->{word} . ", ";
+ }
+ chop $csv_data;
+ chop $csv_data;
+ $csv_data .= "\n";
+ return $c->render(text=>$csv_data);
} else {
$c->render(template=>"index", word=>$word, cutoff=>$cutoff, 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, dedupe=> $dedupe, marked=>\%marked, lists=> \@lists, collocators=> $res->{syntagmatic});
}