Welcome to mirror list, hosted at ThFree Co, Russian Federation.

srilm.cc « lmserver « contrib - github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 657bed3c4b68af73b9c03e70ed29bfb38b0940fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <cassert>
#include <iostream>
#include "Ngram.h"

using namespace std;
Vocab vocab;
Ngram* ngram = NULL;

extern "C" {

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

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

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

}