Example #1
0
    def run(self):
        aligner = LevenshteinAligner(weights=self.weights)
        style = self.args.style
        nonid = self.args.nonid

        for line in self.args.infile:
            try:
                (word1, word2) = line.strip().decode(self.args.encoding).split('\t')
            except ValueError:
                print >> sys.stderr, "*** Ignoring line: %s" % line

            if not (nonid and word1 == word2):
                aligner.print_alignments(word1, word2, style)
Example #2
0
 def perform_alignments(self):
     alignments = {}
     leven = LevenshteinAligner(weights=self.weights, epsilon=self.epsilon)
     for pair in self.pairs:
         alignments[pair] = leven.align(*pair)
     return alignments