def _import_definition_assocs(self, def_text, def_id): if def_text is not None: morpheme_list = self._import_parse_morphemes(def_text) if len(morpheme_list) > 0: for m in morpheme_list: m["definition_id"] = def_id db.insert_many(self.session, models.DefinitionConsistsOf, morpheme_list)
def _import_expression(self, expression): expression_id, new = db.insert(self.session, models.Expression, expression=expression) if new: morpheme_list = self._import_parse_morphemes(expression) if len(morpheme_list) > 0: for m in morpheme_list: m["expression_id"] = expression_id db.insert_many(self.session, models.ExpressionConsistsOf, morpheme_list) return expression_id
def visit_kanji_list(self, kanji_list): entry_kanji = list() if self.eformat == "J-J1": for i, kanji_text in enumerate(kanji_list): assert self.last_kana_text is not None kanji_id = db.insert( self.session, models.Morpheme, morpheme=uf.unformat_jj1_kanji(kanji_text, self.last_kana_text), type_id=db_constants.MORPHEME_TYPES_TO_ID["KANJI_ENTRY"], status_id=db_constants.MORPHEME_STATUSES_TO_ID["AUTO"], )[0] entry_kanji.append({"entry_id": self.entry_id, "kanji_id": kanji_id, "number": i + 1}) else: for i, kanji_text in enumerate(kanji_list): kanji_id = db.insert( self.session, models.Morpheme, morpheme=kanji_text, type_id=db_constants.MORPHEME_TYPES_TO_ID["KANJI_ENTRY"], status_id=db_constants.MORPHEME_STATUSES_TO_ID["AUTO"], )[0] entry_kanji.append({"entry_id": self.entry_id, "kanji_id": kanji_id, "number": i + 1}) db.insert_many(self.session, models.EntryHasKanji, entry_kanji)
def visit_finish_definition_ues(self): db.insert_many(self.session, models.DefinitionHasUEs, self.definition_ues)