コード例 #1
0
ファイル: mecabman.py プロジェクト: blackknifes/VNR-Core
 def parse(self, text, rubyType, rubyKana=False):
     """
 @param  rubyType  str
 @param* rubyKana  bool
 @yield  (unicode surface, unicode ruby, unicode feature) or return None
 """
     tr = dictman.manager(
     ).translateJapanese if self.__d.translateEnabled and dictman.manager(
     ).japaneseTranslateLanguages() else None
     try:
         return self.__d.getParser().iterparseToRuby(
             text, rubyType, tr=tr, show_ruby_kana=rubyKana)
     except Exception, e:
         dwarn(e)
コード例 #2
0
 def renderKorean(self, text):
   """
   @param  text  unicode
   @return  unicode
   """
   ret = ""
   if self._renderMutex.tryLock():
     ret = dictman.manager().renderKorean(text)
     self._renderMutex.unlock()
   else:
     dwarn("ignore thread contention")
   return ret
コード例 #3
0
 def renderJapanese(self, text):
   """
   @param  text  unicode
   @return  unicode
   """
   ret = ""
   feature = GrimoireBean.instance.lookupFeature(text)
   if self._renderMutex.tryLock():
     ret = skthreads.runsync(partial(
         dictman.manager().renderJapanese, text, exact=True,feature=feature)) # do exact match for speed
     self._renderMutex.unlock()
   else:
     dwarn("ignore thread contention")
   return ret
コード例 #4
0
 def submit(self):
     t = self._getInputText()
     if t:
         h = dictman.manager().renderJapanese(t)
         self.resultEdit.setHtml(h)
コード例 #5
0
 def render_hanzi(self, text):
     import dictman
     return '\n'.join(dictman.manager().renderHanzi(text))