Skip to content

Commit

Permalink
one last test before bedtime
Browse files Browse the repository at this point in the history
git-svn-id: https://ilk.uvt.nl/svn/trunk/sources/pynlpl@5459 12f355fe-0486-481a-ad91-c297ab22b4e3
  • Loading branch information
proycon committed Jul 16, 2010
1 parent 39665bd commit 09d1759
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions mt/wordalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,26 @@ def test(self, sourcefile, targetfile):
for sourcetoken in sourcetokens:
#which of the target-tokens is most frequent?
besttoken = None
bestscore = 0
bestscore = -1
for i, targettoken in enumerate(targettokens):
if targettoken in self.source2target[sourcetoken] and self.source2target[sourcetoken][targettoken] > bestscore:
bestscore = self.source2target[sourcetoken][targettoken]
besttoken = i
if targettoken in self.source2target[sourcetoken]:
score = self.source2target[sourcetoken][targettoken] / float(self.targetfreqlist[targettoken])
if score > bestscore:
bestscore = self.source2target[sourcetoken][targettoken]
besttoken = i
S2Talignment.append(besttoken) #TODO: multi-alignment?

for targettoken in targettokens:
besttoken = None
bestscore = 0
bestscore = -1
for i, sourcetoken in enumerate(sourcetokens):
if sourcetoken in self.target2source[targettoken] and self.target2source[targettoken][sourcetoken] > bestscore:
bestscore = self.target2source[targettoken][sourcetoken]
besttoken = i
if sourcetoken in self.target2source[targettoken]:
score = self.target2source[targettoken][sourcetoken] / float(self.sourcefreqlist[sourcetoken])
if score > bestscore:
bestscore = self.target2source[targettoken][sourcetoken]
besttoken = i
T2Salignment.append(besttoken) #TODO: multi-alignment?

yield sourcetokens, targettokens, S2Talignment, T2Salignment

sourcefile.close()
Expand Down

0 comments on commit 09d1759

Please sign in to comment.