Use Classifier for --category

This commit is contained in:
Samuel Sloniker 2022-11-26 17:50:26 -08:00
parent b3a43150d8
commit 548d670960
Signed by: kj7rrv
GPG Key ID: 1BB4029E66285A62

View File

@ -74,14 +74,12 @@ def main() -> None:
else:
text = sys.stdin.read()
probabilities = model.confidence(text, args.max_ngram_length)
if args.category:
try:
print(sorted(probabilities.items(), key=lambda x: x[1])[-1][0])
except IndexError:
print(None)
classifier = gptc.Classifier(model, args.max_ngram_length)
print(classifier.classify(text))
else:
probabilities = model.confidence(text, args.max_ngram_length)
print(json.dumps(probabilities))
else:
print(json.dumps(gptc.pack(args.model, True)[0]))