0

I have extracted a list of dictionaries from Stanford NER and created a list like the following :

myList = [
{'A':{},'B':['C','D'],
'names': {'PERSON': [u'John Butters', u'Bill', u'Hillary Clinton'],'LOCATION': [],
 'ORGANIZATION': [u'FactSet', u'Pfizer Inc. PFE']}},
{'A':{'Hello'},'B':['F','E'], 
'names': {'PERSON': [u'Tim Anderson', u'Hillary Clinton'], 'LOCATION': [ u'US'], 
'ORGANIZATION': [u'Goldman Sachs GS', u'ConocoPhillips COP', u'FactSet']}},
{'A':{'right'},'B':['M','N'],
'names': {'PERSON': [u'Mohammed bin Salman', u'Spano'], 'LOCATION': [u'Saudi Arabia',u'Red Sea'],
 'ORGANIZATION': [u'Aramco', u'FactSet', u'Goldman Sachs GS']}}
 ]

In the other word I have a list like:

myList = [{},{},{}]

Each dictionary contains details for one specific document. The key of 'names' is a dictionary like:

'names':{'PERSON':[], 'LOCATION':[], 'ORGANIZATION':[]}

I intend to extract the frequency of values under the key of 'names' ----> 'ORGANIZATION' over the whole document, and then count how many times each pair of names occurred together in myList. Any help would be greatly appreciated. The output should look like:

{u'FactSet': 3, u'Pfizer Inc. PFE':1, u'Goldman Sachs GS':2, u'ConocoPhillips COP':1, u'Aramco':1}

And finally, I want to count co-occurrences of the above names. The output can be like:

{[u'FactSet', u'Pfizer Inc. PFE']:1, 
[u'Goldman Sachs GS', u'ConocoPhillips COP']:1,
[u'Goldman Sachs GS', u'FactSet'] :2,
[u'Aramco', u'FactSet']:1, 
[u'Aramco', u'Goldman Sachs GS']:1 }
mk_sch
  • 1,060
  • 4
  • 16
  • 31
  • have tried any approach for this? if yes, then please post that code here. – Shubham Namdeo Jan 31 '17 at 07:20
  • You should give at least one example of what it is that you want to count, based on the values in `myList` (which is rather unreadable, BTW, so consider rephrasing it in some way). – barak manos Jan 31 '17 at 07:25

0 Answers0