Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/fast_align.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions src/force_align.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down