make: /home/master/98/r98922053/srilm-1.5.10/sbin/machine-type: Command not found
make: /sbin/machine-type: Command not found
matherr.c:18:16: warning: 'struct exception' declared inside parameter list will not be visible outside of this definition or declaration
matherr(struct exception *x)
^~~~~~~~~
matherr.c: In function 'matherr':
matherr.c:21:10: error: dereferencing pointer to incomplete type 'struct exception'
if (x->type == SING && strcmp(x->name, "log10") == 0) {
^~
matherr.c:21:20: error: 'SING' undeclared (first use in this function)
if (x->type == SING && strcmp(x->name, "log10") == 0) {
^~~~
matherr.c:21:20: note: each undeclared identifier is reported only once for each function it appears in
matherr.c:29:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make[2]: *** [/home/master/98/r98922053/srilm-1.5.10/common/Makefile.common.targets:85: ../obj/i686-m64/matherr.o] Error 1
make[2]: Leaving directory '/home/master/98/r98922053/srilm-1.5.10/lm/src'
make[1]: *** [Makefile:77: release-libraries] Error 1
make[1]: Leaving directory '/home/master/98/r98922053/srilm-1.5.10'
make: *** [Makefile:51: World] Error 2
11 warnings and 1 error genertated. make[2]: *** [../obj/macosx/LatticeIndex.o] Error 1 make[1]: *** [release-libraries] Error 1 make: *** [World] Error 2
/usr/include/features.h:367:25 fatal error: sys/cdefs.h no such file or directory
ㄅ 八 匕 卜 不 卞 巴 比 丙 包 ... 八 八 匕 匕 不 不 ... ... ㄆ 仆 匹 片 丕 叵 平 扒 扑 疋 ... 仆 仆 匹 匹 片 片 ... ... ㄦ 二 而 耳 兒 洱 貳 爾 餌 邇 ... 二 二 而 而 兒 兒 ... ...注意:每一個字之間都有空格
檢查方法:在 terminal 打 file ZhuYin-Big5.map,只要是 ISO 開頭的應該就沒問題。
SRIPATH ?= /root/srilm-1.5.10 MACHINE_TYPE ?= i686-m64 CXX = g++ CXXFLAGS = -O3 -I$(SRIPATH)/include -w --std=c++11 vpath lib%.a $(SRIPATH)/lib/$(MACHINE_TYPE) TARGET = ngram_test SRC = ngram_test.cpp OBJ = $(SRC:.cpp=.o) .PHONY: all clean all: $(TARGET) $(TARGET): $(OBJ) -loolm -ldstruct -lmisc $(CXX) $(LDFLAGS) -o $@ $^ %.o: %.cpp $(CXX) $(CXXFLAGS) -c $< clean: $(RM) $(OBJ) $(TARGET)source code ngram_test.cpp 為:
#include <stdio.h> #include "Ngram.h"如此就可以利用 lm.wordProb 來得到 language model 的機率。
int main(int argc, char *argv[]) {
int ngram_order = 3; Vocab voc; Ngram lm( voc, ngram_order ); { const char lm_filename[] = "./corpus.lm"; File lmFile( lm_filename, "r" ); lm.read(lmFile); lmFile.close(); } VocabIndex wid = voc.getIndex("囧"); if(wid == Vocab_None) { printf("No word with wid = %d\n", wid); printf("where Vocab_None is %d\n", Vocab_None); } wid = voc.getIndex("患者"); VocabIndex context[] = {voc.getIndex("癮") , voc.getIndex("毒"), Vocab_None}; printf("log Prob(患者|毒-癮) = %f\n", lm.wordProb(wid, context)); }
VocabIndex wid = voc.getIndex("囧");
if(wid == Vocab_None) {
// replace OOV with <unk>
wid = voc.getIndex(Vocab_Unknown);
}
// do something
...
- 解壓縮 srilm-1.5.10.tar.gz
- 修改 Makefile, 在檔案上端加入 SRILM 變數到你的 srilm 目錄(絕對路徑)
- ex: # SRILM = /home/speech/stolcke/project/srilm/devel
- 修改檔案 common/Makefile.machine.i686
- 17 行的 CC 改成 CC = /usr/bin/gcc $(GCC_FLAGS)
- 18 行的 CXX 改成 CXX = /usr/bin/g++ $(GCC_FLAGS) -DINSTANTIATE_TEMPLATES
- 52, 53 行的 tcl 設定改成下面三行
- 請確定 sbin/ 資料夾底下的程式為可執行檔。若不是或不確定,移至 sbin/底下,在命令列輸入 chmod 755 *
- 完成以上步驟後, 在命令列輸入 make MACHINE_TYPE=i686 World
- 清除編譯過程中的暫存檔:make cleanest
- 安裝好後, 可在 bin/i686 中找到 SRILM 的執行檔
i686-m64:=> SRILM = /root/srilm-1.5.10
更多請詳見 Q3
以下 SRILM 路徑都以此路徑舉例說明
NO_TCL = X
TCL_INCLUDE =
TCL_LIBRARY =
-
64 bit machine (e.g., 資工系工作站),請修改 common/Makefile.machine.i686-m64
Mac OS X: 如果系統是 Mac OS X,一開始的編譯方式會和上面不太一樣。修改後執行 make MACHINE_TYPE=i686-m64 World
安裝好後, 可在 bin/i686-m64 中找到 SRILM 的執行檔
line 13: 改為 CC = /usr/bin/gcc $(GCC_FLAGS) -Wimplicit-int
line 14: 改為 CXX = /usr/bin/g++ $(GCC_FLAGS) -DINSTANTIATE_TEMPLATES
line 49, 50: 註解掉
MACHINE_TYPE = macosx
CXX = /usr/bin/g++