From 3baafa46fc8c885191146d47c57e3d41b7fd2974 Mon Sep 17 00:00:00 2001 From: kj7rrv Date: Sun, 7 Nov 2021 10:42:38 -0800 Subject: [PATCH] Create v2 models --- gptc/compiler.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gptc/compiler.py b/gptc/compiler.py index 5c1c19e..865f719 100755 --- a/gptc/compiler.py +++ b/gptc/compiler.py @@ -42,7 +42,12 @@ def compile(raw_model): except KeyError: word_weights[word] = {category:value} - word_weights['__version__'] = 1 - word_weights['__raw__'] = raw_model + 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