if not taggedLine:
    print('Error: files are out of sync.')
taggedLine = taggedLine.split()
if len(trueLine) != len(taggedLine):
    print('Error: files are out of sync.')
for i in range(len(trueLine)):
    truePair = trueLine[i].split('/')
taggedPair = taggedLine[i].split('/')
if truePair[0] != taggedPair[0]:
    print('Error: files are out of sync.')
trueTag = truePair[1]
guessedTag = taggedPair[1]
if trueTag == guessedTag:
    totals[trueTag]['truePositives'] += 1
else:
    totals[trueTag]['falseNegatives'] += 1
totals[guessedTag]['falsePositives'] += 1
How to calculate tag-wise precision and recall for POS tagger?