w2v-server: simplify configuration via MOJO_CONFIG
diff --git a/w2v-server.pl b/w2v-server.pl
index 7d2bbdb..1b9e5ea 100755
--- a/w2v-server.pl
+++ b/w2v-server.pl
@@ -11,13 +11,19 @@
#use Mojo::Server::Daemon;
use Cwd;
-my $DEFAULT_VECS="/vol/work/kupietz/Work2/kl/trunk/Analysemethoden/word2vec/models/dereko-2020-ii-ALPHA.vecs";
-my $DEFAULT_NET = $DEFAULT_VECS;
-$DEFAULT_NET =~ s/\.vecs/.net/;
+my $mojo_config = $ENV{MOJO_CONFIG} // 'w2v-server.conf';
+plugin Config => {file => $mojo_config};
+
+my $DEFAULT_VECS = app->config->{w2v}->{vecs} // "/vol/work/kupietz/Work2/kl/trunk/Analysemethoden/word2vec/models/dereko-2020-ii.vecs";
+my $DEFAULT_NET_NAME = "";
+if ($DEFAULT_VECS=~ /\.vecs/) {
+ $DEFAULT_NET_NAME = $DEFAULT_VECS;
+ $DEFAULT_NET_NAME =~ s/\.vecs/.net/;
+}
+my $DEFAULT_NET = app->config->{w2v}->{net} // $DEFAULT_NET_NAME;
app->static->paths->[0] = getcwd;
-plugin Config => {file => 'w2v-server.conf'};
plugin 'Piwik';
plugin "RemoteAddr";
plugin 'Util::RandomString' => {
@@ -78,6 +84,10 @@
my $have_sprofiles = load_sprofiles($vecs_name);
+if (app->config->{w2v}->{merge}) {
+ $opt_m = app->config->{w2v}->{merge};
+}
+
if($opt_m) {
$mergedEnd = mergeVectors($opt_m);
$title = "<span class=\"merged\">" . $title . "</span> vs. " . fname2corpusname($opt_m);
@@ -102,6 +112,7 @@
if($opt_G) {
print "Filtering garbage\n";
filter_garbage();
+ print "Finished filtering garbage\n";
}
get '*/js/*' => sub {