Provide API to get association scores for specific node collocate pairs
example:
$GET 'http://localhost:5673/getCollocationAssociation?w=triftigen&c=Grund'
{ "f1": 29164,"w1":"triftigen", "N": 53225832863, "collocates": [{"word":"Grund","f2":9868871,"f":5425,"npmi":0.286138,"pmi":7.3855,"llr":44929.5,"lfmd":32.1963,"md":19.7909,"dice":0.00108026,"ld":4.1456,"lncount":0,"rncount":5377,"lnpmi":-1,"rnpmi":9.95764,"af":4.16006,"win":286,"afwin":24}]}
diff --git a/derekovecs-server.c b/derekovecs-server.c
index 5b8915f..b2cdb20 100644
--- a/derekovecs-server.c
+++ b/derekovecs-server.c
@@ -538,6 +538,11 @@
return (strdup(buffer));
}
+char *getCollocationScores(long node, long collocate) {
+ char *res = (cdb ? strdup(get_collocation_scores_as_json(cdb, node, collocate)) : "[]");
+ return res;
+}
+
char *getClassicCollocators(long node) {
char *res = (cdb ? strdup(get_collocators_as_json(cdb, node)) : "[]");
return res;
diff --git a/derekovecs-server.pl b/derekovecs-server.pl
index 298d0e1..c24e32d 100755
--- a/derekovecs-server.pl
+++ b/derekovecs-server.pl
@@ -148,6 +148,11 @@
}
}
+sub getCollocationAssociation {
+ my ($c, $word, $collocate) = @_;
+ return getCollocationScores($word, $collocate)
+}
+
sub getClassicCollocatorsCached {
my ($c, $word) = @_;
my $s2 = "";
@@ -211,6 +216,16 @@
$self->render(json => $vec);
};
+any '*/getCollocationAssociation' => sub {
+ my $self = shift;
+ $self->render(data => getCollocationAssociation($self, getWord($self->param("w") ? $self->param("w") : $self->req->json), getWord($self->param("c"))), format=>'json');
+} => 'getCollocationAssociation';
+
+any '/getCollocationAssociation' => sub {
+ my $self = shift;
+ $self->render(data => getCollocationAssociation($self, getWord($self->param("w") ? $self->param("w") : $self->req->json), getWord($self->param("c"))), format=>'json');
+} => 'getCollocationAssociation1';
+
any '*/getClassicCollocators' => sub {
my $self = shift;
$self->render(data => getClassicCollocatorsCached($self, getWord($self->param("w") ? $self->param("w") : $self->req->json)), format=>'json');