コード例 #1
0
ファイル: srilm.py プロジェクト: zomux/chiropractor
    def tokensProbability(self, tokens):
      if not tokens:
        return 0.0

      prob = srilm_wrapper.getSentenceProb(self.model, ' '.join(tokens) , len(tokens))

      if prob < -999 or prob == 0 : prob = -999.0
      return prob
コード例 #2
0
ファイル: srilm.py プロジェクト: zomux/chiropractor
    def readNGram(self,words):
      """
      @type words: list of string
      @rtype: float
      """
      if len(words) == 0 : return 0.0
      #words = [self.word_id(w) for w in words]
      #words.reverse()

      #iarray = self.create_history(words[1:])
      prob = srilm_wrapper.getSentenceProb(self.model, ' '.join(words) , len(words))
      #srilm_wrapper.delete_intArray(iarray)

      #if prob < -999999 : prob = 0.0
      #prob = math.exp(prob)

      if prob < -99 : prob = -99.0
      return prob
コード例 #3
0
ファイル: srilm.py プロジェクト: zomux/chiropractor
 def sentenceProbability(self, sentence):
     if not sentence:
         return 0.0
     return srilm_wrapper.getSentenceProb(self.model, sentence, len(sentence.split()))
コード例 #4
0
ファイル: srilm.py プロジェクト: zomux/chiropractor
 def sentence_probability(self, sentence):
     """Return the probability of a sentence.
     sentence - string of sentence without start and end tokens."""
     return srilm_wrapper.getSentenceProb(self.model, sentence, len(sentence.split()))