コード例 #1
0
ファイル: cc_kedict.py プロジェクト: qnga/pyglossary
    def __init__(
        self,
        glos: GlossaryType,
        spellKey: str = "",
        posKey: str = "",
        synsKey: str = "",
        tagsKey: str = "",
    ):
        TextGlossaryReader.__init__(self, glos)
        self._spellKey = spellKey
        self._posKey = posKey
        self._synsKey = synsKey
        self._tagsKey = tagsKey

        self._posMapping = {
            "n": "noun",
            "v": "verb",
            "a": "adjective",
            "pron": "pronoun",
            "propn": "proper noun",
            "intj": "interjection",
            "det": "determiner",
            "part": "particle",
            "adv": "adverb",
            "num": "number",
            "abbrev": "abbreviation",
            "suf": "suffix",
            "pref": "prefix",
        }
コード例 #2
0
	def open(self, filename: str) -> None:
		try:
			import mistune
		except ModuleNotFoundError as e:
			e.msg += f", run `{pip} install mistune` to install"
			raise e
		TextGlossaryReader.open(self, filename)
		self._glos.setDefaultDefiFormat("h")
コード例 #3
0
 def __iter__(self) -> "Iterator[BaseEntry]":
     yield from TextGlossaryReader.__iter__(self)
     resDir = self._resDir
     for fname in self._resFileNames:
         with open(join(resDir, fname), "rb") as fromFile:
             yield self._glos.newDataEntry(
                 fname,
                 fromFile.read(),
             )
コード例 #4
0
 def open(self, filename: str) -> None:
     TextGlossaryReader.open(self, filename)
     resDir = f"{filename}_res"
     if isdir(resDir):
         self._resDir = resDir
         self._resFileNames = os.listdir(self._resDir)
コード例 #5
0
 def __init__(self, glos: GlossaryType, hasInfo: bool = True):
     TextGlossaryReader.__init__(self, glos, hasInfo=hasInfo)
     self._resDir = ""
     self._resFileNames = []