Skip to content

Automatically exported from

Notifications You must be signed in to change notification settings


Repository files navigation

Dick Sites (and others) at Google graciously provided a new version
2.0 of the compact language detector, here:

and I ( created the Python bindings and
ported the C++ test case to

This has been tested on Ubuntu 14.04, with both Python 2.7.6 and

Updated Nov 11 2014 to the latest CLD2 release, adding new bestEffort
flag (to force a guess even when confidence is low), and cutting over
to the CLD2 methods that confirm incoming UTF-8 is valid.

To build:

  * First checkout cld2, cd internal, run  This will
    create both (small tables, detects 83 languages) and (large tables, detects 163 languages).  Install
    those libraries somewhere on your LD_LIBRARY_PATH, for example
    copy them into /usr/lib.

  * Edit both and change CLD2_PATH to point to
    where you checked out the CLD2 sources.

  * python build

  * python build

Note that all Python sources work with both python 2.x and 3.x so if
you want to install for python3.x just repeat the above steps using
python3 (or whatever python command runs python 3.x in your

To test both the small and full language tables:

  * python

The test produces a lot of output, due to the test cases testing the
debug flags; this is normal.  As long as it says OK in the end then
the tests passed.

To install:

  * python install (as root)

  * python install (as root)

For documentation run:

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

NOTE: and were used as temporary helpers during
development and are not needed for building

NOTE: you must pass only valid UTF-8 bytes to the detect function,
otherwise you can hit segmentation fault or get incorrect results.


Automatically exported from