Changeset 226
- Timestamp:
- 11/10/12 18:39:27 (12 years ago)
- Location:
- pymigemo/trunk
- Files:
-
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
pymigemo/trunk/ChangeLog
r42 r226 1 2012-11-10 Atzm WATANABE <atzm@atzm.org> 2 3 * pymigemo.c: Python3 API support 4 1 5 *pymigemo-0.3 (07 Nov 2010) 2 6 2010-11-07 Atzm WATANABE <atzm@atzm.org> -
pymigemo/trunk/README.rst
r42 r226 1 $Id$1 .. $Id$ 2 2 3 = ããã¯äœïŒ = 4 C/Migemo ã Python ãã䜿ãããã® binding ã§ãïŒ 3 :mod:`migemo` --- C/Migemo ã® Python ãã€ã³ãã£ã³ã° 4 =================================================== 5 5 6 .. module:: migemo 7 :synopsis: C/Migemo ã® Python ãã€ã³ãã£ã³ã° 8 .. moduleauthor:: Atzm WATANABE <atzm@atzm.org> 6 9 7 = å¿ 8 èŠãªãã® = 9 C/Migemo ã©ã€ãã©ãªãã€ã³ã¹ããŒã«ãããŠããããšãåæãšãªã£ãŠããŸãïŒ 10 ã©ã€ãã©ãªæ€çŽ¢ãã¹ã« migemo.so ãïŒãããæ€çŽ¢ãã¹ã« migemo.h ãååšããããšãã確èªäžããïŒ 10 `C/Migemo <http://www.kaoriya.net/software/cmigemo>`_ ã 11 Python ããå©çšããããã®æ¡åŒµã¢ãžã¥ãŒã«ã§ãïŒ 11 12 13 ãã®ã¢ãžã¥ãŒã«ã®å©çšã«ããã£ãŠã¯ïŒ 14 C/Migemo ãã€ã³ã¹ããŒã«ãããŠããããšãåæãšãªã£ãŠããŸãïŒ 15 ã©ã€ãã©ãªæ€çŽ¢ãã¹ã« migemo.so ãïŒ 16 ãããæ€çŽ¢ãã¹ã« migemo.h ãååšããããšãã確èªäžããïŒ 12 17 13 = ã€ã³ã¹ããŒã«æ¹æ³ = 14 å梱㮠setup.py ããå©çšäžããïŒ 18 ã€ã³ã¹ããŒã« 19 ------------ 20 å梱㮠setup.py ããå©çšäžãã:: 15 21 16 {{{ 17 $ ./setup.py build 18 # ./setup.py install 19 }}} 22 $ ./setup.py build 23 # ./setup.py install 20 24 25 åºæ¬çãªäœ¿ãæ¹ 26 -------------- 27 åºæ¬çãªäœ¿ãæ¹ã¯ä»¥äžã®ããã«ãªããŸã:: 21 28 22 = ã©ã€ã»ã³ã¹ = 29 >>> import migemo 30 >>> m = migemo.Migemo('/usr/share/migemo/migemo-dict') 31 >>> print(m.query('hoge')) 32 (hoge|ïœïœïœïœ 33 |ã»ã|æ鯚|åžæ¡|è£å 34 |ãã²) 35 36 :meth:`Migemo.query` ã¡ãœããã«æååãæž¡ããšïŒæ£èŠè¡šçŸã unicode ã§è¿ããŸãïŒ 37 ãã®æ£èŠè¡šçŸã :mod:`re` ãšçµã¿åãããã°æ€çŽ¢çã®çšéã«å©çšããããšãã§ããŸãïŒ 38 39 .. note:: 40 è¿åŽãããæ£èŠè¡šçŸã¯èªã¿èŸŒãã èŸæžã«ãã£ãŠç°ãªãã®ã§ïŒ 41 å¿ 42 ãããäžèšã®éãã«ãªããšã¯éããŸããïŒ 43 44 ãªãã¡ã¬ã³ã¹ 45 ------------ 46 47 :class:`Migemo` ã¯ã©ã¹ 48 `````````````````````` 49 50 .. class:: Migemo(dictionary) 51 52 migemo ããã³ãã«ããã¯ã©ã¹ã§ãïŒ 53 *dictionary* ã¯å©çšãã migemo-dict èŸæžãã¡ã€ã«ã®ãã¹ã§ãïŒ 54 55 .. method:: query(query) 56 57 *query* ããæ£èŠè¡šçŸã unicode ã§è¿ããŸãïŒ 58 *query* 㯠unicode ã§ããšã³ã³ãŒããããæååã§ãæ§ããŸããïŒ 59 ãã ã *query* ãæååã®å ŽåïŒ 60 ãã®ãšã³ã³ãŒãã£ã³ã°ãèŸæžã®ãšã³ã³ãŒãã£ã³ã°ãšç°ãªããšïŒ 61 ãšã©ãŒãšãªãå¯èœæ§ããããŸãïŒ 62 63 .. method:: is_enable() 64 65 èŸæžãæ£åžžã«èªã¿èŸŒããŠãããã©ãããã§ãã¯ããŸãïŒ 66 æ£åžžã«èªã¿èŸŒããŠããå Žå㯠``True`` ãïŒ 67 ããã§ãªãå Žå㯠``False`` ãè¿ããŸãïŒ 68 69 .. method:: load(dict_id, dict_file) 70 71 èŸæžãèªã¿èŸŒã¿ãŸãïŒ 72 *dict_id* ã¯åŸè¿°ã® DICTID ã®ããããã§ïŒèªã¿èŸŒãèŸæžã®çš®é¡ãæå®ããŸãïŒ 73 *dict_file* ã¯èŸæžãã¡ã€ã«ã®ãã¹ã§ãïŒ 74 ãã®ã¡ãœããã¯æåãããšèªã¿èŸŒãã èŸæžã® DICTID ãè¿ããŸãïŒ 75 èªã¿èŸŒã¿ã«å€±æããå Žå㯠:data:`DICTID_INVALID` ãè¿ããŸãïŒ 76 77 .. method:: get_operator(index) 78 79 *index* ã§æå®ãããïŒæ£èŠè¡šçŸã«äœ¿çšããã¡ã¿æåãè¿ããŸãïŒ 80 *index* ã¯åŸè¿°ã® OPINDEX ã®ãããããæå®ããå¿ 81 èŠããããŸãïŒ 82 83 .. method:: set_operator(index, op) 84 85 *index* ã§æå®ãããæ£èŠè¡šçŸã«äœ¿çšããã¡ã¿æåã *op* ã«å€æŽããŸãïŒ 86 *index* ã¯åŸè¿°ã® OPINDEX ã®ãããããæå®ããå¿ 87 èŠããããŸãïŒ 88 å€æŽã«æåããã° ``True`` ãïŒå€±æããã° ``False`` ãè¿ããŸãïŒ 89 90 .. method:: get_encoding() 91 92 èªã¿èŸŒãã èŸæžã®ãšã³ã³ãŒãã£ã³ã°ãæååã§è¿ããŸãïŒ 93 äŸãã° EUC-JP ã§æžãããèŸæžã§ããã° ``'euc_jp'`` ãè¿ããŸãïŒ 94 ``'cp932'`` ã ``'euc_jp'`` ã ``'utf8'`` ã ``'ascii'`` 95 ã®ãããããè¿ããŸãïŒ 96 97 DICTID 98 `````` 99 100 :meth:`Migemo.load` ã§å©çšããèŸæžã®çš®é¡ã§ãïŒ 101 102 .. data:: DICTID_MIGEMO 103 104 migemo-dict èŸæžã瀺ããŸãïŒ 105 106 .. data:: DICTID_ROMA2HIRA 107 108 ããŒãåâ平仮åå€æè¡šã瀺ããŸãïŒ 109 110 .. data:: DICTID_HIRA2KATA 111 112 平仮åâã«ã¿ã«ãå€æè¡šã瀺ããŸãïŒ 113 114 .. data:: DICTID_HAN2ZEN 115 116 åè§âå 117 šè§å€æè¡šã瀺ããŸãïŒ 118 119 .. data:: DICTID_ZEN2HAN 120 121 å 122 šè§âåè§å€æè¡šã瀺ããŸãïŒ 123 124 .. data:: DICTID_INVALID 125 126 èŸæžã®èªã¿èŸŒã¿ã«å€±æããå Žåã«è¿ã DICTID ã§ãïŒ 127 128 OPINDEX 129 ``````` 130 131 :meth:`Migemo.get_operator` ãŸã㯠:meth:`Migemo.set_operator` 132 ã§å©çšããã¡ã¿æåã®çš®é¡ã§ãïŒ 133 134 .. data:: OPINDEX_OR 135 136 è«çåã瀺ããŸãïŒ 137 ããã©ã«ã㯠``'|'`` ã§ãïŒ 138 139 .. data:: OPINDEX_NEST_IN 140 141 ã°ã«ãŒãã³ã°æã®éãæ¬åŒ§ã瀺ããŸãïŒ 142 ããã©ã«ã㯠``'('`` ã§ãïŒ 143 144 .. data:: OPINDEX_NEST_OUT 145 146 ã°ã«ãŒãã³ã°æã®éãæ¬åŒ§ã瀺ããŸãïŒïŒ 147 ããã©ã«ã㯠``')'`` ã§ãïŒ 148 149 .. data:: OPINDEX_SELECT_IN 150 151 éžæã®éå§ãè¡šãéãéæ¬åŒ§ã瀺ããŸãïŒ 152 ããã©ã«ã㯠``'['`` ã§ãïŒ 153 154 .. data:: OPINDEX_SELECT_OUT 155 156 éžæã®çµäºãè¡šãéãéæ¬åŒ§ã瀺ããŸãïŒ 157 ããã©ã«ã㯠``']'`` ã§ãïŒ 158 159 .. data:: OPINDEX_NEWLINE 160 161 åæåã®éã«æ¿å 162 ¥ãããã0 å以äžã®ç©ºçœãããã¯æ¹è¡ã«ãããããã 163 ãã¿ãŒã³ã瀺ããŸãïŒ 164 ããã©ã«ã㯠``''`` ã§ãïŒ 165 166 VERSION 167 ``````` 168 169 migemo ã®ããŒãžã§ã³ã§ãïŒ 170 171 .. data:: MIGEMO_VERSION 172 173 C/Migemo ã®ããŒãžã§ã³ã瀺ããŸãïŒ 174 175 .. data:: PYMIGEMO_VERSION 176 177 PyMigemo ã®ããŒãžã§ã³ã瀺ããŸãïŒ 178 179 ã©ã€ã»ã³ã¹ 180 ---------- 23 181 äºæ¡é 24 182 BSD ã©ã€ã»ã³ã¹ã«æºæ ããŸãïŒ 25 183 詳现ã¯å梱㮠LICENSE ãã¡ã€ã«ãã芧äžããïŒ 26 27 28 = 䜿ãæ¹ =29 {{{30 >>> import migemo31 >>> m = migemo.Migemo("/usr/share/migemo/migemo-dict")32 >>> print m.query("hoge")33 (hoge|ïœïœïœïœ34 |ã»ã|æ鯚|åžæ¡|è£å35 |ãã²)36 }}}37 * â» query() çµæã¯èªã¿èŸŒãã èŸæžã«ãã£ãŠç°ãªããŸã38 39 40 == ãªãã¡ã¬ã³ã¹ ==41 === ã¢ãžã¥ãŒã«ã³ã³ãã³ã ===42 * VERSION43 * MIGEMO_VERSION44 * C/Migemo ã®ããŒãžã§ã³45 * PYMIGEMO_VERSION46 * PyMigemo ã®ããŒãžã§ã³47 48 * DICTID49 * DICTID_MIGEMO50 * migemo-dict èŸæž51 * DICTID_ROMA2HIRA52 * ããŒãåâ平仮åå€æè¡š53 * DICTID_HIRA2KATA54 * 平仮åâã«ã¿ã«ãå€æè¡š55 * DICTID_HAN2ZEN56 * åè§âå57 šè§å€æè¡š58 * DICTID_ZEN2HAN59 * å60 šè§âåè§å€æè¡š61 * DICTID_INVALID62 * load ã¡ãœããã§èŸæžã®èªã¿èŸŒã¿ã«å€±æããå Žåã«è¿ã63 64 * OPINDEX65 * OPINDEX_OR66 * è«çå67 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠"|"68 * OPINDEX_NEST_IN69 * ã°ã«ãŒãã³ã°æã®éãæ¬åŒ§70 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠"("71 * OPINDEX_NEST_OUT72 * ã°ã«ãŒãã³ã°æã®éãæ¬åŒ§73 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠")"74 * OPINDEX_SELECT_IN75 * éžæã®éå§ãè¡šãéãéæ¬åŒ§76 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠"["77 * OPINDEX_SELECT_OUT78 * éžæã®çµäºãè¡šãéãéæ¬åŒ§79 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠"]"80 * OPINDEX_NEWLINE81 * åæåã®éã«æ¿å82 ¥ãããã0 å以äžã®ç©ºçœãããã¯æ¹è¡ã«ãããããããã¿ãŒã³83 * Migemo.get_operator() ã«æž¡ããéã®ããã©ã«ã㯠"" (空æåå)84 85 * Migemo ã¯ã©ã¹86 * __init__(dictionary)87 * Migemo ã¯ã©ã¹ã®ã³ã³ã¹ãã©ã¯ã¿88 * åŒæ°89 * dictionary: migemo-dict èŸæžãã¡ã€ã«ã®ãã¹ (str)90 * get_encoding()91 * migemo-dict èŸæžã®ãšã³ã³ãŒãã£ã³ã°ã str ã§è¿ãïŒ92 äŸãã° EUC-JP ã§æžãããèŸæžã§ããã° "euc_jp" ãè¿ãïŒ93 cp932ïŒeuc_jpïŒutf8 ã®ãããããè¿ããïŒ94 èŸæžã®ãšã³ã³ãŒãã£ã³ã°ããããã«è©²åœããªãã£ãå Žå㯠"ascii" ãè¿ã95 * åŒæ°96 * ãªã97 * è¿ãå€98 * ãšã³ã³ãŒãã£ã³ã°æåå (str)99 * get_operator(index)100 * index ã§æå®ãããïŒæ£èŠè¡šçŸã«äœ¿çšããã¡ã¿æåãè¿ã (str)101 * åŒæ°102 * index: åè¿°ã® OPINDEX ã®ãããã103 * è¿ãå€104 * ã¡ã¿æåå (str)105 * is_enable()106 * Migemo å107 éšã«ïŒæ£åžžã«èŸæžãèªã¿èŸŒããŠãããã©ããããã§ãã¯ãã108 * åŒæ°109 * ãªã110 * è¿ãå€111 * çåœå€ : æ£åžžã«èªã¿èŸŒããŠããå Žåã«ç112 * load(dict_id, dict_file)113 * Migemo ãªããžã§ã¯ãã«èŸæžãè¿œå ã§èªã¿èŸŒã114 * åŒæ°115 * dict_id: åè¿°ã® DICTID ã®ãããã116 * dict_file: èŸæžãã¡ã€ã«ã®ãã¹117 * è¿ãå€118 * èªã¿èŸŒãã èŸæžã® DICTIDïŒ119 èªã¿èŸŒã¿ã«å€±æããå Žå DICTID_INVALID ãè¿ã120 * query(query)121 * query ã§äžããããæååããæ¥æ¬èªæ€çŽ¢ã®ããã®æ£èŠè¡šçŸãè¿ã122 * åŒæ°123 * query: åãåãããæåå (Unicode or str)ïŒ124 str 㧠ascii 以å€ã®æååãæž¡ãå ŽåïŒ125 èŸæžãšåããšã³ã³ãŒãã£ã³ã°ã®æååã§ãªããšãšã©ãŒã«ãªãå¯èœæ§ããã126 * è¿ãå€127 * æ£èŠè¡šçŸæåå (Unicode)128 * set_operator(index, op)129 * index ã§æå®ãããïŒæ£èŠè¡šçŸã«äœ¿çšããã¡ã¿æåã op ã«å€æŽãã130 * åŒæ°131 * index: åè¿°ã® OPINDEX ã®ãããã132 * op: ã¡ã¿æåå (str)133 * è¿ãå€134 * çåœå€ : æåæã«ç135 136 137 = ãã®ä» =138 æ¬ãœãããŠã§ã¢ã«å¯Ÿããã³ã¡ã³ãïŒãã°å ±åïŒããããªã©ã¯å€§ãã«æè¿ããŸãïŒ139 äžèšã¡ãŒã«ã¢ãã¬ã¹ãŸã§ãæ°è»œã«ãå¯ãäžããïŒ140 141 Atzm WATANABE <atzm@atzm.org>
Note: See TracChangeset
for help on using the changeset viewer.