Stuck on using Megam in Python (nltk.classify.MaxentClassifier)

I use Ubuntu x64, after two days and search the entire network, but I could not install Megam, I read all the information on this page http://www.cs.utah.edu/~hal/megam/ and installed the x64 version o ' calm with http://packages.ubuntu.com/precise/ocaml, but when I want to use "megam" as a classifier in python, it says:

"NLTK could not find the megammer file! Use the software settings for a specific configuration or set the MEGAM environment variable.

Can anyone tell me how I can install and use it in Python?

I downloaded " ocaml-3.12.1.tar.gz ", but the "make" command does not work (as readme says). I also downloaded " megam_i686.opt ", but it is not executable, and I can not run it

any help?

thanks in advance

+6
source share
5 answers

Use config_megam () to tell NLTK where the Megam executable is located. See http://nltk.googlecode.com/svn/trunk/doc/api/nltk.classify.megam-module.html for details and documentation.

You also need to create MEGAM with the correct 32/64 bit setting for your system. "megam_i686.opt" for x86 iirc, so you have to compile it for 64 bits. Some time has passed since I did this, but a simple build on the x64 system was all I needed: "Make does not work" is not very useful: I'm sure it gave you some error messages ... ? Perhaps the paths are not set or read-only?


Edit: It looks like the link is currently broken. The main Megam website can be found at:

http://www.umiacs.umd.edu/~hal/megam/

although it has not been updated for some time.

+2
source

For future users:

megam is now available on MAC via brew:

 $brew tap homebrew/science $brew install megam 
+9
source

The answer given by Hugh Perkins helped me solve the problem (because of the low reputation, you can not add a comment to this answer). After downloading the zip file (from http://thinknook.com/wp-content/uploads/2012/11/MEGAM.zip ) I needed to tell python where it was, and this was done by adding it to os. environ as:

os.environ ["MEGAM"] = '<<Full path followed by the file name β†’ / megam-64'

+2
source

I managed to run megam on my instance of docker running Debian 9.7 by following these steps. Based on the steps for MacOS, install the steps suggested by Jack Hong here .

  1. apt-get install make make
  2. apt-get install ocaml-nox (or apt-get install ocaml if you need x window support)
  3. download source from here
  4. unzip the source code by creating the megam_0.92 directory
  5. Edit the Makefile in megam_0.92 and make the following changes. (The first change has already been made in my particular case):
    • WITHCLIBS = -I / usr / local / lib / ocaml / caml
    • WITHSTR = str.cma -cclib -lcamlstr
  6. Save the changes and run make in your megam_0.92 directory.
  7. add nltk.config_megam ('//megam_0.92/megam') to your script and everything should be fine.
0
source

All Articles