Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

return index as well

  • Loading branch information...
commit 23a866fffcf8e38c6d1bc3ea83658f08a1451b44 1 parent 4bbb325
@proycon authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 formats/giza.py
View
8 formats/giza.py
@@ -98,6 +98,7 @@ def __repr__(self):
def getalignedtarget(self, index):
targetindices = []
target = None
+ foundindex = -1
for sourceindex, targetindex in self.alignment:
if sourceindex == index:
targetindices.append(sourceindex)
@@ -108,10 +109,13 @@ def getalignedtarget(self, index):
consecutive = False
break
if consecutive:
+ foundindex = (min(targetindices), max(targetindices))
target = ' '.join(self.target[min(targetindices):max(targetindices)+1])
elif targetindices:
- target = self.target[targetindices[0]]
- return target
+ foundindex = targetindices[0]
+ target = self.target[foundindex]
+
+ return target, foundindex
class GizaModel(object):
def __init__(self, filename, encoding= 'utf-8'):
Please sign in to comment.
Something went wrong with that request. Please try again.