NLTK was unable to find megam

2,089 views
Skip to first unread message

Ruud van Houtum

unread,
Mar 18, 2013, 11:25:48 AM3/18/13
to nltk-...@googlegroups.com
Hello everybody!

Currently I am working to extract structured data/ tables from text files and while reading the book I stumbled on the chunker chapter.
I am not sure if this is the best method for extraction tables but it seems to be the only available resource concerning this.

I am trying to train a classifier-based chunker (just following the example in the book) but when compiling it gives me the following error:

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

  For more information, on megam, see:
    <http://www.cs.utah.edu/~hal/megam/>
===========================================================================

I have been looking online for a solution but I can't really find anything that is not outdated. I found this website thou: http://takahashifumiki.com/web/programing/1992/ which is in Japanese.
I think I will be able to manage to go through and read whatever is needed, however I am not sure if this is the prober way / updated solution.

A few post on this group have been posted in the past in regards to megam aswel, but they don't seem to apply anymore either.
One reason for this is that the http://www.cs.utah.edu/~hal/megam/ is offline.

Any advice would be greatly appreciated,
Thanks.


George Orton

unread,
Mar 18, 2013, 12:01:00 PM3/18/13
to nltk-...@googlegroups.com
Hi Ruud, I recently put a lot of effort into trying to install megam on my system for use with a classifier. Unfortunately I was never able to get megam to install correctly. Even getting to the point I did was very convoluted. I have copied the correspondence I had with different people as I tried to work through this problem and attached it to this post. If you are willing to work through all of this you may have better luck than I had. Because I did not have a specific need for megam I ended up just using the NaiveBayesClassifier. Good Luck, George

1)Hello, I am attempting to use the megam algorithm with the Maxent Classifier. When I try to use the command self.classifier = nltk.MaxentClassifier.train( train_set, algorithm='megam', trace = 0) I get the following error:

>>> 

Traceback (most recent call last):
  File "/Users/George Orton/text_proc_7.py", line 124, in <module>
    chunker = ConsecutiveNPChunker(train_sents)
  File "/Users/George Orton/text_proc_7.py", line 112, in __init__
    self.tagger = ConsecutiveNPChunkTagger(tagged_sents)
  File "/Users/George Orton/text_proc_7.py", line 97, in __init__
    train_set, algorithm='megam', trace=0)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/classify/maxent.py", line 315, in train
    gaussian_prior_sigma, **cutoffs)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/classify/maxent.py", line 1518, in train_maxent_classifier_with_megam
    stdout = call_megam(options)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/classify/megam.py", line 163, in call_megam
    config_megam()
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/classify/megam.py", line 59, in config_megam
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/internals.py", line 528, in find_binary
    url, verbose)
  File "/Library/Frameworks/Python.framework/Versions/7.3/lib/python2.7/site-packages/nltk/internals.py", line 512, in find_file
    raise LookupError('\n\n%s\n%s\n%s' % (div, msg, div))
LookupError: 

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

  For more information, on megam, see:
===========================================================================
>>> 

To try and resolve this I did a web search on installing megam and found: 

MegaM: http://hal3.name/megam/megam_src.tgz (requires ocaml; edit Makefile to setWITHCLIBS to point to location of ocaml .h files; locate these using macports withport contents ocaml, install megam binary, e.g. to /usr/local/bin and setMEGAMHOME to point to this directory).

I then downloaded megam and tried again but got the same error message. Because these direction say that ocaml is required and that I must edit Makefile to set WITHCLIBS to point to the location of ocaml .h files I typed port contents ocaml at the terminal prompt and got:

george-ortons-macbook-pro:~ George Orton$ port contents ocaml
Warning: port definitions are more than two weeks old, consider using selfupdate
Port ocaml is not installed.

What I'm hoping is that someone can help me with this megam installation. Am I correct in assuming that ocaml is a programming language that I must first install in order to use megam? Any help with this megam installation process would be appreciated. Thanks, George

2) Hi George,

First you need to install OCaml, then build MegaM from source. See also:

-Steven Bird

3) Hi Steven, Thank you for your response. I will try to document the process I go through as I install megam. In hopes of providing a reference for future questions about megam installation. Sincerely, George

