Data is like this{DT The NNP Fulton NNP County NNP Grand NNP Jury VBD said NNP Friday 0 DT an NN investigation IN of NNP Atlanta POS 's JJ recent JJ primary NN election VBD produced
DT no NN evidence ‘’ ‘’ IN that DT any NNS irregularities VBD took NN place . . DT The NN jury RB further VBD said IN in JJ term-end NNS presentments IN that DT the NNP City NNP Executive }
fname = open('/content/try list.txt', "r")
counts = dict()
for line in fname:
words = line.split()
for word in words:
if word not in counts:
counts[word] = 1
else:
counts[word] += 1
print(counts)
My output : {'DT': 10, 'The': 2, 'NNP': 11, 'Fulton': 1, 'County': 1, 'Grand': 1, 'Jury': 1, 'VBD': 5, 'said': 2, 'Friday': 1, '0': 1, 'an': 1, 'NN': 9, 'investigation': 1, 'IN': 8, 'of': 4, 'Atlanta': 2, 'POS': 1, "'s": 1, 'JJ': 4, 'recent': 1,}
It’s counting the occurrence of each word and stage but how can I do words wise?
Expected output should be: The–>DT:48, Fulton–> NNP:28