The tuples inside the file:
('Wanna', 'O')
('be', 'O')
('like', 'O')
('Alexander', 'B')
('Coughan', 'I')
('?', 'O')
My question is, how to join two strings from the different tuples but in the same index with a condition?
For example in my case, i want to join string in [0] if [1] equal to 'B' and followed by 'I'
So the output will be like:
Alexander Coughan
This is my code but the output is not like i want which is it just printed "NONE":
readF = read_file ("a.txt")
def jointuples(sentt, i):
word= sentt[i][0]
wordj = sentt[i-1][0]
nameq = sentt[i][1]
if nameq =='I':
temp= ' '.join (word + wordj)
return temp
def join2features(sentt):
return [jointuples(sentt, i) for i in range(len(sentt))]
c_joint = [join2features(s) for s in readF]
c_joint
if nameq =='I-NP'there... what do you expect that to do?