From 314bdef1c529f992ee6d50651522f16e4f6d78e2 Mon Sep 17 00:00:00 2001 From: Samuel Sloniker Date: Sat, 26 Nov 2022 13:05:37 -0800 Subject: [PATCH] Compiler settings --- compile.py | 12 ++++++++++-- compiler.toml | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 compiler.toml diff --git a/compile.py b/compile.py index 716209b..a2e72cb 100755 --- a/compile.py +++ b/compile.py @@ -14,11 +14,15 @@ # details. # # You should have received a copy of the GNU General Public License along with -# this program. If not, see . +# this program. If not, see . import sqlite3 +import tomli import gptc +with open("compiler.toml", "rb") as f: + config = tomli.load(f) + con = sqlite3.connect("articles.db") con.execute("CREATE TABLE IF NOT EXISTS articles(source, category, url, text);") @@ -29,7 +33,11 @@ raw_model = [ with open("model.gptc", "w+b") as f: f.write( - gptc.compile(raw_model, max_ngram_length=3, min_count=5).serialize() + gptc.compile( + raw_model, + max_ngram_length=config["max_ngram_length"], + min_count=config["min_count"], + ).serialize() ) con.commit() diff --git a/compiler.toml b/compiler.toml new file mode 100644 index 0000000..099793f --- /dev/null +++ b/compiler.toml @@ -0,0 +1,2 @@ +max_ngram_length=3 +min_count=5