示例#1
0
 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)
示例#2
0
    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
示例#3
0
 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)
示例#4
0
 def visit_finish_definition_ues(self):
     db.insert_many(self.session, models.DefinitionHasUEs, self.definition_ues)