pymtranslate/translator.py
def initTef(self):
        ''' 
        get all probable matches
        and then initialize t(f|e)
        '''
        probs = {}
        transmissions = {}

        # go through each german word
        for word in self.en_words:
            word_poss = []
            # if word in sentence.. then
            for sent in self.en_dict:
                if word in sent:
                    matching = self.de_dict[self.en_dict.index(sent)]
                    word_poss = word_poss + matching.split()

            # remove the duplicates
            word_poss = list(set(word_poss))
            # add the probable matches
            probs[word] = word_poss

        self.probs = probs
        print self.probs

        for word in self.en_words:
            # print self.probs
            word_probs = self.probs[word]
            if (len(word_probs) == 0):
                print word, word_probs
            uniform_prob = 1.0 / len(word_probs)

            word_probs = dict([(w, uniform_prob) for w in word_probs])

            # save word_probs
            transmissions[word] = word_probs

        self.transmissions = transmissions
def initTef(self):
        ''' 
        get all probable matches
        and then initialize t(f|e)
        '''
        probs = {}
        transmissions = {}

        # go through each german word
        for word in self.en_words:
            word_poss = []
            # if word in sentence.. then
            for sent in self.en_dict:
                if word in sent:
                    matching = self.de_dict[self.en_dict.index(sent)]
                    word_poss = word_poss + matching.split()

            # remove the duplicates
            word_poss = list(set(word_poss))
            # add the probable matches
            probs[word] = word_poss

        self.probs = probs
        print self.probs

        for word in self.en_words:
            # print self.probs
            word_probs = self.probs[word]
            if (len(word_probs) == 0):
                print word, word_probs
            uniform_prob = 1.0 / len(word_probs)

            word_probs = dict([(w, uniform_prob) for w in word_probs])

            # save word_probs
            transmissions[word] = word_probs

        self.transmissions = transmissions
def initTef ( self ) : probs = { } transmissions = { } # go through each german word for word in self . en_words : word_poss = [ ] # if word in sentence.. then for sent in self . en_dict : if word in sent : matching = self . de_dict [ self . en_dict . index ( sent ) ] word_poss = word_poss + matching . split ( ) # remove the duplicates word_poss = list ( set ( word_poss ) ) # add the probable matches probs [ word ] = word_poss self . probs = probs print self . probs for word in self . en_words : # print self.probs word_probs = self . probs [ word ] if ( len ( word_probs ) == 0 ) : print word , word_probs uniform_prob = 1.0 / len ( word_probs ) word_probs = dict ( [ ( w , uniform_prob ) for w in word_probs ] ) # save word_probs transmissions [ word ] = word_probs self . transmissions = transmissions
get all probable matches
        and then initialize t(f|e)
get all probable matches and then initialize t ( f|e )