Question

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

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top