summaryrefslogtreecommitdiff
path: root/src/srilm.py
blob: ef371cf0c4903f3033cb2f7ff3f1816b290a4d6f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import logging
import subprocess

class SRILM:

  def __init__(self, config):
    self.config = config

  def run_ngram_count(self):
    log = open('%s/lm.log' % self.config.experiment_dir, 'w')
    p = subprocess.Popen([self.config.srilm_ngram_count,
                          '-text', '%s/train.%s.lm' % (self.config.experiment_dir, self.config.tgt),
                          '-order', '3',
                          '-no-sos',
                          '-no-eos',
                          '-lm', '%s/%s.arpa' % (self.config.experiment_dir, self.config.tgt),
                          '-unk'],
                          stderr=log)
    p.wait()
    log.close()