Skip to content

Install kenlm

Ming Xu (徐明) edited this page Jun 5, 2023 · 6 revisions

kenlm版本更新到0.1版本啦,pip install kenlm 直接安装就可以成功。

方法1:pip安装, pip install https://github.com/kpu/kenlm/archive/master.zip

方法2: 方法1不奏效,就是依赖的工具没装,centos安装如下:

sudo yum install boost boost-devel
sudo yum install zlib zlib-devel
sudo yum install gcc gcc-c++
pip install https://github.com/kpu/kenlm/archive/master.zip

方法3:linux下编译安装教程

方法4:基本同方法3,自己编译:

  • Assuming that you already have g++ and bash installed, run the following commands to setup the kenlm library properly:
    • wget -O - https://kheafield.com/code/kenlm.tar.gz |tar xz
    • mkdir kenlm/build
    • cd kenlm/build
    • sudo apt-get install build-essential libboost-all-dev cmake zlib1g-dev libbz2-dev liblzma-dev (to install basic dependencies)
    • cmake ..
    • make -j2
    • cd .. # 返回上一层
    • python3 setup.py install # 安装kenlm到python库中

其中cmake ..时可能提示某些工具缺失,安装相应工具即可:

  • Install Boost:

    • cd $HOME, Download boost_1_67_0.tar.bz2 from here
    • 解压:tar --bzip2 -xf $HOME/boost_1_67_0.tar.bz2
    • 安装:cd boost_1_67_0; sh ./bootstrap.sh; ./b2 install
    • export BOOST_ROOT=$HOME/boost_1_67_0/
  • Install Eigen3:

    • cd $HOME; wget -O - https://gitlab.com/libeigen/eigen/-/archive/3.2.10/eigen-3.2.10.tar.bz2 |tar xj
    • export Eigen3_DIR=$HOME/eigen-3.2.10
    • Go back to the kenlm/build folder and run rm CMakeCache.txt

相关windows安装kenlm的issue:https://github.com/shibing624/pycorrector/issues/71#issuecomment-563040699