tags:

views:

349

answers:

4

I want to use the nltk libraries in c++.

Is there a glue language/mechanism I can use to do this?

Reason: I havent done any serious programming in c++ for a while and want to revise NLP concepts at the same time.

Thanks

+1  A: 

I haven't tried directly calling Python functions from C++, but here are some alternative ideas...

Generally, it's easier to call C++ code from a high-level language like Python than the other way around. If you're interested in this approach, then you could create a C++ codebase and access it from Python. You could either directly use the external API provided by python [it should be described somewhere in the Python docs] or use a tool like SWIG to automate the C++-to-Python wrapping process.

Depending on how you want to use the library, you could alternatively create Python scripts which you call from C++ with the exec* functions.

Mr Fooz
+13  A: 

Although calling c++ libs from python is more normal - you can call a python module from c++ by bascially calling the python intepreter and have it execute the python source. This is called embedding

Alternatively the boost.python library makes it very easy.

Martin Beckett
+10  A: 

You can also try the Boost.Python library; which has this capability. This library is mainly used to expose C++ to Python, but can be used the other way around.

zdan
+1  A: 

Pyrex can be cleanly used for this purpose. There's an example in the source-code release.

fivebells