12 # |
12 # |
13 # This library is free software; you can redistribute it and/or |
13 # This library is free software; you can redistribute it and/or |
14 # modify it under the terms of the GNU Lesser General Public |
14 # modify it under the terms of the GNU Lesser General Public |
15 # License as published by the Free Software Foundation; either |
15 # License as published by the Free Software Foundation; either |
16 # version 2.1 of the License, or (at your option) any later version. |
16 # version 2.1 of the License, or (at your option) any later version. |
17 # |
17 # |
18 # This library is distributed in the hope that it will be useful, |
18 # This library is distributed in the hope that it will be useful, |
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
21 # Lesser General Public License for more details. |
21 # Lesser General Public License for more details. |
22 # |
22 # |
23 # You should have received a copy of the GNU Lesser General Public |
23 # You should have received a copy of the GNU Lesser General Public |
24 # License along with this library; if not, write to the Free Software |
24 # License along with this library; if not, write to the Free Software |
25 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
25 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA |
26 # 02110-1301 USA |
26 # 02110-1301 USA |
27 ######################### END LICENSE BLOCK ######################### |
27 ######################### END LICENSE BLOCK ######################### |
28 |
28 |
29 from . import constants |
|
30 import sys |
|
31 from .charsetgroupprober import CharSetGroupProber |
29 from .charsetgroupprober import CharSetGroupProber |
32 from .sbcharsetprober import SingleByteCharSetProber |
30 from .sbcharsetprober import SingleByteCharSetProber |
33 from .langcyrillicmodel import Win1251CyrillicModel, Koi8rModel, Latin5CyrillicModel, MacCyrillicModel, Ibm866Model, Ibm855Model |
31 from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel, |
|
32 Latin5CyrillicModel, MacCyrillicModel, |
|
33 Ibm866Model, Ibm855Model) |
34 from .langgreekmodel import Latin7GreekModel, Win1253GreekModel |
34 from .langgreekmodel import Latin7GreekModel, Win1253GreekModel |
35 from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel |
35 from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel |
36 from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel |
36 from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel |
37 from .langthaimodel import TIS620ThaiModel |
37 from .langthaimodel import TIS620ThaiModel |
38 from .langhebrewmodel import Win1255HebrewModel |
38 from .langhebrewmodel import Win1255HebrewModel |
39 from .hebrewprober import HebrewProber |
39 from .hebrewprober import HebrewProber |
40 |
40 |
|
41 |
41 class SBCSGroupProber(CharSetGroupProber): |
42 class SBCSGroupProber(CharSetGroupProber): |
42 def __init__(self): |
43 def __init__(self): |
43 CharSetGroupProber.__init__(self) |
44 CharSetGroupProber.__init__(self) |
44 self._mProbers = [ \ |
45 self._mProbers = [ |
45 SingleByteCharSetProber(Win1251CyrillicModel), |
46 SingleByteCharSetProber(Win1251CyrillicModel), |
46 SingleByteCharSetProber(Koi8rModel), |
47 SingleByteCharSetProber(Koi8rModel), |
47 SingleByteCharSetProber(Latin5CyrillicModel), |
48 SingleByteCharSetProber(Latin5CyrillicModel), |
48 SingleByteCharSetProber(MacCyrillicModel), |
49 SingleByteCharSetProber(MacCyrillicModel), |
49 SingleByteCharSetProber(Ibm866Model), |
50 SingleByteCharSetProber(Ibm866Model), |
53 SingleByteCharSetProber(Latin5BulgarianModel), |
54 SingleByteCharSetProber(Latin5BulgarianModel), |
54 SingleByteCharSetProber(Win1251BulgarianModel), |
55 SingleByteCharSetProber(Win1251BulgarianModel), |
55 SingleByteCharSetProber(Latin2HungarianModel), |
56 SingleByteCharSetProber(Latin2HungarianModel), |
56 SingleByteCharSetProber(Win1250HungarianModel), |
57 SingleByteCharSetProber(Win1250HungarianModel), |
57 SingleByteCharSetProber(TIS620ThaiModel), |
58 SingleByteCharSetProber(TIS620ThaiModel), |
58 ] |
59 ] |
59 hebrewProber = HebrewProber() |
60 hebrewProber = HebrewProber() |
60 logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, False, hebrewProber) |
61 logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, |
61 visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, hebrewProber) |
62 False, hebrewProber) |
|
63 visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True, |
|
64 hebrewProber) |
62 hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) |
65 hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber) |
63 self._mProbers.extend([hebrewProber, logicalHebrewProber, visualHebrewProber]) |
66 self._mProbers.extend([hebrewProber, logicalHebrewProber, |
|
67 visualHebrewProber]) |
64 |
68 |
65 self.reset() |
69 self.reset() |