if I have a text like this
1
<src> he is a [man]</src>
<tgt>lui è un [uomo]</tgt>
2
<src> she is a [woman]</src>
<tgt>lei è una donna</tgt>
3
<src> he works well</src>
<tgt> lui lavora [bene]</tgt>
and I want to detect the strings between the brackets only if the brackets are present in the src and tgt line, so in the text above, I want to detect only [man][uomo], because in the src line there is [man] and in the tgt line there is [uomo]. Can someone help me
I tried this code
line = str()
num = str()
line1 = str()
num1 = str()
for i, line in enumerate(file):
lines = iter(filer1)
if line.startswith("<src>"):
line += '%s\n' % line.strip()
num += '%s\n' % filer1[i-1]
if line.startswith("<tgt>"):
line1 += '%s\n' % line.strip()
num1 += '%s\n' % filer1[i-2]
for l in line.splitlines():
for ll in line1.splitlines():
for n in num.splitlines():
for nn in num1.splitlines():
if n ==nn:
m = re.findall(r"\[(.*?)\]",l)
mm = re.findall(r"\[(.*?)\]",ll)
if m and mm:
print '[{}]'.format(m[0]), '[{}]'.format(mm[0])