You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
425 B
18 lines
425 B
import sqlite3 |
|
import gptc |
|
|
|
con = sqlite3.connect("articles.db") |
|
con.execute("CREATE TABLE IF NOT EXISTS articles(source, category, url, text);") |
|
|
|
raw_model = [ |
|
{"text": i[0], "category": i[1]} |
|
for i in con.execute("SELECT text, category FROM articles;") |
|
] |
|
|
|
with open("model.gptc", "w+b") as f: |
|
f.write( |
|
gptc.compile(raw_model, max_ngram_length=3, min_count=3).serialize() |
|
) |
|
|
|
con.commit() |
|
con.close()
|
|
|