4) Hello, In my ongoing quest to install MegaM I have installed OCaml. I downloaded OCaml from "http://caml.inria.fr/download.en.html" and then installed it. According to the information I obtained from a web search I must next "edit Makefile to set WITHCLIBS to point to location of ocaml .h files; locate these using macports with "port contents ocaml"". So first I typed in port contents ocaml at the Terminal prompt. I got an error message saying:

george-ortons-macbook-pro:~ George Orton$ port contents ocaml
Port ocaml is not installed.

So next I used finder ( I am on a Mac) to try and locate any ocaml.h files but was unable to locate any, there are lots of ocaml files on my system but none that are .h (at least none that I could find). I installed OCaml after downloading it so it's not clear to me why I am getting the not installed message when using Macports. If anybody has any ideas on how to proceed from here I would appreciate the help. I know this is not specifically an nltk question, but since I only wish to use MegaM in conjunction with nltk I am posting in this forum. Sincerely, George

5) Hi George,

Macports only knows about software that was installed using macports. Since you didn't use macports to install ocaml, you can't use macports to tell you where it is installed. You could look at the ocaml makefile to see where it installs ocaml. Or you could reinstall ocaml using macports (sudo port install ocaml). Or you could re-try searching for the ocaml install location using your finder (since it may have re-indexed your hard drive by now).

-Steven Bird

6) Hi George,

If megam is troublesome to install on your platform, you may prefer to use the MaxEnt classifier that is bundled with NLTK. While a little slower in many situations, it is also ample, runs natively in Python and suitable for a wide range of experimental purposes. It may be worth using this to conduct your experiments before investing (a potentially long) time coaxing megam into running on your platform. Good luck either way!

All the best,


Leon

7) Caveat: I have had a hard time using the NLTK MaxEnt classifier for any but the most trivial problems.

Training for a classifier-based POS tagger took ~30minutes with MegaM[1], but never convered with the NLTK classifier. By "never" I mean I gave up after >10hrs with all 8 cores of my Macbook slammed.

[1] I.e. I have successfully installed MegaM on my MBP, OSX 10.7...I *may* have documented the process, if so, I'll report here ASAP.

8) Hi Steven, Leon & Fred, Thank you for your responses. Fred, if by chance you documented the process of successfully loading MegaM onto you MBP I would greatly appreciate your posting the process here. Steven I decided to try your suggestion and reinstall ocaml using Macports. Unfortunately I received an error message:

george-ortons-macbook-pro:~ George Orton$ sudo port install ocaml
Password:
Error: Unable to open port: can't read "build.cmd": Failed to locate 'make' in path: '/opt/local/bin:/opt/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin' or at its MacPorts configuration time location, did you move it?

I'm not sure what this error means, my best guess is that the macports install of ocaml is faulty. Perhaps macports is unable to install ocaml because I have already installed ocaml without using macports and I would need to uninstall ocaml before attempting a macports ocaml install. Because I was unsuccessful with the macports install I decided to try and edit megam's Makefile to set WITHCLIBS to the location of the ocaml .h files. This is per the instructions I originally found doing an internet search. The problem with this is that I'm not sure what exactly an ocaml .h file is. When I look up ocaml in Finder I find 470 different files and folders none of which end in .h. What I decided to try was taking the path to the folder labeled ocaml and using that as the location to set the WITHCLIBS location. Here is what my original WITHCLIBS location read:

WITHCLIBS =-I /usr/lib/ocaml/caml

and here is what I changed it to:

WITHCLIBS =-I /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang

I found it odd that the path listed macports since my macports install failed, but I wasn't sure what else to try. Unfortunately this Makefile edit did not solve the problem. When I ran my original self.classifier = nltk.MaxentClassifier.train( train_set, algorithm='megam', trace = 0) code ( I am running the code from chapter 7, page 275 of the Natural Language Processing with Python text) I got the same error message I originally encountered:

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

Clearly, the Makefile edit I tried is not correct. In reading the MegaM documentation I read about the nltk.config_megam("path to megam")  command. So I also tried putting that in my code. Unfortunately that also gave an error message:

