d = defaultdict(list)
with open('doc1') as f:
    with open('doc2') as f2:
        values = map(float, f2.read().split())
for line in f:
    if line.strip() and not line.startswith('TOPIC'):
        name, val = line.split()
d[name].append(float(val))
for k, v in list(d.items()):
    pass
Как определить вероятность слов?