import json
from collections import defaultdict
class Vocabulary(object):
def __init__(self):
# frequencies of entities
self.entities = defaultdict(int)
# frequencies of words
self.words = defaultdict(int)
def add(self, entities, words):
for entity, value in entities.items():
self.entities[entity] += value
for word, value in words.items():
self.words[word] += value
def add_word(self, word):
self.words[word] += 1
def to_dict(self):
return {
'entities': dict(self.entities),
'words': dict(self.words),
}
class Data(object):
NARRATOR = "