NLTK was unable to find the /Users/George Orton/Downloads file!
Use software specific configuration paramaters or set the MEGAM environment variable.

To proceed from this point I think I need to know which file is being referenced in the directions which say edit the Makefile file with the location of the ocaml .h file. Which of the 470 ocaml files/folders is the ocaml .h file. I am also not clear on whether I need to use the nltk.config_megam("path to megam")  command when attempting to use the megam algorithm with the Maxent Classifier. If anybody has any thoughts on how to proceed from here I would greatly appreciate the input. Sincerely, George

9) I also gave up installing MegaM (using ocaml from homebrew); editing the makefile didn't help me either :) 

Classifiers in scikit-learn are really good and efficient; there is LogisticRegression classifier - see http://scikit-learn.org/dev/modules/generated/sklearn.linear_model.LogisticRegression.html#sklearn.linear_model.LogisticRegression and  http://scikit-learn.org/dev/modules/linear_model.html#logistic-regression . You can use it directly or through a NLTK compat layer (see https://github.com/nltk/nltk/blob/master/nltk/classify/scikitlearn.py ) 

10) Hello, I am still working on trying to get MegaM to work with the Maxent Classifier. I decided to try reinstalling ocaml to see if the install directories would be listed during the install process. It turns out the directory path was listed. The command line executables are all installed in /usr/local/bin. Armed with this information I went into megam's Makefile file and edited the WITHCLIBS line to show this path. I then ran my code and unfortunately got the same error message as before. 

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

Based on this error message I am beginning to think that it is not the WITHCLIBS setting inside megam's Makefile file that is causing the problem but the nltk specific command:

nltk.config_megam('.../path/to/megam')

which is causing the problem. I have tried adding this command to my code and I get a similar but different error message. Here is my version of the config_megam:

nltk.config_megam("/Users/George Orton/Downloads/megam_0.92")

and here is the error message I get when I run my code with this command included:

NLTK was unable to find the /Users/George Orton/Downloads/megam_0.92 file!
Use software specific configuration paramaters or set the MEGAM environment variable.

From this error message I believe that perhaps the path I am supposed to use in the config_megam command is supposed to be one of the files inside the megam folder rather than the path to the megam folder itself. So, I am wondering if anybody has any experience with this particular config_megam command and knows what '.../path/to/megam' should be? In the interim I changed the classifier from the Maxent to the NaiveBayes classifier in order to continue working through the concept presented in the Natural Language Processing with Python text where this question arose. Sincerely, George

11) Hi there,

Are you still trying to get this working? Have you successfully compiled megam at all?

Fred.

12) Hi Fred, I have stopped actively working on getting MegaM to work. I would still like to use MegaM but I have been unable to get beyond the issues I wrote about in my previous posts. I believe I have been able to compile MegaM, I have performed an install from the file I downloaded at  http://hal3.name/megam/megam_src.tgz. Unfortunately I'm not sure where to proceed from here so I have just continued to use the NaiveBayes classifier. If you have any thoughts on how to proceed I would appreciate you input. Sincerely, George

13) Hi George,

Just to be clear: you unzipped that file, and built the project (by typing "make" or "make opt" in a terminal window) without any errors? If so, where are the binary files ("megam" or "megam.opt") located on your machine?

14) Hi Fred, I did unzip the file but I didn't build it. I didn't realize that was necessary. I suppose that would be why I can't seem to find the location of the binary files. Would you please tell me the full "make" command I would need to type in Terminal to build the project. Thanks, George

15) If you look at the contents of the README file, it should have all the information you need. In principle, you should be able to simply type "make" and it will build the megam binary. If there are errors, let me know and we'll see what's needed to get you further along.

Before you do that, though, do you have OCaml installed on your machine? Megam is written in the OCaml programming language and you need OCaml installed to be able to compile it.

I'm working right now, so my answers won't always come this quickly, just so you know.

Thanks,
Fred.

16) Hi Fred, Thanks for your help. I believe I have OCaml installed on my machine. I went to the Ocaml website, downloaded the file and then installed it, however I am not familiar with OCaml so I hope I didn't miss a step. Thank you for letting me know about the read me file. I'll look at it tomorrow morning and follow it's instructions. I'll let you know my results. Don't work too hard. Sincerely, george

