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
ㄅ 八 匕 卜 不 卞 巴 比 丙 包 ... 八 八 匕 匕 不 不 ... ... ㄆ 仆 匹 片 丕 叵 平 扒 扑 疋 ... 仆 仆 匹 匹 片 片 ... ... ㄦ 二 而 耳 兒 洱 貳 爾 餌 邇 ... 二 二 而 而 兒 兒 ... ...注意:第一個字/注音後面接的是tab,且後面每一個字之間都有空格。
SRIPATH ?= /home/master/98/r98922053/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 ...