step_done now implemented in database.py

This commit is contained in:
Ozbolt Menegatti 2019-08-21 12:57:42 +02:00
parent 3ea62ed242
commit 33528f1495
3 changed files with 13 additions and 10 deletions

View File

@ -24,3 +24,12 @@ class Database:
def commit(self):
self.db.commit()
def is_step_done(self, step_name):
wc_done = self.db.execute("SELECT count(*) FROM StepsDone WHERE step=?", (step_name, )).fetchone()
return wc_done[0] != 0
def step_is_done(self, step_name):
self.db.execute("INSERT INTO StepsDone (step) VALUES (?)", (step_name, ))
self.db.commit()

View File

@ -104,9 +104,7 @@ class MatchStore:
def determine_colocation_dispersions(self):
step_name = 'dispersions'
wc_done = self.db.execute("SELECT count(*) FROM StepsDone WHERE step=?", (step_name, )).fetchone()
if wc_done[0] == 1:
if self.db.is_step_done(step_name):
self.load_dispersions()
return
@ -120,9 +118,7 @@ class MatchStore:
print("Storing dispersions...")
self.store_dispersions()
self.db.execute("INSERT INTO StepsDone (step) VALUES (?)", (step_name, ))
self.db.commit()
self.db.step_is_done(step_name)
def store_dispersions(self):
for (structure_id, component_id, lemma), disp in self.dispersions.items():

View File

@ -43,8 +43,7 @@ class WordStats:
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:
if self.db.is_step_done(step_name):
print("Skipping GenerateRenders, already complete")
return
@ -58,8 +57,7 @@ class WordStats:
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()
self.db.step_is_done(step_name)
def common_lemma_msd(self, lemma, msd):
lf = self.lemma_features