17) Good Morning Fred, I read the Readme file in megam. Unfortunately when I ran make at the terminal prompt I got an error message saying:

george-ortons-macbook-pro:~ George Orton$ make
-bash: make: command not found

Since I was in my root directory when I ran the "make" command I though that perhaps for "make" to work I need to change to my megam directory. After changing to the megam directory I re-ran the "make" command. Unfortunately I got the same error message.

george-ortons-macbook-pro:megam_0.92 George Orton$ make
-bash: make: command not found

Is this perhaps an indication that Ocaml is not fully installed? I downloaded Ocaml previously and went through it's install process. I have several Ocaml folders on my system, but since I've never used Ocaml I'm really not sure how to determine if it is properly configured. Any suggestions you have would be greatly appreciated. Sincerely, George

18) Hi George...

"make" is a general tool that reads "makefiles" (you'll see one of those in the megam directory) and executes the commands in them. It looks as if you don't have make installed, which in turn means that you probably don't have any of the Mac development tools installed (which you're going to need if you want to start getting more seriously into some of these packages).

First step, then, is to install the Mac Developer Tools:

https://itunes.apple.com/us/app/xcode/id497799835?ls=1&mt=12

once you have that installed, install one of the binary OCaml package for Mac:

http://caml.inria.fr/pub/old_caml_site/caml-macosx-howto/index.html

THEN you can go back and try to build megam.

Let me know how far you get...


Cheers,
F.

19) Hi Fred, Boy this sure is fun. I installed X Code without any difficulties. I went to the OCaml link you provided and downloaded OCaml. However when I tried to install OCaml I got an error message indicating that the disk image was damaged and should be ejected. However, when I first started this odyssey I visited http://caml.inria.fr/download.en.html and successfully downloaded and installed OCaml 4.00.1. So I believe I have a working version of OCaml on my system. However when I go to Terminal to try and build MegaM I still get the same error message:
george-ortons-macbook-pro:~ George Orton$ make
-bash: make: command not found
george-ortons-macbook-pro:~ George Orton$ 

Do I perhaps need to enter into Xcode from terminal before I execute the "make" command, similar to entering Python at Terminal? Is there a simple way to verify that OCaml is up and running on my system? Thanks for all your help. Sincerely, George

20) Hi George.

1) even if you have OCaml properly installed, you'll still need "make" in order to build Megam, but we'll start by checking that anyway. Open a Terminal and type "ocaml" at the prompt. If you have OCaml installed, you should get dropped into the OCaml read-eval-print loop...it'll look something like this:

user@host:~ $ ocaml
        OCaml version 4.00.0



(type Ctrl-D to exit)

If that didn't happen, then OCaml isn't installed properly.

2) Hmm...if XCode installed properly, you really should have make available from the command-line. Let's try the following...open a Terminal and type the following:

$ sudo /usr/libexec/locate.updatedb
[N.B. you'll need to enter your administrator password]
[N.B...this may run for several minutes]

$ which make

The second command should display a path to make somewhere on your system. If nothing shows up, then you'll need to double-check that XCode did, in fact, install properly, and if so, then start by Googling "install make on Mac OSX" and see what comes up.

Once you know for sure that OCaml and make are on your system, we'll be able to start tackling actually building Megam.


Cheers,
Fred.

21) Hi Fred, It turns out I have both OCaml and Xcode installed properly. When I type ocaml at the Terminal prompt I get the OCaml heading and prompt just as you described. If I go into Finder and double click Xcode then the Xcode user interface pulls up without any problems. I did as you suggested and typed in sudo /usr/libexec/locate.updatedb at the terminal prompt. The locate program ran for a few minutes and then retuned me to the terminal prompt. I then typed "which make" and was not rewarded with a path name but just a return to my standard terminal prompt. Here is my terminal output as I worked through this process:

Last login: Fri Jan 18 20:48:58 on ttys000
george-ortons-macbook-pro:~ George Orton$ ocaml
        OCaml version 4.00.1

