def to_entity_json(entity, entity_sentiment, entity_frequency):
 json_doc = {}
 avg_sentiment = (float(entity_sentiment) / float(entity_frequency))
 json_doc['wiki_url'] = entity
 json_doc['name'] = get_wiki_title(entity)
 json_doc['sentiment'] = float(('%.3f' % entity_sentiment))
 json_doc['avg_sentiment'] = float(('%.3f' % avg_sentiment))
 return json.dumps(json_doc)

def to_entity_json ( entity , entity_sentiment , entity_frequency ) : json_doc = { } avg_sentiment = ( float ( entity_sentiment ) / float ( entity_frequency ) ) json_doc [ 'wiki_url' ] = entity json_doc [ 'name' ] = get_wiki_title ( entity ) json_doc [ 'sentiment' ] = float ( ( '%.3f' % entity_sentiment ) ) json_doc [ 'avg_sentiment' ] = float ( ( '%.3f' % avg_sentiment ) ) return json . dumps ( json_doc )
convert entities and their associated sentiment to json .