diff --git a/src/fast_align.cc b/src/fast_align.cc index 637af26..07ca495 100644 --- a/src/fast_align.cc +++ b/src/fast_align.cc @@ -483,6 +483,8 @@ int main(int argc, char** argv) { } } tlp += log_prob; + cout <<"x"; + cout << log_prob; cout << " ||| " << log_prob << endl << flush; } // loop over test set sentences cerr << "TOTAL LOG PROB " << tlp << endl; diff --git a/src/force_align.py b/src/force_align.py index 7eba63c..0c9d19d 100755 --- a/src/force_align.py +++ b/src/force_align.py @@ -30,12 +30,17 @@ def align(self, line): self.fwd_align.stdin.write('{}\n'.format(line)) self.rev_align.stdin.write('{}\n'.format(line)) # f words ||| e words ||| links ||| score - fwd_line = self.fwd_align.stdout.readline().split('|||')[2].strip() - rev_line = self.rev_align.stdout.readline().split('|||')[2].strip() + f = self.fwd_align.stdout.readline().split('|||')[2].strip().split('x') + fwd_line = f[0] + fwd_score =float(f[1]) + r = self.rev_align.stdout.readline().split('|||')[2].strip().split('x') + rev_line = r[0] + rev_score = float(r[1]) + global_score = (fwd_score+rev_score)/2 self.tools.stdin.write('{}\n'.format(fwd_line)) self.tools.stdin.write('{}\n'.format(rev_line)) al_line = self.tools.stdout.readline().strip() - return al_line + return al_line, global_score def close(self): self.fwd_align.stdin.close() @@ -83,7 +88,7 @@ def main(): line = sys.stdin.readline() if not line: break - sys.stdout.write('{}\n'.format(aligner.align(line.strip()))) + sys.stdout.write('{} |{}\n'.format(aligner.align(line.strip())[0],aligner.align(line.strip())[1])) sys.stdout.flush() aligner.close()