The size of the tuples in the list is 39.
Here is my codes:
def joinphrase(joinph,i):
length = len(joinph)
res = ['%s %s' % (joinph[i][0], joinph[i + 1][0])
for i in range(length)
if i < length - 1 and joinph[i][2] == 'B-NP' and joinph[i + 1][2] == 'I-NP']
return res
def sentjoinphrase(joinph):
return [joinphrase(joinph, i) for i in range(len(joinph))]
example = test_sents[0]
print (sentjoinphrase(example))
I want to join two strings from the different tuples with a condition and print the join output. But the output printed 39 times according to the size of the tuples in the list.
How to print the output only 1 time?