{"action":"created","issue":{"url":"https://api.github.com/repos/EasyIME/PIME/issues/155","repository_url":"https://api.github.com/repos/EasyIME/PIME","labels_url":"https://api.github.com/repos/EasyIME/PIME/issues/155/labels{/name}","comments_url":"https://api.github.com/repos/EasyIME/PIME/issues/155/comments","events_url":"https://api.github.com/repos/EasyIME/PIME/issues/155/events","html_url":"https://github.com/EasyIME/PIME/issues/155","id":168030816,"number":155,"title":"有關定制輸入法行為問題","user":{"login":"KennethWong355","id":20685900,"avatar_url":"https://avatars.githubusercontent.com/u/20685900?v=3","gravatar_id":"","url":"https://api.github.com/users/KennethWong355","html_url":"https://github.com/KennethWong355","followers_url":"https://api.github.com/users/KennethWong355/followers","following_url":"https://api.github.com/users/KennethWong355/following{/other_user}","gists_url":"https://api.github.com/users/KennethWong355/gists{/gist_id}","starred_url":"https://api.github.com/users/KennethWong355/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KennethWong355/subscriptions","organizations_url":"https://api.github.com/users/KennethWong355/orgs","repos_url":"https://api.github.com/users/KennethWong355/repos","events_url":"https://api.github.com/users/KennethWong355/events{/privacy}","received_events_url":"https://api.github.com/users/KennethWong355/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-07-28T07:27:27Z","updated_at":"2016-07-28T09:41:44Z","closed_at":null,"body":"[版本：0.14]\r\n\r\nKenLuoTW ，你好：\r\n\r\n我想把輸入法的候選字輸出個人化， 例如酷倉輸入法，現在打 “日”字， 只會出現 ‘’日‘’ 跟 ‘’曰‘’ 這\r\n兩個字，但我想打 ‘’日‘’字的時候， 所有 “日\" 字開頭的 字都會出現在候選字選單， 就如 (aaa 的 “晶\") 和\r\n (aitc 的“曠”) 。\r\n---------------------------------------------checj.cin --------------------------------------------------\r\na 日\r\na 曰\r\naa 昌\r\naaa 晶\r\naamh 暘\r\n...\r\naitc 曠\r\n---------------------------------------------checj.cin END ---------------------------------------------\r\n\r\n\r\n\r\n\r\n\r\n\r\n我嘗試過對  “cin.py” 的  ”def getCharDef(self, key)”  作不同的修改，可是修改完打字就當機，\r\n請問可以怎樣修改？\r\n\r\n原本的 def getCharDef(self, key)：\r\ndef getCharDef(self, key): \r\n      return self.chardefs[key]\r\n\r\n修改版本A：\r\ndef getCharDef(self, key):\r\nreturn next( v for k,v in self.chardefs.items() if k.startswith(key))\r\n\r\n修改版本B：\r\nresult=[]\r\n\r\ndef getCharDef(self, key):\r\n        for d in self.chardefs.keys():\r\n            if key == d[0]:\r\n               result.extend(self.chardefs[d])\r\nreturn result\r\n\r\n修改版本C：\r\naCharDefTempList =[]\r\nbCharDefTempList =[]\r\ncCharDefTempList =[]\r\ndCharDefTempList =[]\r\neCharDefTempList =[]\r\n\r\ndef getCharDef(self, key):\r\naCharDefTempList = self.chardefs[key]\r\nbCharDefTempList = self.chardefs[key+key]   \r\ncCharDefTempList = self.chardefs[key+key+key]\r\ndCharDefTempList = self.chardefs[key+key+key+key]\r\neCharDefTempList = self.chardefs[key+key+key+key+key]\r\nreturn list(itertools.chain(aCharDefTempList, bCharDefTempList, cCharDefTempList, dCharDefTempList, eCharDefTempList))\r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/EasyIME/PIME/issues/comments/235848572","html_url":"https://github.com/EasyIME/PIME/issues/155#issuecomment-235848572","issue_url":"https://api.github.com/repos/EasyIME/PIME/issues/155","id":235848572,"user":{"login":"KennethWong355","id":20685900,"avatar_url":"https://avatars.githubusercontent.com/u/20685900?v=3","gravatar_id":"","url":"https://api.github.com/users/KennethWong355","html_url":"https://github.com/KennethWong355","followers_url":"https://api.github.com/users/KennethWong355/followers","following_url":"https://api.github.com/users/KennethWong355/following{/other_user}","gists_url":"https://api.github.com/users/KennethWong355/gists{/gist_id}","starred_url":"https://api.github.com/users/KennethWong355/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KennethWong355/subscriptions","organizations_url":"https://api.github.com/users/KennethWong355/orgs","repos_url":"https://api.github.com/users/KennethWong355/repos","events_url":"https://api.github.com/users/KennethWong355/events{/privacy}","received_events_url":"https://api.github.com/users/KennethWong355/received_events","type":"User","site_admin":false},"created_at":"2016-07-28T09:41:43Z","updated_at":"2016-07-28T09:41:43Z","body":"還有一個問題我想問問，這個project 是不是沒法運行 “Debug 模式” ？（如果能運行Debug 模式的話， 應該怎麼運行？）\r\n\r\n\r\n我試過在 （cinbase 下的 __init__.py）  和 （cin.py）加  logging，在任何一個加logging， 運行輸入法就會當機， 想寫 logging 來 Debug要怎麼辦？\r\n\r\n#  __init__.py 加  logging\r\n\r\nimport winsound\r\n**import logging** \r\nfrom .swkb import swkb\r\n\r\n....\r\n\r\nclass CinBase:\r\n    def __init__(self):\r\n        self.cinbasecurdir = os.path.abspath(os.path.dirname(__file__))\r\n\r\n\r\n  # 初始化輸入行為設定\r\n    def initTextService(self, CinBaseTextService):\r\n        # 使用 OpenCC 繁體中文轉簡體\r\n        CinBaseTextService.opencc = None\r\n        CinBaseTextService.langMode = -1\r\n.\r\n.\r\n.       \r\n        **LOG_FILENAME = 'tsfLog.log' \r\n        logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)**\r\n.\r\n.\r\n.\r\n            # 組字字根超過最大值\r\n            if len(CinBaseTextService.compositionChar) > CinBaseTextService.maxCharLength:\r\n                if CinBaseTextService.cin.isInKeyName(CinBaseTextService.compositionChar[len(CinBaseTextService.compositionChar)-1:]):\r\n                    keyLength = len(CinBaseTextService.cin.getKeyName(CinBaseTextService.compositionChar[len(CinBaseTextService.compositionChar)-1:]))\r\n                else:\r\n                    keyLength = 1\r\n                CinBaseTextService.setCompositionString(CinBaseTextService.compositionString[:-keyLength])\r\n                CinBaseTextService.compositionChar = CinBaseTextService.compositionChar[:-1]\r\n                if CinBaseTextService.cin.isInCharDef(CinBaseTextService.compositionChar) and CinBaseTextService.closemenu:\r\n\r\n**logging.debug('Before enter function')**\t\r\ncandidates = CinBaseTextService.cin.getCharDef(CinBaseTextService.compositionChar, CinBaseTextService.candMaxItems)\r\n\r\n\r\n---------------------------------------------------------------------------------------------------------------\r\n\r\n#  cin.py 加 logging\r\n\r\nfrom __future__ import print_function\r\nfrom __future__ import unicode_literals\r\nimport re\r\n**import logging** \r\n\r\ndef __init__(self, fs):\r\n    state = PARSING_HEAD_STATE\r\n    **LOG_FILENAME = 'tsfLog.log' \r\n    logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG)**\r\n.\r\n.\r\n.\r\n\r\ndef getCharDef(self, key): \r\n**logging.debug('Enter function getCharDef()')**\r\nreturn self.chardefs[key]\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"KennethWong355"}}