Step recorded: generate_renders

This commit is contained in:
Ozbolt Menegatti 2019-08-21 12:16:10 +02:00
parent 046aef031f
commit dedc031696
2 changed files with 11 additions and 0 deletions

View File

@ -10,6 +10,9 @@ class Database:
self.new = not os.path.exists(filename)
self.db = sqlite3.connect(filename)
self.init("CREATE TABLE StepsDone ( step varchar(32) )")
self.commit()
def execute(self, *args, **kwargs):
return self.db.execute(*args, **kwargs)

View File

@ -42,6 +42,12 @@ class WordStats:
return self.all_words
def generate_renders(self):
step_name = 'generate_renders'
wc_done = self.db.execute("SELECT count(*) FROM StepsDone WHERE step=?", (step_name, )).fetchone()
if wc_done[0] == 1:
print("Skipping GenerateRenders, already complete")
return
lemmas = [lemma for (lemma, ) in self.db.execute("SELECT DISTINCT lemma FROM UniqWords")]
for lemma in progress(lemmas, 'word-count'):
num_words = defaultdict(int)
@ -51,6 +57,8 @@ class WordStats:
for msd0, freq in num_words.items():
self.db.execute("INSERT INTO WordCount (lemma, msd0, frequency) VALUES (?,?,?)",
(lemma, msd0, freq))
self.db.execute("INSERT INTO StepsDone (step) VALUES (?)", (step_name, ))
self.db.commit()
def common_lemma_msd(self, lemma, msd):