1

I have this Perl script:

use strict;
use warnings;
use WordNet::QueryData;
use WordNet::Similarity::random;
use WordNet::Similarity::path;
use WordNet::Similarity::wup;
use WordNet::Similarity::lch;
use WordNet::Similarity::jcn;
use WordNet::Similarity::res;
use WordNet::Similarity::lin;
use WordNet::Similarity::hso;
use WordNet::Similarity::lesk;
use WordNet::Similarity::vector; 
use WordNet::Similarity::vector_pairs; 

#loading wordnet
my $wn = WordNet::QueryData->new;
my $path = WordNet::Similarity::path->new($wn, "config-files/config-path.conf");
my $value = $path->getRelatedness("eat#v#1", "play#v#1");
print "PATH Similarity = $value\n";

This script computes the path similarity between the two verbs (eat , play) using the Wordnet ontology.

I want to use this script inside my php code but I don't want to use exec(),system(),shell_exec() functions to call the perl script.

So my question: is there any way to use this perl script inside my php code directly?

VFX
  • 496
  • 4
  • 13
  • http://stackoverflow.com/questions/3438626/calling-perl-script-from-php-and-passing-in-variables-while-also-using-variabli --- http://stackoverflow.com/questions/455369/can-you-include-php-in-a-perl-file – Funk Forty Niner May 10 '17 at 15:13
  • Well, there is no production worthy solution that I can think of. But if you just want to fiddle with it, then configure apache to process .pl scripts with perl, and run curl requests to and from your script. – Dimi May 10 '17 at 15:14
  • Why don't you want to use any of those functions? – Barmar May 10 '17 at 15:48
  • [When you're ready to do the opposite ...](https://metacpan.org/pod/PHP) – mob May 10 '17 at 16:17
  • @mob FWIW: That module doesn't work with any modern version of PHP. –  May 10 '17 at 16:39
  • @Barmar Actually I want to compute the similarity for a big number of word pairs, so if I used those functions there will be too much I/O traffic between php side and Perl side and that's taking too much time (13 seconds for 2000 pairs) – VFX May 10 '17 at 18:02
  • 3
    Are you sure communication is the bottleneck? Maybe you're not doing it efficiently. Are you restarting the script for each pair? You could start the perl script as a coprocess, send word pairs to it through a pipe, and receive the responses through another pipe. Make sure you disable buffering to prevent deadlock. – Barmar May 10 '17 at 18:15

0 Answers0