Create v2 models

This commit is contained in:
Samuel Sloniker 2021-11-07 10:42:38 -08:00
parent b3d975f3d1
commit 3baafa46fc

View File

@ -42,7 +42,12 @@ def compile(raw_model):
except KeyError: except KeyError:
word_weights[word] = {category:value} word_weights[word] = {category:value}
word_weights['__version__'] = 1 model = {}
word_weights['__raw__'] = raw_model for word, weights in word_weights.items():
total = sum(weights.values())
model[word] = {category: weight/total for category, weight in weights.items()}
return word_weights model['__version__'] = 2
model['__raw__'] = raw_model
return model