# ^D
george-ortons-macbook-pro:~ George Orton$ sudo /usr/libexec/locate.updatedb
Password:
george-ortons-macbook-pro:~ George Orton$ which make
george-ortons-macbook-pro:~ George Orton$ 

After going through this procedure I double checked that Xcode was installed and it was. I even created a dummy project using one of the standard templates just to be sure. I then tried doing an internet search on "install make on Mac OSX" and didn't find anything except that to get make you have to install Xcode. It would appear that make is not resident in the version of Xcode I just installed. Is there a way to check and see if make is present in Xcode? Thank you for your ongoing help. Sincerely, George

22) Hi Fred, I found the problem. It turns out that make is an optional install in the latest version of Xcode. In order to install "make" it is necessary to open Xcode and got to Xcode- >Preferences- >Downloads and install the component named command line tools. Once installed I opened Terminal and typed make -v to see if make was present and was rewarded with the version of make that is now present on my system.

george-ortons-macbook-pro:~ George Orton$ make -v
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0

Next I tried typing make at the Terminal prompt but I received the following message:

george-ortons-macbook-pro:~ George Orton$ make
make: *** No targets specified and no makefile found.  Stop.
george-ortons-macbook-pro:~ George Orton$ 

Then I tried typing make megam and I got the following error message:

