From 378a23608d00438f32088474ea0d2166d63f6584 Mon Sep 17 00:00:00 2001 From: kj7rrv Date: Tue, 16 Nov 2021 21:50:59 -0800 Subject: [PATCH] Model v3 --- {src/gptc => gptc}/__init__.py | 0 {src/gptc => gptc}/__main__.py | 0 {src/gptc => gptc}/classifier.py | 5 +++-- {src/gptc => gptc}/compiler.py | 4 ++-- {src/gptc => gptc}/exceptions.py | 0 {src/gptc => gptc}/tokenizer.py | 0 6 files changed, 5 insertions(+), 4 deletions(-) rename {src/gptc => gptc}/__init__.py (100%) rename {src/gptc => gptc}/__main__.py (100%) rename {src/gptc => gptc}/classifier.py (93%) rename {src/gptc => gptc}/compiler.py (93%) rename {src/gptc => gptc}/exceptions.py (100%) rename {src/gptc => gptc}/tokenizer.py (100%) diff --git a/src/gptc/__init__.py b/gptc/__init__.py similarity index 100% rename from src/gptc/__init__.py rename to gptc/__init__.py diff --git a/src/gptc/__main__.py b/gptc/__main__.py similarity index 100% rename from src/gptc/__main__.py rename to gptc/__main__.py diff --git a/src/gptc/classifier.py b/gptc/classifier.py similarity index 93% rename from src/gptc/classifier.py rename to gptc/classifier.py index 8fdd1eb..c424a93 100755 --- a/src/gptc/classifier.py +++ b/gptc/classifier.py @@ -22,7 +22,7 @@ class Classifier: except: model_version = 1 - if model_version == 2: + if model_version == 3: self.model = model else: # The model is an unsupported version @@ -63,8 +63,9 @@ class Classifier: probs[category] = value except KeyError: pass + probs = {model['__names__'][category]: value/65535 for category, value in probs.items()} total = sum(probs.values()) - probs = {model['__names__'][category]: value/total for category, value in probs.items()} + probs = {category: value/total for category, value in probs.items()} return probs def classify(self, text): diff --git a/src/gptc/compiler.py b/gptc/compiler.py similarity index 93% rename from src/gptc/compiler.py rename to gptc/compiler.py index 54a1032..d7c34ce 100755 --- a/src/gptc/compiler.py +++ b/gptc/compiler.py @@ -52,11 +52,11 @@ def compile(raw_model): total = sum(weights.values()) model[word] = [] for category in names: - model[word].append(weights.get(category, 0)/total) + model[word].append(round((weights.get(category, 0)/total)*65535)) model['__names__'] = names - model['__version__'] = 2 + model['__version__'] = 3 model['__raw__'] = raw_model return model diff --git a/src/gptc/exceptions.py b/gptc/exceptions.py similarity index 100% rename from src/gptc/exceptions.py rename to gptc/exceptions.py diff --git a/src/gptc/tokenizer.py b/gptc/tokenizer.py similarity index 100% rename from src/gptc/tokenizer.py rename to gptc/tokenizer.py