Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Running a Perl module in Qt

Running a Perl module in Qt

Scheduled Pinned Locked Moved General and Desktop
21 Posts 4 Posters 14.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    magpielover
    wrote on 9 Jan 2012, 14:02 last edited by
    #11

    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.

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on 9 Jan 2012, 14:06 last edited by
      #12

      You run it inside the build directory. Read the whole sentence! Because it runs in a specific directory does not mean it runs everywhere.

      cd to /tmp and try to run your script again...

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • M Offline
        M Offline
        magpielover
        wrote on 9 Jan 2012, 14:14 last edited by
        #13

        @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");@

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on 9 Jan 2012, 14:24 last edited by
          #14

          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.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • M Offline
            M Offline
            magpielover
            wrote on 9 Jan 2012, 14:31 last edited by
            #15

            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?

            1 Reply Last reply
            0
            • G Offline
              G Offline
              goetz
              wrote on 9 Jan 2012, 14:40 last edited by
              #16

              [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++.

              http://www.catb.org/~esr/faqs/smart-questions.html

              1 Reply Last reply
              0
              • M Offline
                M Offline
                magpielover
                wrote on 9 Jan 2012, 14:50 last edited by
                #17

                I appreciate your effort. I'd better get familiar with perlembed.

                Thanks

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  goetz
                  wrote on 9 Jan 2012, 14:53 last edited by
                  #18

                  Despite using perlembed (which introduces another library) you should try to use the WordNet library directly, without using perl at all.

                  http://www.catb.org/~esr/faqs/smart-questions.html

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    magpielover
                    wrote on 9 Jan 2012, 15:08 last edited by
                    #19

                    [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

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      dangelog
                      wrote on 9 Jan 2012, 20:28 last edited by
                      #20

                      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.

                      Software Engineer
                      KDAB (UK) Ltd., a KDAB Group company

                      1 Reply Last reply
                      0
                      • V Offline
                        V Offline
                        vezprog
                        wrote on 10 Jan 2012, 13:34 last edited by
                        #21

                        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.

                        1 Reply Last reply
                        0

                        20/21

                        9 Jan 2012, 20:28

                        • Login

                        • Login or register to search.
                        20 out of 21
                        • First post
                          20/21
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved