diff --git a/src/database.py b/src/database.py index 32da2a2..547abee 100644 --- a/src/database.py +++ b/src/database.py @@ -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) diff --git a/src/word_stats.py b/src/word_stats.py index 0462bee..341e8d6 100644 --- a/src/word_stats.py +++ b/src/word_stats.py @@ -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):