Fix getVecsByRanks, used by the collocator SOM
getVecs was never exported, so POST /derekovecs/getVecsByRanks answered every
request with "Undefined subroutine &main::getVecs" and the collocator SOM
never got its vectors.
The route also only existed with the /derekovecs prefix, while the frontend
derives its base url from the current path, so it could not be reached at all
for instances served from the root. Added the prefix independent route like the
other web service functions have.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Change-Id: I983b2a34f75892c2302861a0219e4614ffb1d4c9
diff --git a/lib/IDS/DeReKoVecs/Read.pm b/lib/IDS/DeReKoVecs/Read.pm
index fffa9e5..0da0cf4 100644
--- a/lib/IDS/DeReKoVecs/Read.pm
+++ b/lib/IDS/DeReKoVecs/Read.pm
@@ -31,7 +31,7 @@
use Mojo::Cache;
use Exporter qw(import);
-our @EXPORT = qw(init_net load_sprofiles getVocabSize getDowntimeCalendar getCollocationAssociation getClassicCollocatorsCached getSimilarProfiles getSimilarProfilesCached getBiggestMergedDifferences filter_garbage get_neighbours getWordNumber dump_vecs dump_for_numpy cos_similarity_as_json get_version getPosWiseW2VCollocators configure_cache cache_stats);
+our @EXPORT = qw(init_net load_sprofiles getVocabSize getDowntimeCalendar getCollocationAssociation getClassicCollocatorsCached getSimilarProfiles getSimilarProfilesCached getBiggestMergedDifferences filter_garbage get_neighbours getVecs getWordNumber dump_vecs dump_for_numpy cos_similarity_as_json get_version getPosWiseW2VCollocators configure_cache cache_stats);
my $cccache = Mojo::Cache->new(max_keys => $CC_CACHE_MAX_KEYS); # classic collocator cache
my $spcache = Mojo::Cache->new(max_keys => $SP_CACHE_MAX_KEYS); # similar profile cache
diff --git a/script/derekovecs-server b/script/derekovecs-server
index b15341e..613a37b 100755
--- a/script/derekovecs-server
+++ b/script/derekovecs-server
@@ -180,7 +180,13 @@
}
-post '/derekovecs/getVecsByRanks' => sub {
+post '*/getVecsByRanks' => sub {
+ my $self = shift;
+ my $vec = getVecs($self->req->json);
+ $self->render(json => $vec);
+};
+
+post '/getVecsByRanks' => sub {
my $self = shift;
my $vec = getVecs($self->req->json);
$self->render(json => $vec);