Installing Compact Language Detection 2 (CLD2) on Ubuntu

Posted: April 2nd, 2014 | Author: | Filed under: IT Related | Tags: , , | 5 Comments »

I’ve been using chromium-compact-language-detector before, and when they moved to v2.0, chromium-compact-language-detector has been renamed in to Compact Language Detection 2 (CLD2). I’ve read blog post on the performance review and i’m really impressed. So let give them a try.

Install the dependencies:

sudo apt-get install mercurial gcc-multilib python-dev build-essential

Download CLD2 and the python binding:

cd /tmp/
svn checkout http://cld2.googlecode.com/svn/trunk/ cld2
hg clone https://code.google.com/p/chromium-compact-language-detector/

Compile CLD2 and install the lib (for 32bit) :

cd /tmp/cld2/internal/
cat compile_libs.sh | sed 's/\ \-m64\ //g' > compile_me.sh
chmod +x compile_me.sh
./compile_me.sh
sudo cp *.so /usr/lib/

Compile CLD2 and install the lib (for 64bit) :

cd /tmp/cld2/internal/
./compile_libs.sh
sudo cp *.so /usr/lib64/

Compile the python binding:

cd /tmp/chromium-compact-language-detector/
 
python setup.py build
python setup_full.py build
 
sudo python setup.py install
sudo python setup_full.py install

Give the library a test:

python test.py

For documentation:

python -c "import cld2; help(cld2.detect)"

Done! Thanks


5 Comments on “Installing Compact Language Detection 2 (CLD2) on Ubuntu”

  1. 1 Threepwood said at 6:19 PM on April 29th, 2014:

    Thank you for this tutorial, it works perfectly !
    question, how to interface with PHP ?
    I searched the documentation, but I can not find anything with CLD2 …

  2. 2 E said at 1:16 AM on August 3rd, 2014:

    Hi, thanks for your detailed instruction. I really appreciate it. Unfortunately, my installation has still been unsuccessful. Here’s the error I am getting when I start compiling the python binding:

    `pkg-config –libs –cflags cld` returns in error:
    Package cld was not found in the pkg-config search path.
    Perhaps you should add the directory containing `cld.pc’
    to the PKG_CONFIG_PATH environment variable
    No package ‘cld’ found

    The `cld` C++ library is absent from this system. Please install it.

    Any help/suggestion will be greatly appreciated.

    Cheers!

  3. 3 SEGUIER said at 11:27 PM on March 15th, 2017:

    Hi, thanks for your tutorial, but I have an error with the command :
    python setup_full.py build
    pycldmodule.cc:22:30: fatal error: compact_lang_det.h: Aucun fichier ou dossier de ce type

  4. 4 Install CLD2 on Ubuntu 16.04 for apertium-apy – vee: ดิจิทัล said at 2:41 AM on May 7th, 2017:

    […] http://blog.xanda.org/2014/04/02/installing-compact-language-detection-2-cld2-on-ubuntu/ I wrote a script for Ubuntu 16.04 sudo apt-get install libcld2-dev git clone […]

  5. 5 Installing CLD2 on Ubuntu 16.04 for apertium-apy – vee: ดิจิทัล said at 2:44 AM on May 7th, 2017:

    […] http://blog.xanda.org/2014/04/02/installing-compact-language-detection-2-cld2-on-ubuntu/ I wrote a script for Ubuntu 16.04 sudo apt-get install libcld2-dev git clone […]


Leave a Reply