This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
forked from scrapinghub/python-cld2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
50 lines (32 loc) · 1.51 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Dick Sites (and others) at Google graciously provided a new version
2.0 of the compact language detector, here:
https://code.google.com/p/cld2/
and I (lucene@mikemccandless.com) created the Python bindings and
ported the C++ test case to test.py.
This has been tested on Ubuntu 12.10, with both Python 2.7.3 and
3.2.3.
To build:
* First checkout cld2 and run internal/compile_libs.sh. This will
create both libcld2.so (detects 83 languages) and libcld2_full.so
(detects 163 languages). Install those libraries somewhere on
your LD_LIBRARY_PATH, for example copy them into /usr/lib64.
* Define the CLD2_PATH environment variable to point to where you
checked out the CLD2 sources: export CLD2_PATH='/path/to/cld2'
* python setup.py build
* python setup_full.py 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
environment).
To test both the small and full language tables:
* python test.py
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 setup.py install (as root)
* python setup_full.py install (as root)
For documentation run:
* python -c "import cld2; help(cld2.detect)"
NOTE: you must pass only valid UTF-8 bytes to the detect function,
otherwise you can hit segmentation fault or get incorrect results.