def set_doctypes(self, doctype1, doctype2): if doctype1 == doctype2: raise ValueError('Please enter two different doctypes') d = Db().get_doctype_counts() if doctype1 not in d.keys(): raise ValueError('Unknown doctype: ' + doctype1) if doctype2 not in d.keys(): raise ValueError('Unknown doctype: ' + doctype2) self.doctype1 = doctype1 self.doctype2 = doctype2
def execute(self): pl = [] db = Db() d = db.get_doctype_counts() self.doctype1_count = d.get(self.doctype1) self.doctype2_count = d.get(self.doctype2) self.doctype1_word_count = db.get_words_count(self.doctype1) self.doctype2_word_count = db.get_words_count(self.doctype2) for word in self.words: p = self.p_for_word(db, word) pl.append(p) result = self.p_from_list(pl) return result
def execute(self): Db().reset() Status().execute()
def execute(self): db = Db() return db.get_doctype_counts().items()
def is_doctype_valid(doctype): return Db().get_words_count(doctype) > 0