Step recorded: generate_renders
This commit is contained in:
parent
046aef031f
commit
dedc031696
|
@ -11,6 +11,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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
Loading…
Reference in New Issue
Block a user