對于master分支,編譯方法如下:
git clone https://github.com/hankcs/HanLP.git
mvn install -DskipTests
·由于目前一些test不夠規範,使用了寫死路徑下的資源,是以暫時跳過單元測試。
·該方法不會将src/main/resources目錄下的任何資源(包括hanlp.properties)打包進jar,如果需要打包資源檔案,請切換到portable分支。
portable分支git checkout portable
然後将需要的data放入src/main/resources,最後執行:
運作jar目前jar包中有一些子產品可以指令行執行,以感覺機詞法分析器為例。由于這些子產品一般需要加載外部data,是以需要在運作時指定hanlp.properties。運作時,一個典型的目錄結構如下:

·此處隻列出了重要的目錄。
·一個良好的實踐是把hanlp.properties放到resources目錄下。
指令行需要指定jar包和hanlp.properties所在的目錄:
$ java -cp target/hanlp-1.6.0.jar:src/main/resources com.hankcs.hanlp.model.perceptron.Main -test \
<<< '華安集團胡花蕊來到紐約藝術博物館參觀'
[華安/nz 集團/n]/nt 胡花蕊/nr 來到/v [紐約/ns 藝術/n 博物館/n]/ns 參觀/v
·Windows使用者請使用分号java -cp target/hanlp-1.6.0.jar;src/main/resources