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

View File

@ -43,8 +43,7 @@ class WordStats:
def generate_renders(self): def generate_renders(self):
step_name = 'generate_renders' step_name = 'generate_renders'
wc_done = self.db.execute("SELECT count(*) FROM StepsDone WHERE step=?", (step_name, )).fetchone() if self.db.is_step_done(step_name):
if wc_done[0] == 1:
print("Skipping GenerateRenders, already complete") print("Skipping GenerateRenders, already complete")
return return
@ -58,8 +57,7 @@ class WordStats:
self.db.execute("INSERT INTO WordCount (lemma, msd0, frequency) VALUES (?,?,?)", self.db.execute("INSERT INTO WordCount (lemma, msd0, frequency) VALUES (?,?,?)",
(lemma, msd0, freq)) (lemma, msd0, freq))
self.db.execute("INSERT INTO StepsDone (step) VALUES (?)", (step_name, )) self.db.step_is_done(step_name)
self.db.commit()
def common_lemma_msd(self, lemma, msd): def common_lemma_msd(self, lemma, msd):
lf = self.lemma_features lf = self.lemma_features