george-ortons-macbook-pro:~ George Orton$ make megam
make: *** No rule to make target `megam'.  Stop.
george-ortons-macbook-pro:~ George Orton$ 

This is definitely closer to the solution. Now it seems the question becomes what is the proper syntax necessary to tell make to build megam. Sincerely, George

23) Hi George,

This is good progress! Now just cd into the megam directory and type "make" and you should be good to go...(barring any compilation errors, of course).

F.


24) Hi Fred, I cd'd into my megam directory and typed make. Unfortunately the result is somewhat ambiguous. Here is the terminal output, it appears to fail but I'm not sure:

george-ortons-macbook-pro:megam_0.92 George Orton$ make
ocamldep *.mli *.ml > .depend
ocamlc -g -custom  -o megam str.cma -cclib -lstr bigarray.cma -cclib -lbigarray unix.cma -cclib -lunix -I /usr/local/bin fastdot_c.c fastdot.cmo intHashtbl.cmo arry.cmo util.cmo data.cmo bitvec.cmo cg.cmo wsemlm.cmo bfgs.cmo pa.cmo perceptron.cmo radapt.cmo kernelmap.cmo abffs.cmo main.cmo
fastdot_c.c:4:19: error: alloc.h: No such file or directory
fastdot_c.c:5:22: error: bigarray.h: No such file or directory
fastdot_c.c:6:20: error: custom.h: No such file or directory
fastdot_c.c:7:18: error: fail.h: No such file or directory
fastdot_c.c:8:20: error: intext.h: No such file or directory
fastdot_c.c:10:22: error: mlvalues.h: No such file or directory
fastdot_c.c:14: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_mult_dense_sparse’
fastdot_c.c:35: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_mult_dense_sparse_val’
fastdot_c.c:67: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_norm_dense’
fastdot_c.c:82: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_mult_dense_dense’
fastdot_c.c:99: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_mult_dense’
fastdot_c.c:114: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_add_dense_dense’
fastdot_c.c:135: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_add_dense_sparse’
fastdot_c.c:155: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘c_add_dense_sparse_val’
make: *** [megam] Error 2
george-ortons-macbook-pro:megam_0.92 George Orton$ 

When I look in my megam directory in Finder I find several new files have been created, so something definitely happened. However when I try to run my nltk code I get the same error message I have been getting all along saying that the megam file cannot be found. When I first posted this question on the nltk forum Steven Bird pointed out a link that seems to be similar to what I experienced when building megam. This is the link:

The pertinent portion of the post seems to be:

An update: Hal Daume III (creator of MegaM) wrote me 10 Jan, advising 
me to change the WITHSTR line in Makefile so that it points to str.cma 

Similar to what we are instructed to do for WCLIBS and caml. 

Then you do the same for WITHUNIX and unix.cma, and WITHBIGARRAY and 
bigarray.cma 

I've already changed the WITHCLIBS line in megams Makefile to point to ocaml. "WITHCLIBS =-I /usr/local/bin" . At least I think this is correct, when I installed ocaml the dialogue box indicated that the ocaml command line executables were going to be installed in this location. 

This is a copy of my current megam makefile:

# Usage of this Makefile:
# To incrementally recompile the system, type
#     make
# To recompute dependancies between modules, type
#     make depend
# To remove the executable and all the compiled files, type
#     make clean
# To compile using the native code compiler
#     make opt
#
##################################################################

EXEC = megam

# If you need special libraries provided with the Caml system,
# (graphics, arbitrary precision numbers, regular expression on strings, ...),
# you must set the variable LIBS to the proper set of libraries. For
# instance, to use the graphics library set LIBS to $(WITHGRAPHICS):
LIBS=$(WITHSTR) $(WITHBIGARRAY) $(WITHUNIX) $(WITHCLIBS)

# You may use any of the following predefined variable
# WITHGRAPHICS : provides the graphics library
# WITHUNIX : provides the Unix interface library
# WITHSTR : provides the regular expression string manipulation library
# WITHNUMS : provides the arbitrary precision arithmetic package
# WITHTHREADS : provides the byte-code threads library
# WITHDBM : provides the Data Base Manager library
#
#
########################## End of Documentation ####################



########################## User's variables #####################
#
# The Caml sources (including camlyacc and camllex source files)


########################## Advanced user's variables #####################
#
# The Caml compilers. #
# You may fix here the path to access the Caml compiler on your machine
CAMLC = ocamlc -g
CAMLOPT = ocamlopt -unsafe -ccopt -O4 -ccopt -ffast-math -inline 99999 
CAMLDEP = ocamldep
CAMLLEX = ocamllex
CAMLYACC = ocamlyacc

# Should be set to -custom if you use any of the libraries above
# or if any C code have to be linked with your program
# (irrelevant for ocamlopt)

CUSTOM=-custom 

# Default setting of the WITH* variables. Should be changed if your
# local libraries are not found by the compiler.
WITHGRAPHICS =graphics.cma -cclib -lgraphics -cclib -L/usr/X11R6/lib -cclib -lX11

WITHUNIX =unix.cma -cclib -lunix

WITHSTR =str.cma -cclib -lstr

WITHBIGARRAY =bigarray.cma -cclib -lbigarray

WITHNUMS =nums.cma -cclib -lnums

WITHTHREADS =threads.cma -cclib -lthreads

WITHDBM =dbm.cma -cclib -lmldbm -cclib -lndbm

#WITHCLIBS =-I /usr/lib/ocaml/3.09.2/caml
#WITHCLIBS =-I /usr/lib/ocaml/caml
#WITHCLIBS =-I /opt/local/var/macports/sources/rsync.macports.org/release/ports/lang/ocaml
WITHCLIBS =-I /usr/local/bin

################ End of user's variables #####################


##############################################################
################ This part should be generic
################ Nothing to set up or fix here
##############################################################

all: depend $(EXEC)

opt : $(EXEC).opt

#ocamlc -custom other options graphics.cma other files -cclib -lgraphics -cclib -lX11
#ocamlc -thread -custom other options threads.cma other files -cclib -lthreads
#ocamlc -custom other options str.cma other files -cclib -lstr
#ocamlc -custom other options nums.cma other files -cclib -lnums
#ocamlc -custom other options unix.cma other files -cclib -lunix
#ocamlc -custom other options dbm.cma other files -cclib -lmldbm -cclib -lndbm

SOURCES1 = $(SOURCES:.mly=.ml)
SOURCES2 = $(SOURCES1:.mll=.ml)
OBJS = $(SOURCES2:.ml=.cmo)
OPTOBJS = $(SOURCES2:.ml=.cmx)

$(EXEC): $(OBJS)
$(CAMLC) $(CUSTOM) -o $(EXEC) $(LIBS) $(OBJS)

$(EXEC).opt: $(OPTOBJS)
$(CAMLOPT) -o $(EXEC).opt $(LIBS:.cma=.cmxa) $(OPTOBJS)

.SUFFIXES:
.SUFFIXES: .ml .mli .cmo .cmi .cmx .mll .mly

.ml.cmo:
$(CAMLC) -c $<

.mli.cmi:
$(CAMLC) -c $<

.ml.cmx:
$(CAMLOPT) -c $<

.mll.cmo:
$(CAMLLEX) $<
$(CAMLC) -c $*.ml

.mll.cmx:
$(CAMLLEX) $<
$(CAMLOPT) -c $*.ml

.mly.cmo:
$(CAMLYACC) $<
$(CAMLC) -c $*.mli
$(CAMLC) -c $*.ml

.mly.cmx:
$(CAMLYACC) $<
$(CAMLOPT) -c $*.mli
$(CAMLOPT) -c $*.ml

.mly.cmi:
$(CAMLYACC) $<
$(CAMLC) -c $*.mli

$(CAMLLEX) $<

$(CAMLYACC) $<

clean:
rm -f *.cm[iox] *~ .*~ #*#
rm -f $(EXEC)
rm -f $(EXEC).opt

.depend: $(SOURCES2)
$(CAMLDEP) *.mli *.ml > .depend

depend: $(SOURCES2)
$(CAMLDEP) *.mli *.ml > .depend

include .depend



It appears to me that the suggestions listed in the post that Steven referenced are already in place in my megam makefile. At this point my best guess is that I have a failed megam build on my system but I really don't know how to check megam functionality other than to run it in my existing nltk code, which as I said earlier can't seem to find megam. Do you know of a way independent of nltk that can be used to check for a successful megam build? Thanks, George

Ruud van Houtum

unread,
Mar 18, 2013, 12:25:46 PM3/18/13
to nltk-...@googlegroups.com
Thank you for your swift and thorough reply.
I am still figuring out what the best method is for my needs, so not completely sure if megam is an essential requirement.
But this information is definitely helpful, I think and update should be considered for the book with such implementation to solve this issue.. though this seems a bit much for a, at first glance, seemingly small issue.

If you have any advice/experience regarding table (/structured) data extraction, that would be greatly appreciated.

Thanks for your help,

George Orton

unread,
Mar 18, 2013, 1:22:40 PM3/18/13
to nltk-...@googlegroups.com

Hi Ruud, Pulling structured data out of non-structured text is really a large part of what nltk is all about. What that means is if you really want to understand how to get structured data out of text you pretty much have to work your way through and understand the Natural Language Processing with Python text (or some equivalent text if there are any). Not the easy answer I know but still pretty much the truth of it. When I first started trying to understand nltk I did a project to extract structured data from some text using some code written by Jacob Perkins. Jacob is a frequent contributor to this site, and he has written some excellent code that automates the extraction of structured data from non-structured text. I used it for my first project and had very good results. It is relatively simple to use, so if your timeline doesn't allow you to work through a complete understanding of nltk I would recommend trying Jacob's code. I think Jacob is currently on a thread in this forum discussing his code.
They may have changed over time but these are the links to Jacob's code that I used


Jack Hong

unread,
Dec 3, 2013, 1:40:07 AM12/3/13
to nltk-...@googlegroups.com
I managed to install megam and have NLTK read the binary successfully. This is what I did on Mac OS X 10.9:

1. Download megam_src.tgz from  http://hal3.name/megam and unzip it (got a folder named megam_0.92

2. Download the precompiled Ocaml from http://caml.inria.fr/ocaml/release.en.html, mount and install the program
(The readme.txt in the mounted Ocaml image stated that 'library and support files' will be installed in /usr/local/lib/ocaml)

4. Open the file Makefile in megam_0.92 folder and edit WITHCLIBS =-I /usr/local/lib/ocaml/caml

5. Edit WITHSTR =str.cma -cclib -lcamlstr

6. Go to Terminal, navigate to the megam_0.92 folder and return 'make'. That will give you a bunch of files, including a binary file named megam.

7. Point nltk.config_megam to the fullpath of megam, i.e,  nltk.config_megam('/Users/.../megam_0.92/megam')
(NLTK will print [Found /Users/.../megam_0.92/megam: ...] if successful)

Hope this helps!
Reply all
Reply to author
Forward
0 new messages