Running a Perl module in Qt
-
I would say you need to actually install the perl module. calling
@
make install
@usually is sufficient.
I'm pretty sure, your program does not work if you call if from the command line outside its build directory as it will be unable to finde the module then too.
You can try to add a perl library path to the command line:
@
perl -I /home/path/lib script.pl
@ -
bq. I would say you need to actually install the perl module. calling
Actually I have already installed the module and am able to run it on terminal
Here are the command I used when I ran it on terminal and outcome.@kirbac@ubuntu:~/Desktop/WordNet-Similarity-2.05$ perl samples/sample.pl vehicle#n#1 car#n#1 Loading WordNet... done.
Creating jcn object... done.
Creating res object... done.
Creating lin object... done.
Creating wup object... done.
Creating lch object... done.
Creating hso object... done.
Creating path object... done.
Creating random object... done.
Creating lesk object... done.
Creating vector object... done.
Creating vector_pairs object... done.
JCN Similarity = 0.679238561464479
RES Similarity = 5.5313491229262
LIN Similarity = 0.882549308265133
WUP Similarity = 0.818181818181818
LCH Similarity = 2.07944154167984
HSO Similarity = 4
@I think I am calling it from the command line outside its build directory. I am kinda puzzled here.
-
@kirbac@ubuntu:~/Desktop/Alternative$ perl /home/kirbac/Desktop/Dene-build-desktop-Desktop_Qt_4_7_4_for_GCC__Qt_SDK__Release/sample.pl banana#n#1 apple#n#1
Loading WordNet... done.
Creating jcn object... done.
Creating res object... done.
Creating lin object... done.
Creating wup object... done.
Creating lch object... done.
Creating hso object... done.
Creating path object... done.
Creating random object... done.
Creating lesk object... done.
Creating vector object... done.
Creating vector_pairs object... done.
JCN Similarity = 0.0480946368308077
RES Similarity = 1.36959027657875
LIN Similarity = 0.1164047451416
WUP Similarity = 0.434782608695652
LCH Similarity = 1.04982212449868
HSO Similarity = 2@
I created an alternative folder and I can run it again.
I am curious about the exact command the below generates.
@
QProcess perl;
perl.start("perl /home/kirbac/Desktop/WordNet-Similarity-2.05/samples/sample.pl vehicle#n#1 car#n#1");@ -
Doesn't look like a Qt problem - something with calling the perl script is screwed up. Most probably some environment variables or the wrong perl interpreter running the script. Try to use the full path to a perl interpreter. Or check the version of "perl -v" of the QProcess.
-
I agree with you not being a Qt problem. I believe what Qt is capable of and that's why I am trying to find a solution. It's so awkward. Everything seems to be normal.
I also suspect that I am missing qmake variables.
Here is the last question before I fall into despair and give up.Which variables would you use in the project file?
-
[quote author="magpielover" date="1326119505"
Which variables would you use in the project file?
[/quote]NONE! Your project builds and runs just fine! The only problem you have is how to setup the command line for the perl interpreter. There's nothing in a .pro file that can you help here.
The state of affairs is quite clear:
Perl shows you the include paths, and it cannot find the requested module in there. Go to that directories and check manually. Check that the version of perl called by QProcess is the same as on the command line (depending on the PATH env variable this can differ!). Add the installation directory using -I switch. Ask some Perl gurus...As a last resort, use the WordNet libraries directly, it seems to be standard C or C++.
-
I appreciate your effort. I'd better get familiar with perlembed.
Thanks
-
[quote author="Volker" date="1326120811"]Despite using perlembed (which introduces another library) you should try to use the WordNet library directly, without using perl at all. [/quote]
English lexical database WordNet written in C has nothing to do with similarity measurement algorithms. In WordNet database Nouns, verbs, adjectives and adverbs are grouped into sets of cognitive synonyms (synsets), each expressing a distinct concept. Synsets are interlinked by means of conceptual-semantic and lexical relations.
However, there exist some algorithms which use WordNet tools to measure the semantic relatedness. The module I have been struggling with is a Perl module that implements a variety of semantic similarity and relatedness measures based on information found in the lexical database WordNet. In particular, it supports the measures of Resnik, Lin, Jiang-Conrath, Leacock-Chodorow, Hirst-St.Onge, Wu-Palmer, Banerjee-Pedersen, and Patwardhan-Pedersen.
Therefore, I cannot use WordNet C code directly for my purpose. I need the implementation of the algorithms I mentioned above.
I will try to implement the algorithms myself in C++ and release the code for people's good.
Thanks -
I would simply avoid embedding the Perl interpreter. It's much more complicated than simply running the perl interpreter.
Just double check that the working directory is the same, the env variables are the same, etcetera. You need to gain some knowledge about how Perl finds its modules. Read perldoc perlmod, perldoc -f require, perldoc -f use.
-
I've used QProcess to access external applications on my linux box multiple times without flaw. I also had issues like you are having right now being that I could run the application on the command line with no errors, and then I tried using QProcess and had issues all around.
My solution was following the exact example on the QProcess page using the argument string lists, checking for errors, and all that jazz.
For example (right from the QProcess documentation)
@
QObject *parent;
...
QString program = "./path/to/Qt/examples/widgets/analogclock";
QStringList arguments;
arguments << "-style" << "motif";QProcess *myProcess = new QProcess(parent);
myProcess->start(program, arguments);
@Just a thought though. Here's the docs if you haven't already been there. http://developer.qt.nokia.com/doc/qt-4.8/qprocess.html
I think when I was having issues, the QProcess line recognized some characters differently then what the command line does. So an argument string list was absolutely required for my case. Also, put ' ' around your arguments as well.
Best of luck.