light-blue
light-blue

Reputation: 254

stuck in using Megam in Python ( nltk.classify.MaxentClassifier)

I'm using ubuntu x64, after two days and searching all the net, still i've not been able to install Megam, i've read all information in this page http://www.cs.utah.edu/~hal/megam/ and installed x64 version of o'calm from http://packages.ubuntu.com/precise/ocaml but when i want to use "megam" as a classifier in python, it says:

"NLTK was unable to find the megam file! Use software specific configuration paramaters or set the MEGAM environment variable.

could anybody tell me how can i install and make use of it in python?

i've downloaded "ocaml-3.12.1.tar.gz" but the "make" command doesn't work (as it's said in its readme). i've downloaded "megam_i686.opt" too, but it's not executable and i cannot run it

any help?

thanks in advance

Upvotes: 6

Views: 3829

Answers (5)

Maciej
Maciej

Reputation: 2185

I manged to get megam to run on my docker instance running debian 9.7 following the steps below. Based on steps for MacOS install steps suggested by Jack Hong here.

  1. apt-get install make
  2. apt-get install ocaml-nox (or apt-get install ocaml, if you want x window support)
  3. download source from here
  4. unzip source creating a megam_0.92 directory
  5. Edit the Makefile in megam_0.92 and make the following changes. (The first change was already done in my particular instance):
    • WITHCLIBS=-I /usr/local/lib/ocaml/caml
    • WITHSTR =str.cma -cclib -lcamlstr
  6. Save the changes and run make inside your megam_0.92 directory
  7. add nltk.config_megam('//megam_0.92/megam') to your script and all should be well.

Upvotes: 0

user1953366
user1953366

Reputation: 1611

Answer given by Hugh Perkins, helped me resolve the issue (due to low reputation can't add a comment to that 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 that was done by adding it in os.environ as:

os.environ["MEGAM"] = '<<Complete path followed by file name>>/megam-64'

Upvotes: 2

Hugh Perkins
Hugh Perkins

Reputation: 8622

I downloaded from http://thinknook.com/wp-content/uploads/2012/11/MEGAM.zip , which was linked from http://thinknook.com/nltk-megam-maximum-entropy-library-on-64-bit-linux-2012-11-27/ This worked ok for me, on ubuntu 14.04

Upvotes: 0

winwaed
winwaed

Reputation: 7801

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 build MEGAM with the right 32/64 bit setting for your system. "megam_i686.opt" is for x86 iirc, so you should compile it for 64 bit. It is a while since I did this, but a simple build on an x64 system was all I needed: "Make doesn't work" is not very useful: I'm sure it gave you a few error messages...? Probably paths not set or are read only?


Edit: Looks like the above link is currently broken. The main Megam site can be found at:

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

although it hasn't been updated for a while.

Upvotes: 2

pg2455
pg2455

Reputation: 5168

For the future users:

megam is now available on MAC through brew:

$brew tap homebrew/science
$brew install megam

Upvotes: 9

Related Questions