I would like to count all the repeated words in this dictionary and group them in another dictionary.
data = [{'text': 'Real Madrid', 'type': 'ORG'}, {'text': 'España', 'type': 'LOC'}, {'text': 'Real Madrid TV', 'type': 'MISC'}, {'text': 'España', 'type': 'PER'}, {'text': 'España', 'type': 'PER'}, {'text': 'Real Madrid', 'type': 'ORG'}, {'text': 'Atlético de Madrid', 'type': 'LOC'}, {'text': 'Real Madrid', 'type': 'ORG'}, {'text': 'Real Madrid', 'type': 'ORG'}, {'text': 'Real Mad', 'type': 'ORG'}, {'text': 'Ricardo Rodríguez', 'type': 'PER'}]
Capture of the dictionary structure
In the dictionary as you can see, the word Real Madrid is repeated 4 times, Spain is repeated 2 times, others once.
What I want is to create another dictionary by adding the Quantity column and put the repeated values there; I mean my new dictionary would be with the new fields: text, type and quantity; the new dimension of the dictionary would be 6.
This is my breakthrough:
valor = data[0]['text']
del data[0]
count = 0
value_count = []
for x in data:
if x['text'] == valor:
value_count.append({'text': x['text'], 'type':x['type']})
valor = x['text']
print (value_count)
Thanks