[SRILM User List] c++ sample for building language model

Yi Yang yangyiycc at gmail.com
Fri Mar 8 08:06:57 PST 2013


Hi Mohsen,

Hope the following codes can be helpful:

void SrilmTest::srilm_init(const char* fname, int order) {
  File file(fname, "r", 0);
  assert(file);
  ngram = new Ngram(vocab, order);
  ngram->read(file, false);
  cerr << "Done\n";
}

int SrilmTest::srilm_getvoc(const char* word) {
  return vocab.getIndex((VocabString)word);
}

float SrilmTest::srilm_wordprob(int w, int* context) {
  return (float)ngram->wordProb(w, (VocabIndex*)context);
}


On Thu, Mar 7, 2013 at 3:23 PM, mohsen jadidi <mohsen.jadidi at gmail.com>wrote:

> Hey,
>
> I need to use srilm in my c++ code to build ML. all the examples and
> slides in the internet explained it using ngram-count command not code. I
> know should use <Ngram.h> <Vocab.h>. can you point me to a starting point?
>
> cheers,
>
>
> --
> Mohsen
>
> _______________________________________________
> SRILM-User site list
> SRILM-User at speech.sri.com
> http://www.speech.sri.com/mailman/listinfo/srilm-user
>



-- 
Sincerely,
Yi Yang
http://www.cc.gatech.edu/~yyang319/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.speech.sri.com/pipermail/srilm-user/attachments/20130308/d62eff95/attachment.html>


More information about the SRILM-User mailing list