Skip to content
Myr

update charade

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Kenneth Reitz · committed by Kenneth Reitz · parent b60b11e · Browse files · 41 files+4488 added−4705 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

41 files+4488 added−4705 removed

  • other:+4488 added−4705 removed

41 files+4488 added−4705 removed

modified:requests/packages/charade/__init__.py+26 added-27 removed
1######################## BEGIN LICENSE BLOCK ########################2# This library is free software; you can redistribute it and/or3# modify it under the terms of the GNU Lesser General Public4# License as published by the Free Software Foundation; either5# version 2.1 of the License, or (at your option) any later version.6#7# This library is distributed in the hope that it will be useful,8# but WITHOUT ANY WARRANTY; without even the implied warranty of9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10# Lesser General Public License for more details.11#12# You should have received a copy of the GNU Lesser General Public13# License along with this library; if not, write to the Free Software14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA15# 02110-1301 USA16######################### END LICENSE BLOCK #########################1718__version__ = "1.1"192021def detect(aBuf):22 from . import universaldetector23 u = universaldetector.UniversalDetector()24 u.reset()25 u.feed(aBuf)26 u.close()27 return u.result1######################## BEGIN LICENSE BLOCK ########################2# This library is free software; you can redistribute it and/or3# modify it under the terms of the GNU Lesser General Public4# License as published by the Free Software Foundation; either5# version 2.1 of the License, or (at your option) any later version.6# 7# This library is distributed in the hope that it will be useful,8# but WITHOUT ANY WARRANTY; without even the implied warranty of9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU10# Lesser General Public License for more details.11# 12# You should have received a copy of the GNU Lesser General Public13# License along with this library; if not, write to the Free Software14# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA15# 02110-1301 USA16######################### END LICENSE BLOCK #########################1718__version__ = "1.0.0"1920def detect(aBuf):21 from . import universaldetector22 u = universaldetector.UniversalDetector()23 u.reset()24 u.feed(aBuf)25 u.close()26 return u.result
modified:requests/packages/charade/big5freq.py+11 added-9 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3# 3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8# 8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# Big5 frequency table29# by Taiwan's Mandarin Promotion Council 29# by Taiwan's Mandarin Promotion Council30# <http://www.edu.tw:81/mandr/>31# 31#32# 128 --> 0.4226133# 256 --> 0.5785134# 512 --> 0.7485135# 1024 --> 0.8938436# 2048 --> 0.9758337# 37#38# Ideal Distribution Ratio = 0.74851/(1-0.74851) =2.9839# Random Distribution Ration = 512/(5401-512)=0.10540# 40#41# Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR4243BIG5_TYPICAL_DISTRIBUTION_RATIO = 0.754445#Char to FreqOrder table46BIG5_TABLE_SIZE = 53764748Big5CharToFreqOrder = ( \48Big5CharToFreqOrder = (49 1,1801,1506, 255,1431, 198, 9, 82, 6,5008, 177, 202,3681,1256,2821, 110, # 16503814, 33,3274, 261, 76, 44,2114, 16,2946,2187,1176, 659,3971, 26,3451,2653, # 32511198,3972,3350,4202, 410,2215, 302, 590, 361,1964, 8, 204, 58,4510,5009,1932, # 4852 63,5010,5011, 317,1614, 75, 222, 159,4203,2417,1480,5012,3555,3091, 224,2822, # 64
867 unmodified lines
92013920,13921,13922,13923,13924,13925,13926,13927,13928,13929,13930,13931,13932,13933,13934,13935, #1393692113936,13937,13938,13939,13940,13941,13942,13943,13944,13945,13946,13947,13948,13949,13950,13951, #1395292213952,13953,13954,13955,13956,13957,13958,13959,13960,13961,13962,13963,13964,13965,13966,13967, #1396892313968,13969,13970,13971,13972) #13973924925# flake8: noqa
modified:requests/packages/charade/big5prober.py+42 added-42 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import Big5DistributionAnalysis31from .mbcssm import Big5SMModel323334class Big5Prober(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(Big5SMModel)38 self._mDistributionAnalyzer = Big5DistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "Big5"1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import Big5DistributionAnalysis31from .mbcssm import Big5SMModel323334class Big5Prober(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(Big5SMModel)38 self._mDistributionAnalyzer = Big5DistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "Big5"
modified:requests/packages/charade/chardistribution.py+230 added-228 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,29 EUCTW_TYPICAL_DISTRIBUTION_RATIO)30from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,31 EUCKR_TYPICAL_DISTRIBUTION_RATIO)32from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,33 GB2312_TYPICAL_DISTRIBUTION_RATIO)34from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,35 BIG5_TYPICAL_DISTRIBUTION_RATIO)36from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,37 JIS_TYPICAL_DISTRIBUTION_RATIO)38from .compat import wrap_ord3940ENOUGH_DATA_THRESHOLD = 102441SURE_YES = 0.9942SURE_NO = 0.01434445class CharDistributionAnalysis:46 def __init__(self):47 # Mapping table to get frequency order from char order (get from48 # GetOrder())49 self._mCharToFreqOrder = None50 # Size of above table51 self._mTableSize = None52 # This is a constant value which varies from language to language,53 # used in calculating confidence. See54 # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html55 # for further detail.56 self._mTypicalDistributionRatio = None57 self.reset()5859 def reset(self):60 """reset analyser, clear any state"""61 # If this flag is set to constants.True, detection is done and62 # conclusion has been made63 self._mDone = False64 # Total characters encountered65 self._mTotalChars = 066 # The number of characters whose frequency order is less than 51267 self._mFreqChars = 06869 def feed(self, aStr, aCharLen):70 """feed a character with known length"""71 if aCharLen == 2:72 # we only care about 2-bytes character in our distribution analysis73 order = self.get_order(aStr)74 else:75 order = -176 if order >= 0:77 self._mTotalChars += 178 # order is valid79 if order < self._mTableSize:80 if 512 > self._mCharToFreqOrder[order]:81 self._mFreqChars += 18283 def get_confidence(self):84 """return confidence based on existing data"""85 # if we didn't receive any character in our consideration range, return86 # negative answer87 if self._mTotalChars <= 0:88 return SURE_NO8990 if self._mTotalChars != self._mFreqChars:91 r = self._mFreqChars / ((self._mTotalChars - self._mFreqChars)92 * self._mTypicalDistributionRatio)93 if r < SURE_YES:94 return r9596 # normalize confidence (we don't want to be 100% sure)97 return SURE_YES9899 def got_enough_data(self):100 # It is not necessary to receive all data to draw conclusion.101 # For charset detection, certain amount of data is enough102 return self._mTotalChars > ENOUGH_DATA_THRESHOLD103104 def get_order(self, aStr):105 # We do not handle characters based on the original encoding string,106 # but convert this encoding string to a number, here called order.107 # This allows multiple encodings of a language to share one frequency108 # table.109 return -1110111112class EUCTWDistributionAnalysis(CharDistributionAnalysis):113 def __init__(self):114 CharDistributionAnalysis.__init__(self)115 self._mCharToFreqOrder = EUCTWCharToFreqOrder116 self._mTableSize = EUCTW_TABLE_SIZE117 self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO118119 def get_order(self, aStr):120 # for euc-TW encoding, we are interested121 # first byte range: 0xc4 -- 0xfe122 # second byte range: 0xa1 -- 0xfe123 # no validation needed here. State machine has done that124 if aStr[0] >= '\xC4':125 return 94 * (wrap_ord(aStr[0]) - 0xC4) + wrap_ord(aStr[1]) - 0xA1126 else:127 return -1128129130class EUCKRDistributionAnalysis(CharDistributionAnalysis):131 def __init__(self):132 CharDistributionAnalysis.__init__(self)133 self._mCharToFreqOrder = EUCKRCharToFreqOrder134 self._mTableSize = EUCKR_TABLE_SIZE135 self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO136137 def get_order(self, aStr):138 # for euc-KR encoding, we are interested139 # first byte range: 0xb0 -- 0xfe140 # second byte range: 0xa1 -- 0xfe141 # no validation needed here. State machine has done that142 if aStr[0] >= '\xB0':143 return 94 * (wrap_ord(aStr[0]) - 0xB0) + wrap_ord(aStr[1]) - 0xA1144 else:145 return -1146147148class GB2312DistributionAnalysis(CharDistributionAnalysis):149 def __init__(self):150 CharDistributionAnalysis.__init__(self)151 self._mCharToFreqOrder = GB2312CharToFreqOrder152 self._mTableSize = GB2312_TABLE_SIZE153 self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO154155 def get_order(self, aStr):156 # for GB2312 encoding, we are interested157 # first byte range: 0xb0 -- 0xfe158 # second byte range: 0xa1 -- 0xfe159 # no validation needed here. State machine has done that160 if (aStr[0] >= '\xB0') and (aStr[1] >= '\xA1'):161 return 94 * (wrap_ord(aStr[0]) - 0xB0) + wrap_ord(aStr[1]) - 0xA1162 else:163 return -1164165166class Big5DistributionAnalysis(CharDistributionAnalysis):167 def __init__(self):168 CharDistributionAnalysis.__init__(self)169 self._mCharToFreqOrder = Big5CharToFreqOrder170 self._mTableSize = BIG5_TABLE_SIZE171 self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO172173 def get_order(self, aStr):174 # for big5 encoding, we are interested175 # first byte range: 0xa4 -- 0xfe176 # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe177 # no validation needed here. State machine has done that178 if aStr[0] >= '\xA4':179 if aStr[1] >= '\xA1':180 return (157 * (wrap_ord(aStr[0]) - 0xA4) + wrap_ord(aStr[1])181 - 0xA1 + 63)182 else:183 return (157 * (wrap_ord(aStr[0]) - 0xA4) + wrap_ord(aStr[1])184 - 0x40)185 else:186 return -1187188189class SJISDistributionAnalysis(CharDistributionAnalysis):190 def __init__(self):191 CharDistributionAnalysis.__init__(self)192 self._mCharToFreqOrder = JISCharToFreqOrder193 self._mTableSize = JIS_TABLE_SIZE194 self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO195196 def get_order(self, aStr):197 # for sjis encoding, we are interested198 # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe199 # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe200 # no validation needed here. State machine has done that201 if (aStr[0] >= '\x81') and (aStr[0] <= '\x9F'):202 order = 188 * (wrap_ord(aStr[0]) - 0x81)203 elif (aStr[0] >= '\xE0') and (aStr[0] <= '\xEF'):204 order = 188 * (wrap_ord(aStr[0]) - 0xE0 + 31)205 else:206 return -1207 order = order + wrap_ord(aStr[1]) - 0x40208 if aStr[1] > '\x7F':209 order = -1210 return order211212213class EUCJPDistributionAnalysis(CharDistributionAnalysis):214 def __init__(self):215 CharDistributionAnalysis.__init__(self)216 self._mCharToFreqOrder = JISCharToFreqOrder217 self._mTableSize = JIS_TABLE_SIZE218 self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO219220 def get_order(self, aStr):221 # for euc-JP encoding, we are interested222 # first byte range: 0xa0 -- 0xfe223 # second byte range: 0xa1 -- 0xfe224 # no validation needed here. State machine has done that225 if aStr[0] >= '\xA0':226 return 94 * (wrap_ord(aStr[0]) - 0xA1) + wrap_ord(aStr[1]) - 0xa1227 else:228 return -11######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .euctwfreq import (EUCTWCharToFreqOrder, EUCTW_TABLE_SIZE,29 EUCTW_TYPICAL_DISTRIBUTION_RATIO)30from .euckrfreq import (EUCKRCharToFreqOrder, EUCKR_TABLE_SIZE,31 EUCKR_TYPICAL_DISTRIBUTION_RATIO)32from .gb2312freq import (GB2312CharToFreqOrder, GB2312_TABLE_SIZE,33 GB2312_TYPICAL_DISTRIBUTION_RATIO)34from .big5freq import (Big5CharToFreqOrder, BIG5_TABLE_SIZE,35 BIG5_TYPICAL_DISTRIBUTION_RATIO)36from .jisfreq import (JISCharToFreqOrder, JIS_TABLE_SIZE,37 JIS_TYPICAL_DISTRIBUTION_RATIO)38from .compat import wrap_ord3940ENOUGH_DATA_THRESHOLD = 102441SURE_YES = 0.9942SURE_NO = 0.01434445class CharDistributionAnalysis:46 def __init__(self):47 # Mapping table to get frequency order from char order (get from48 # GetOrder())49 self._mCharToFreqOrder = None50 self._mTableSize = None # Size of above table51 # This is a constant value which varies from language to language,52 # used in calculating confidence. See53 # http://www.mozilla.org/projects/intl/UniversalCharsetDetection.html54 # for further detail.55 self._mTypicalDistributionRatio = None56 self.reset()5758 def reset(self):59 """reset analyser, clear any state"""60 # If this flag is set to True, detection is done and conclusion has61 # been made62 self._mDone = False63 self._mTotalChars = 0 # Total characters encountered64 # The number of characters whose frequency order is less than 51265 self._mFreqChars = 06667 def feed(self, aBuf, aCharLen):68 """feed a character with known length"""69 if aCharLen == 2:70 # we only care about 2-bytes character in our distribution analysis71 order = self.get_order(aBuf)72 else:73 order = -174 if order >= 0:75 self._mTotalChars += 176 # order is valid77 if order < self._mTableSize:78 if 512 > self._mCharToFreqOrder[order]:79 self._mFreqChars += 18081 def get_confidence(self):82 """return confidence based on existing data"""83 # if we didn't receive any character in our consideration range,84 # return negative answer85 if self._mTotalChars <= 0:86 return SURE_NO8788 if self._mTotalChars != self._mFreqChars:89 r = (self._mFreqChars / ((self._mTotalChars - self._mFreqChars)90 * self._mTypicalDistributionRatio))91 if r < SURE_YES:92 return r9394 # normalize confidence (we don't want to be 100% sure)95 return SURE_YES9697 def got_enough_data(self):98 # It is not necessary to receive all data to draw conclusion.99 # For charset detection, certain amount of data is enough100 return self._mTotalChars > ENOUGH_DATA_THRESHOLD101102 def get_order(self, aBuf):103 # We do not handle characters based on the original encoding string,104 # but convert this encoding string to a number, here called order.105 # This allows multiple encodings of a language to share one frequency106 # table.107 return -1108109110class EUCTWDistributionAnalysis(CharDistributionAnalysis):111 def __init__(self):112 CharDistributionAnalysis.__init__(self)113 self._mCharToFreqOrder = EUCTWCharToFreqOrder114 self._mTableSize = EUCTW_TABLE_SIZE115 self._mTypicalDistributionRatio = EUCTW_TYPICAL_DISTRIBUTION_RATIO116117 def get_order(self, aBuf):118 # for euc-TW encoding, we are interested119 # first byte range: 0xc4 -- 0xfe120 # second byte range: 0xa1 -- 0xfe121 # no validation needed here. State machine has done that122 first_char = wrap_ord(aBuf[0])123 if first_char >= 0xC4:124 return 94 * (first_char - 0xC4) + wrap_ord(aBuf[1]) - 0xA1125 else:126 return -1127128129class EUCKRDistributionAnalysis(CharDistributionAnalysis):130 def __init__(self):131 CharDistributionAnalysis.__init__(self)132 self._mCharToFreqOrder = EUCKRCharToFreqOrder133 self._mTableSize = EUCKR_TABLE_SIZE134 self._mTypicalDistributionRatio = EUCKR_TYPICAL_DISTRIBUTION_RATIO135136 def get_order(self, aBuf):137 # for euc-KR encoding, we are interested138 # first byte range: 0xb0 -- 0xfe139 # second byte range: 0xa1 -- 0xfe140 # no validation needed here. State machine has done that141 first_char = wrap_ord(aBuf[0])142 if first_char >= 0xB0:143 return 94 * (first_char - 0xB0) + wrap_ord(aBuf[1]) - 0xA1144 else:145 return -1146147148class GB2312DistributionAnalysis(CharDistributionAnalysis):149 def __init__(self):150 CharDistributionAnalysis.__init__(self)151 self._mCharToFreqOrder = GB2312CharToFreqOrder152 self._mTableSize = GB2312_TABLE_SIZE153 self._mTypicalDistributionRatio = GB2312_TYPICAL_DISTRIBUTION_RATIO154155 def get_order(self, aBuf):156 # for GB2312 encoding, we are interested157 # first byte range: 0xb0 -- 0xfe158 # second byte range: 0xa1 -- 0xfe159 # no validation needed here. State machine has done that160 first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])161 if (first_char >= 0xB0) and (second_char >= 0xA1):162 return 94 * (first_char - 0xB0) + second_char - 0xA1163 else:164 return -1165166167class Big5DistributionAnalysis(CharDistributionAnalysis):168 def __init__(self):169 CharDistributionAnalysis.__init__(self)170 self._mCharToFreqOrder = Big5CharToFreqOrder171 self._mTableSize = BIG5_TABLE_SIZE172 self._mTypicalDistributionRatio = BIG5_TYPICAL_DISTRIBUTION_RATIO173174 def get_order(self, aBuf):175 # for big5 encoding, we are interested176 # first byte range: 0xa4 -- 0xfe177 # second byte range: 0x40 -- 0x7e , 0xa1 -- 0xfe178 # no validation needed here. State machine has done that179 first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])180 if first_char >= 0xA4:181 if second_char >= 0xA1:182 return 157 * (first_char - 0xA4) + second_char - 0xA1 + 63183 else:184 return 157 * (first_char - 0xA4) + second_char - 0x40185 else:186 return -1187188189class SJISDistributionAnalysis(CharDistributionAnalysis):190 def __init__(self):191 CharDistributionAnalysis.__init__(self)192 self._mCharToFreqOrder = JISCharToFreqOrder193 self._mTableSize = JIS_TABLE_SIZE194 self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO195196 def get_order(self, aBuf):197 # for sjis encoding, we are interested198 # first byte range: 0x81 -- 0x9f , 0xe0 -- 0xfe199 # second byte range: 0x40 -- 0x7e, 0x81 -- oxfe200 # no validation needed here. State machine has done that201 first_char, second_char = wrap_ord(aBuf[0]), wrap_ord(aBuf[1])202 if (first_char >= 0x81) and (first_char <= 0x9F):203 order = 188 * (first_char - 0x81)204 elif (first_char >= 0xE0) and (first_char <= 0xEF):205 order = 188 * (first_char - 0xE0 + 31)206 else:207 return -1208 order = order + second_char - 0x40209 if second_char > 0x7F:210 order = -1211 return order212213214class EUCJPDistributionAnalysis(CharDistributionAnalysis):215 def __init__(self):216 CharDistributionAnalysis.__init__(self)217 self._mCharToFreqOrder = JISCharToFreqOrder218 self._mTableSize = JIS_TABLE_SIZE219 self._mTypicalDistributionRatio = JIS_TYPICAL_DISTRIBUTION_RATIO220221 def get_order(self, aBuf):222 # for euc-JP encoding, we are interested223 # first byte range: 0xa0 -- 0xfe224 # second byte range: 0xa1 -- 0xfe225 # no validation needed here. State machine has done that226 char = wrap_ord(aBuf[0])227 if char >= 0xA0:228 return 94 * (char - 0xA1) + wrap_ord(aBuf[1]) - 0xa1229 else:230 return -1
modified:requests/packages/charade/charsetgroupprober.py+106 added-107 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728import sys29from . import constants30from .charsetprober import CharSetProber313233class CharSetGroupProber(CharSetProber):34 def __init__(self):35 CharSetProber.__init__(self)36 self._mActiveNum = 037 self._mProbers = []38 self._mBestGuessProber = None3940 def reset(self):41 CharSetProber.reset(self)42 self._mActiveNum = 043 for prober in self._mProbers:44 if prober:45 prober.reset()46 prober.active = True47 self._mActiveNum += 148 self._mBestGuessProber = None4950 def get_charset_name(self):51 if not self._mBestGuessProber:52 self.get_confidence()53 if not self._mBestGuessProber:54 return None55 # self._mBestGuessProber = self._mProbers[0]56 return self._mBestGuessProber.get_charset_name()5758 def feed(self, aBuf):59 for prober in self._mProbers:60 if not prober:61 continue62 if not prober.active:63 continue64 st = prober.feed(aBuf)65 if not st:66 continue67 if st == constants.eFoundIt:68 self._mBestGuessProber = prober69 return self.get_state()70 elif st == constants.eNotMe:71 prober.active = False72 self._mActiveNum -= 173 if self._mActiveNum <= 0:74 self._mState = constants.eNotMe75 return self.get_state()76 return self.get_state()7778 def get_confidence(self):79 st = self.get_state()80 if st == constants.eFoundIt:81 return 0.9982 elif st == constants.eNotMe:83 return 0.0184 bestConf = 0.085 self._mBestGuessProber = None86 for prober in self._mProbers:87 if not prober:88 continue89 if not prober.active:90 if constants._debug:91 sys.stderr.write(prober.get_charset_name() + ' not '92 'active\n')93 continue94 cf = prober.get_confidence()95 if constants._debug:96 sys.stderr.write('%s confidence = %s\n' %97 (prober.get_charset_name(), cf))98 if bestConf < cf:99 bestConf = cf100 self._mBestGuessProber = prober101102 if not self._mBestGuessProber:103 return 0.0104 return bestConf105# else:106# self._mBestGuessProber = self._mProbers[0]107# return self._mBestGuessProber.get_confidence()1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3# 4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8# 9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants29import sys30from .charsetprober import CharSetProber313233class CharSetGroupProber(CharSetProber):34 def __init__(self):35 CharSetProber.__init__(self)36 self._mActiveNum = 037 self._mProbers = []38 self._mBestGuessProber = None3940 def reset(self):41 CharSetProber.reset(self)42 self._mActiveNum = 043 for prober in self._mProbers:44 if prober:45 prober.reset()46 prober.active = True47 self._mActiveNum += 148 self._mBestGuessProber = None4950 def get_charset_name(self):51 if not self._mBestGuessProber:52 self.get_confidence()53 if not self._mBestGuessProber:54 return None55# self._mBestGuessProber = self._mProbers[0]56 return self._mBestGuessProber.get_charset_name()5758 def feed(self, aBuf):59 for prober in self._mProbers:60 if not prober:61 continue62 if not prober.active:63 continue64 st = prober.feed(aBuf)65 if not st:66 continue67 if st == constants.eFoundIt:68 self._mBestGuessProber = prober69 return self.get_state()70 elif st == constants.eNotMe:71 prober.active = False72 self._mActiveNum -= 173 if self._mActiveNum <= 0:74 self._mState = constants.eNotMe75 return self.get_state()76 return self.get_state()7778 def get_confidence(self):79 st = self.get_state()80 if st == constants.eFoundIt:81 return 0.9982 elif st == constants.eNotMe:83 return 0.0184 bestConf = 0.085 self._mBestGuessProber = None86 for prober in self._mProbers:87 if not prober:88 continue89 if not prober.active:90 if constants._debug:91 sys.stderr.write(prober.get_charset_name()92 + ' not active\n')93 continue94 cf = prober.get_confidence()95 if constants._debug:96 sys.stderr.write('%s confidence = %s\n' %97 (prober.get_charset_name(), cf))98 if bestConf < cf:99 bestConf = cf100 self._mBestGuessProber = prober101 if not self._mBestGuessProber:102 return 0.0103 return bestConf104# else:105# self._mBestGuessProber = self._mProbers[0]106# return self._mBestGuessProber.get_confidence()
modified:requests/packages/charade/charsetprober.py
modified:requests/packages/charade/codingstatemachine.py+61 added-64 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart, eError29from .compat import wrap_ord303132class CodingStateMachine:33 def __init__(self, sm):34 self._mModel = sm35 self._mCurrentBytePos = 036 self._mCurrentCharLen = 037 self.reset()3839 def reset(self):40 self._mCurrentState = eStart4142 def next_state(self, c):43 # for each byte we get its class44 # if it is first byte, we also get byte length45 try:46 byteCls = self._mModel['classTable'][wrap_ord(c)]47 except IndexError:48 return eError49 if self._mCurrentState == eStart:50 self._mCurrentBytePos = 051 self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]5253 # from byte's class and stateTable, we get its next state54 next_state = (self._mCurrentState + self._mModel['classFactor'] +55 byteCls)56 self._mCurrentState = self._mModel['stateTable'][next_state]57 self._mCurrentBytePos += 158 return self._mCurrentState5960 def get_current_charlen(self):61 return self._mCurrentCharLen6263 def get_coding_state_machine(self):64 return self._mModel['name']1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart29from .compat import wrap_ord303132class CodingStateMachine:33 def __init__(self, sm):34 self._mModel = sm35 self._mCurrentBytePos = 036 self._mCurrentCharLen = 037 self.reset()3839 def reset(self):40 self._mCurrentState = eStart4142 def next_state(self, c):43 # for each byte we get its class44 # if it is first byte, we also get byte length45 # PY3K: aBuf is a byte stream, so c is an int, not a byte46 byteCls = self._mModel['classTable'][wrap_ord(c)]47 if self._mCurrentState == eStart:48 self._mCurrentBytePos = 049 self._mCurrentCharLen = self._mModel['charLenTable'][byteCls]50 # from byte's class and stateTable, we get its next state51 curr_state = (self._mCurrentState * self._mModel['classFactor']52 + byteCls)53 self._mCurrentState = self._mModel['stateTable'][curr_state]54 self._mCurrentBytePos += 155 return self._mCurrentState5657 def get_current_charlen(self):58 return self._mCurrentCharLen5960 def get_coding_state_machine(self):61 return self._mModel['name']
modified:requests/packages/charade/compat.py+2 added-5 removed
17 unmodified lines
18# 02110-1301 USA19######################### END LICENSE BLOCK #########################202122from sys import version_info232422def wrap_ord(a):26 if isinstance(a, str) and version_info < (3, 0):23 if isinstance(a, str):24 return ord(a)28 elif isinstance(a, int) and version_info >= (3, 0):25 elif isinstance(a, int):26 return a
modified:requests/packages/charade/constants.py+39 added-39 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829_debug = 03031eDetecting = 032eFoundIt = 133eNotMe = 23435eStart = 036eError = 137eItsMe = 23839SHORTCUT_THRESHOLD = 0.951######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17# 18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22# 23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829_debug = 03031eDetecting = 032eFoundIt = 133eNotMe = 23435eStart = 036eError = 137eItsMe = 23839SHORTCUT_THRESHOLD = 0.95
modified:requests/packages/charade/escprober.py+86 added-84 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants29from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,30 ISO2022KRSMModel)31from .charsetprober import CharSetProber32from .codingstatemachine import CodingStateMachine333435class EscCharSetProber(CharSetProber):36 def __init__(self):37 CharSetProber.__init__(self)38 self._mCodingSM = [39 CodingStateMachine(HZSMModel),40 CodingStateMachine(ISO2022CNSMModel),41 CodingStateMachine(ISO2022JPSMModel),42 CodingStateMachine(ISO2022KRSMModel)43 ]44 self.reset()4546 def reset(self):47 CharSetProber.reset(self)48 for codingSM in self._mCodingSM:49 if not codingSM:50 continue51 codingSM.active = True52 codingSM.reset()53 self._mActiveSM = len(self._mCodingSM)54 self._mDetectedCharset = None5556 def get_charset_name(self):57 return self._mDetectedCharset5859 def get_confidence(self):60 if self._mDetectedCharset:61 return 0.9962 else:63 return 0.006465 def feed(self, aBuf):66 for c in aBuf:67 for codingSM in self._mCodingSM:68 if not codingSM:69 continue70 if not codingSM.active:71 continue72 codingState = codingSM.next_state(c)73 if codingState == constants.eError:74 codingSM.active = False75 self._mActiveSM -= 176 if self._mActiveSM <= 0:77 self._mState = constants.eNotMe78 return self.get_state()79 elif codingState == constants.eItsMe:80 self._mState = constants.eFoundIt81 self._mDetectedCharset = codingSM.get_coding_state_machine()82 return self.get_state()8384 return self.get_state()1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants29from .escsm import (HZSMModel, ISO2022CNSMModel, ISO2022JPSMModel,30 ISO2022KRSMModel)31from .charsetprober import CharSetProber32from .codingstatemachine import CodingStateMachine33from .compat import wrap_ord343536class EscCharSetProber(CharSetProber):37 def __init__(self):38 CharSetProber.__init__(self)39 self._mCodingSM = [40 CodingStateMachine(HZSMModel),41 CodingStateMachine(ISO2022CNSMModel),42 CodingStateMachine(ISO2022JPSMModel),43 CodingStateMachine(ISO2022KRSMModel)44 ]45 self.reset()4647 def reset(self):48 CharSetProber.reset(self)49 for codingSM in self._mCodingSM:50 if not codingSM:51 continue52 codingSM.active = True53 codingSM.reset()54 self._mActiveSM = len(self._mCodingSM)55 self._mDetectedCharset = None5657 def get_charset_name(self):58 return self._mDetectedCharset5960 def get_confidence(self):61 if self._mDetectedCharset:62 return 0.9963 else:64 return 0.006566 def feed(self, aBuf):67 for c in aBuf:68 # PY3K: aBuf is a byte array, so c is an int, not a byte69 for codingSM in self._mCodingSM:70 if not codingSM:71 continue72 if not codingSM.active:73 continue74 codingState = codingSM.next_state(wrap_ord(c))75 if codingState == constants.eError:76 codingSM.active = False77 self._mActiveSM -= 178 if self._mActiveSM <= 0:79 self._mState = constants.eNotMe80 return self.get_state()81 elif codingState == constants.eItsMe:82 self._mState = constants.eFoundIt83 self._mDetectedCharset = codingSM.get_coding_state_machine() # nopep884 return self.get_state()8586 return self.get_state()
modified:requests/packages/charade/escsm.py+242 added-240 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart, eError, eItsMe2930HZ_cls = (31 1, 0, 0, 0, 0, 0, 0, 0, # 00 - 0732 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f33 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 1734 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f35 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 2736 0, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f37 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 3738 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f39 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 4740 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f41 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 5742 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f43 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 6744 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f45 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 7746 0, 0, 0, 4, 0, 5, 2, 0, # 78 - 7f47 1, 1, 1, 1, 1, 1, 1, 1, # 80 - 8748 1, 1, 1, 1, 1, 1, 1, 1, # 88 - 8f49 1, 1, 1, 1, 1, 1, 1, 1, # 90 - 9750 1, 1, 1, 1, 1, 1, 1, 1, # 98 - 9f51 1, 1, 1, 1, 1, 1, 1, 1, # a0 - a752 1, 1, 1, 1, 1, 1, 1, 1, # a8 - af53 1, 1, 1, 1, 1, 1, 1, 1, # b0 - b754 1, 1, 1, 1, 1, 1, 1, 1, # b8 - bf55 1, 1, 1, 1, 1, 1, 1, 1, # c0 - c756 1, 1, 1, 1, 1, 1, 1, 1, # c8 - cf57 1, 1, 1, 1, 1, 1, 1, 1, # d0 - d758 1, 1, 1, 1, 1, 1, 1, 1, # d8 - df59 1, 1, 1, 1, 1, 1, 1, 1, # e0 - e760 1, 1, 1, 1, 1, 1, 1, 1, # e8 - ef61 1, 1, 1, 1, 1, 1, 1, 1, # f0 - f762 1, 1, 1, 1, 1, 1, 1, 1, # f8 - ff63)6465HZ_st = (66 eStart, eError, 3, eStart, eStart, eStart, eError, eError, # 00-0767 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f68 eItsMe, eItsMe, eError, eError, eStart, eStart, 4, eError, # 10-1769 5, eError, 6, eError, 5, 5, 4, eError, # 18-1f70 4, eError, 4, 4, 4, eError, 4, eError, # 20-2771 4, eItsMe, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f72)7374HZCharLenTable = (0, 0, 0, 0, 0, 0)7576HZSMModel = {'classTable': HZ_cls,77 'classFactor': 6,78 'stateTable': HZ_st,79 'charLenTable': HZCharLenTable,80 'name': "HZ-GB-2312"}8182ISO2022CN_cls = (83 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 0784 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f85 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 1786 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f87 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 2788 0, 3, 0, 0, 0, 0, 0, 0, # 28 - 2f89 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 3790 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f91 0, 0, 0, 4, 0, 0, 0, 0, # 40 - 4792 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f93 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 5794 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f95 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 6796 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f97 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 7798 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f99 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87100 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f101 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97102 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f103 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7104 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af105 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7106 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf107 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7108 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf109 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7110 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df111 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7112 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef113 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7114 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff115)116117ISO2022CN_st = (118 eStart, 3, eError, eStart, eStart, eStart, eStart, eStart, # 00-07119 eStart, eError, eError, eError, eError, eError, eError, eError, # 08-0f120 eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 10-17121 eItsMe, eItsMe, eItsMe, eError, eError, eError, 4, eError, # 18-1f122 eError, eError, eError, eItsMe, eError, eError, eError, eError, # 20-27123 5, 6, eError, eError, eError, eError, eError, eError, # 28-2f124 eError, eError, eError, eItsMe, eError, eError, eError, eError, # 30-37125 eError, eError, eError, eError, eError, eItsMe, eError, eStart, # 38-3f126)127128ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)129130ISO2022CNSMModel = {'classTable': ISO2022CN_cls,131 'classFactor': 9,132 'stateTable': ISO2022CN_st,133 'charLenTable': ISO2022CNCharLenTable,134 'name': "ISO-2022-CN"}135136ISO2022JP_cls = (137 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07138 0, 0, 0, 0, 0, 0, 2, 2, # 08 - 0f139 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17140 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f141 0, 0, 0, 0, 7, 0, 0, 0, # 20 - 27142 3, 0, 0, 0, 0, 0, 0, 0, # 28 - 2f143 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37144 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f145 6, 0, 4, 0, 8, 0, 0, 0, # 40 - 47146 0, 9, 5, 0, 0, 0, 0, 0, # 48 - 4f147 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57148 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f149 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67150 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f151 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77152 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f153 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87154 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f155 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97156 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f157 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7158 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af159 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7160 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf161 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7162 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf163 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7164 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df165 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7166 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef167 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7168 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff169)170171ISO2022JP_st = (172 eStart, 3, eError, eStart, eStart, eStart, eStart, eStart, # 00-07173 eStart, eStart, eError, eError, eError, eError, eError, eError, # 08-0f174 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 10-17175 eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, # 18-1f176 eError, 5, eError, eError, eError, 4, eError, eError, # 20-27177 eError, eError, eError, 6, eItsMe, eError, eItsMe, eError, # 28-2f178 eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 30-37179 eError, eError, eError, eItsMe, eError, eError, eError, eError, # 38-3f180 eError, eError, eError, eError, eItsMe, eError, eStart, eStart, # 40-47181)182183ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)184185ISO2022JPSMModel = {'classTable': ISO2022JP_cls,186 'classFactor': 10,187 'stateTable': ISO2022JP_st,188 'charLenTable': ISO2022JPCharLenTable,189 'name': "ISO-2022-JP"}190191ISO2022KR_cls = (192 2, 0, 0, 0, 0, 0, 0, 0, # 00 - 07193 0, 0, 0, 0, 0, 0, 0, 0, # 08 - 0f194 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17195 0, 0, 0, 1, 0, 0, 0, 0, # 18 - 1f196 0, 0, 0, 0, 3, 0, 0, 0, # 20 - 27197 0, 4, 0, 0, 0, 0, 0, 0, # 28 - 2f198 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37199 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f200 0, 0, 0, 5, 0, 0, 0, 0, # 40 - 47201 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f202 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57203 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f204 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67205 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f206 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77207 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f208 2, 2, 2, 2, 2, 2, 2, 2, # 80 - 87209 2, 2, 2, 2, 2, 2, 2, 2, # 88 - 8f210 2, 2, 2, 2, 2, 2, 2, 2, # 90 - 97211 2, 2, 2, 2, 2, 2, 2, 2, # 98 - 9f212 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7213 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af214 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7215 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf216 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7217 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf218 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7219 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df220 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7221 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef222 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7223 2, 2, 2, 2, 2, 2, 2, 2, # f8 - ff224)225226ISO2022KR_st = (227 eStart, 3, eError, eStart, eStart, eStart, eError, eError, # 00-07228 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f229 eItsMe, eItsMe, eError, eError, eError, 4, eError, eError, # 10-17230 eError, eError, eError, eError, 5, eError, eError, eError, # 18-1f231 eError, eError, eError, eItsMe, eStart, eStart, eStart, eStart, # 20-27232)233234ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)235236ISO2022KRSMModel = {'classTable': ISO2022KR_cls,237 'classFactor': 6,238 'stateTable': ISO2022KR_st,239 'charLenTable': ISO2022KRCharLenTable,240 'name': "ISO-2022-KR"}1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart, eError, eItsMe2930HZ_cls = (311,0,0,0,0,0,0,0, # 00 - 07320,0,0,0,0,0,0,0, # 08 - 0f330,0,0,0,0,0,0,0, # 10 - 17340,0,0,1,0,0,0,0, # 18 - 1f350,0,0,0,0,0,0,0, # 20 - 27360,0,0,0,0,0,0,0, # 28 - 2f370,0,0,0,0,0,0,0, # 30 - 37380,0,0,0,0,0,0,0, # 38 - 3f390,0,0,0,0,0,0,0, # 40 - 47400,0,0,0,0,0,0,0, # 48 - 4f410,0,0,0,0,0,0,0, # 50 - 57420,0,0,0,0,0,0,0, # 58 - 5f430,0,0,0,0,0,0,0, # 60 - 67440,0,0,0,0,0,0,0, # 68 - 6f450,0,0,0,0,0,0,0, # 70 - 77460,0,0,4,0,5,2,0, # 78 - 7f471,1,1,1,1,1,1,1, # 80 - 87481,1,1,1,1,1,1,1, # 88 - 8f491,1,1,1,1,1,1,1, # 90 - 97501,1,1,1,1,1,1,1, # 98 - 9f511,1,1,1,1,1,1,1, # a0 - a7521,1,1,1,1,1,1,1, # a8 - af531,1,1,1,1,1,1,1, # b0 - b7541,1,1,1,1,1,1,1, # b8 - bf551,1,1,1,1,1,1,1, # c0 - c7561,1,1,1,1,1,1,1, # c8 - cf571,1,1,1,1,1,1,1, # d0 - d7581,1,1,1,1,1,1,1, # d8 - df591,1,1,1,1,1,1,1, # e0 - e7601,1,1,1,1,1,1,1, # e8 - ef611,1,1,1,1,1,1,1, # f0 - f7621,1,1,1,1,1,1,1, # f8 - ff63)6465HZ_st = (66eStart,eError, 3,eStart,eStart,eStart,eError,eError,# 00-0767eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f68eItsMe,eItsMe,eError,eError,eStart,eStart, 4,eError,# 10-1769 5,eError, 6,eError, 5, 5, 4,eError,# 18-1f70 4,eError, 4, 4, 4,eError, 4,eError,# 20-2771 4,eItsMe,eStart,eStart,eStart,eStart,eStart,eStart,# 28-2f72)7374HZCharLenTable = (0, 0, 0, 0, 0, 0)7576HZSMModel = {'classTable': HZ_cls,77 'classFactor': 6,78 'stateTable': HZ_st,79 'charLenTable': HZCharLenTable,80 'name': "HZ-GB-2312"}8182ISO2022CN_cls = (832,0,0,0,0,0,0,0, # 00 - 07840,0,0,0,0,0,0,0, # 08 - 0f850,0,0,0,0,0,0,0, # 10 - 17860,0,0,1,0,0,0,0, # 18 - 1f870,0,0,0,0,0,0,0, # 20 - 27880,3,0,0,0,0,0,0, # 28 - 2f890,0,0,0,0,0,0,0, # 30 - 37900,0,0,0,0,0,0,0, # 38 - 3f910,0,0,4,0,0,0,0, # 40 - 47920,0,0,0,0,0,0,0, # 48 - 4f930,0,0,0,0,0,0,0, # 50 - 57940,0,0,0,0,0,0,0, # 58 - 5f950,0,0,0,0,0,0,0, # 60 - 67960,0,0,0,0,0,0,0, # 68 - 6f970,0,0,0,0,0,0,0, # 70 - 77980,0,0,0,0,0,0,0, # 78 - 7f992,2,2,2,2,2,2,2, # 80 - 871002,2,2,2,2,2,2,2, # 88 - 8f1012,2,2,2,2,2,2,2, # 90 - 971022,2,2,2,2,2,2,2, # 98 - 9f1032,2,2,2,2,2,2,2, # a0 - a71042,2,2,2,2,2,2,2, # a8 - af1052,2,2,2,2,2,2,2, # b0 - b71062,2,2,2,2,2,2,2, # b8 - bf1072,2,2,2,2,2,2,2, # c0 - c71082,2,2,2,2,2,2,2, # c8 - cf1092,2,2,2,2,2,2,2, # d0 - d71102,2,2,2,2,2,2,2, # d8 - df1112,2,2,2,2,2,2,2, # e0 - e71122,2,2,2,2,2,2,2, # e8 - ef1132,2,2,2,2,2,2,2, # f0 - f71142,2,2,2,2,2,2,2, # f8 - ff115)116117ISO2022CN_st = (118eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07119eStart,eError,eError,eError,eError,eError,eError,eError,# 08-0f120eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17121eItsMe,eItsMe,eItsMe,eError,eError,eError, 4,eError,# 18-1f122eError,eError,eError,eItsMe,eError,eError,eError,eError,# 20-27123 5, 6,eError,eError,eError,eError,eError,eError,# 28-2f124eError,eError,eError,eItsMe,eError,eError,eError,eError,# 30-37125eError,eError,eError,eError,eError,eItsMe,eError,eStart,# 38-3f126)127128ISO2022CNCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0)129130ISO2022CNSMModel = {'classTable': ISO2022CN_cls,131 'classFactor': 9,132 'stateTable': ISO2022CN_st,133 'charLenTable': ISO2022CNCharLenTable,134 'name': "ISO-2022-CN"}135136ISO2022JP_cls = (1372,0,0,0,0,0,0,0, # 00 - 071380,0,0,0,0,0,2,2, # 08 - 0f1390,0,0,0,0,0,0,0, # 10 - 171400,0,0,1,0,0,0,0, # 18 - 1f1410,0,0,0,7,0,0,0, # 20 - 271423,0,0,0,0,0,0,0, # 28 - 2f1430,0,0,0,0,0,0,0, # 30 - 371440,0,0,0,0,0,0,0, # 38 - 3f1456,0,4,0,8,0,0,0, # 40 - 471460,9,5,0,0,0,0,0, # 48 - 4f1470,0,0,0,0,0,0,0, # 50 - 571480,0,0,0,0,0,0,0, # 58 - 5f1490,0,0,0,0,0,0,0, # 60 - 671500,0,0,0,0,0,0,0, # 68 - 6f1510,0,0,0,0,0,0,0, # 70 - 771520,0,0,0,0,0,0,0, # 78 - 7f1532,2,2,2,2,2,2,2, # 80 - 871542,2,2,2,2,2,2,2, # 88 - 8f1552,2,2,2,2,2,2,2, # 90 - 971562,2,2,2,2,2,2,2, # 98 - 9f1572,2,2,2,2,2,2,2, # a0 - a71582,2,2,2,2,2,2,2, # a8 - af1592,2,2,2,2,2,2,2, # b0 - b71602,2,2,2,2,2,2,2, # b8 - bf1612,2,2,2,2,2,2,2, # c0 - c71622,2,2,2,2,2,2,2, # c8 - cf1632,2,2,2,2,2,2,2, # d0 - d71642,2,2,2,2,2,2,2, # d8 - df1652,2,2,2,2,2,2,2, # e0 - e71662,2,2,2,2,2,2,2, # e8 - ef1672,2,2,2,2,2,2,2, # f0 - f71682,2,2,2,2,2,2,2, # f8 - ff169)170171ISO2022JP_st = (172eStart, 3,eError,eStart,eStart,eStart,eStart,eStart,# 00-07173eStart,eStart,eError,eError,eError,eError,eError,eError,# 08-0f174eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 10-17175eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,# 18-1f176eError, 5,eError,eError,eError, 4,eError,eError,# 20-27177eError,eError,eError, 6,eItsMe,eError,eItsMe,eError,# 28-2f178eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,# 30-37179eError,eError,eError,eItsMe,eError,eError,eError,eError,# 38-3f180eError,eError,eError,eError,eItsMe,eError,eStart,eStart,# 40-47181)182183ISO2022JPCharLenTable = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0)184185ISO2022JPSMModel = {'classTable': ISO2022JP_cls,186 'classFactor': 10,187 'stateTable': ISO2022JP_st,188 'charLenTable': ISO2022JPCharLenTable,189 'name': "ISO-2022-JP"}190191ISO2022KR_cls = (1922,0,0,0,0,0,0,0, # 00 - 071930,0,0,0,0,0,0,0, # 08 - 0f1940,0,0,0,0,0,0,0, # 10 - 171950,0,0,1,0,0,0,0, # 18 - 1f1960,0,0,0,3,0,0,0, # 20 - 271970,4,0,0,0,0,0,0, # 28 - 2f1980,0,0,0,0,0,0,0, # 30 - 371990,0,0,0,0,0,0,0, # 38 - 3f2000,0,0,5,0,0,0,0, # 40 - 472010,0,0,0,0,0,0,0, # 48 - 4f2020,0,0,0,0,0,0,0, # 50 - 572030,0,0,0,0,0,0,0, # 58 - 5f2040,0,0,0,0,0,0,0, # 60 - 672050,0,0,0,0,0,0,0, # 68 - 6f2060,0,0,0,0,0,0,0, # 70 - 772070,0,0,0,0,0,0,0, # 78 - 7f2082,2,2,2,2,2,2,2, # 80 - 872092,2,2,2,2,2,2,2, # 88 - 8f2102,2,2,2,2,2,2,2, # 90 - 972112,2,2,2,2,2,2,2, # 98 - 9f2122,2,2,2,2,2,2,2, # a0 - a72132,2,2,2,2,2,2,2, # a8 - af2142,2,2,2,2,2,2,2, # b0 - b72152,2,2,2,2,2,2,2, # b8 - bf2162,2,2,2,2,2,2,2, # c0 - c72172,2,2,2,2,2,2,2, # c8 - cf2182,2,2,2,2,2,2,2, # d0 - d72192,2,2,2,2,2,2,2, # d8 - df2202,2,2,2,2,2,2,2, # e0 - e72212,2,2,2,2,2,2,2, # e8 - ef2222,2,2,2,2,2,2,2, # f0 - f72232,2,2,2,2,2,2,2, # f8 - ff224)225226ISO2022KR_st = (227eStart, 3,eError,eStart,eStart,eStart,eError,eError,# 00-07228eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,# 08-0f229eItsMe,eItsMe,eError,eError,eError, 4,eError,eError,# 10-17230eError,eError,eError,eError, 5,eError,eError,eError,# 18-1f231eError,eError,eError,eItsMe,eStart,eStart,eStart,eStart,# 20-27232)233234ISO2022KRCharLenTable = (0, 0, 0, 0, 0, 0)235236ISO2022KRSMModel = {'classTable': ISO2022KR_cls,237 'classFactor': 6,238 'stateTable': ISO2022KR_st,239 'charLenTable': ISO2022KRCharLenTable,240 'name': "ISO-2022-KR"}241242# flake8: noqa
modified:requests/packages/charade/eucjpprober.py+90 added-89 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728import sys29from . import constants30from .mbcharsetprober import MultiByteCharSetProber31from .codingstatemachine import CodingStateMachine32from .chardistribution import EUCJPDistributionAnalysis33from .jpcntx import EUCJPContextAnalysis34from .mbcssm import EUCJPSMModel353637class EUCJPProber(MultiByteCharSetProber):38 def __init__(self):39 MultiByteCharSetProber.__init__(self)40 self._mCodingSM = CodingStateMachine(EUCJPSMModel)41 self._mDistributionAnalyzer = EUCJPDistributionAnalysis()42 self._mContextAnalyzer = EUCJPContextAnalysis()43 self.reset()4445 def reset(self):46 MultiByteCharSetProber.reset(self)47 self._mContextAnalyzer.reset()4849 def get_charset_name(self):50 return "EUC-JP"5152 def feed(self, aBuf):53 aLen = len(aBuf)54 for i in range(0, aLen):55 codingState = self._mCodingSM.next_state(aBuf[i])56 if codingState == constants.eError:57 if constants._debug:58 sys.stderr.write(self.get_charset_name() +59 ' prober hit error at byte ' + str(i) +60 '\n')61 self._mState = constants.eNotMe62 break63 elif codingState == constants.eItsMe:64 self._mState = constants.eFoundIt65 break66 elif codingState == constants.eStart:67 charLen = self._mCodingSM.get_current_charlen()68 if i == 0:69 self._mLastChar[1] = aBuf[0]70 self._mContextAnalyzer.feed(self._mLastChar, charLen)71 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72 else:73 self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)74 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],75 charLen)7677 self._mLastChar[0] = aBuf[aLen - 1]7879 if self.get_state() == constants.eDetecting:80 if (self._mContextAnalyzer.got_enough_data() and81 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):82 self._mState = constants.eFoundIt8384 return self.get_state()8586 def get_confidence(self):87 contxtCf = self._mContextAnalyzer.get_confidence()88 distribCf = self._mDistributionAnalyzer.get_confidence()89 return max(contxtCf, distribCf)1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728import sys29from . import constants30from .mbcharsetprober import MultiByteCharSetProber31from .codingstatemachine import CodingStateMachine32from .chardistribution import EUCJPDistributionAnalysis33from .jpcntx import EUCJPContextAnalysis34from .mbcssm import EUCJPSMModel353637class EUCJPProber(MultiByteCharSetProber):38 def __init__(self):39 MultiByteCharSetProber.__init__(self)40 self._mCodingSM = CodingStateMachine(EUCJPSMModel)41 self._mDistributionAnalyzer = EUCJPDistributionAnalysis()42 self._mContextAnalyzer = EUCJPContextAnalysis()43 self.reset()4445 def reset(self):46 MultiByteCharSetProber.reset(self)47 self._mContextAnalyzer.reset()4849 def get_charset_name(self):50 return "EUC-JP"5152 def feed(self, aBuf):53 aLen = len(aBuf)54 for i in range(0, aLen):55 # PY3K: aBuf is a byte array, so aBuf[i] is an int, not a byte56 codingState = self._mCodingSM.next_state(aBuf[i])57 if codingState == constants.eError:58 if constants._debug:59 sys.stderr.write(self.get_charset_name()60 + ' prober hit error at byte ' + str(i)61 + '\n')62 self._mState = constants.eNotMe63 break64 elif codingState == constants.eItsMe:65 self._mState = constants.eFoundIt66 break67 elif codingState == constants.eStart:68 charLen = self._mCodingSM.get_current_charlen()69 if i == 0:70 self._mLastChar[1] = aBuf[0]71 self._mContextAnalyzer.feed(self._mLastChar, charLen)72 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)73 else:74 self._mContextAnalyzer.feed(aBuf[i - 1:i + 1], charLen)75 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],76 charLen)7778 self._mLastChar[0] = aBuf[aLen - 1]7980 if self.get_state() == constants.eDetecting:81 if (self._mContextAnalyzer.got_enough_data() and82 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):83 self._mState = constants.eFoundIt8485 return self.get_state()8687 def get_confidence(self):88 contxtCf = self._mContextAnalyzer.get_confidence()89 distribCf = self._mDistributionAnalyzer.get_confidence()90 return max(contxtCf, distribCf)
modified:requests/packages/charade/euckrfreq.py+2 added
590 unmodified lines
5918688,8689,8690,8691,8692,8693,8694,8695,8696,8697,8698,8699,8700,8701,8702,8703,5928704,8705,8706,8707,8708,8709,8710,8711,8712,8713,8714,8715,8716,8717,8718,8719,5938720,8721,8722,8723,8724,8725,8726,8727,8728,8729,8730,8731,8732,8733,8734,8735,5948736,8737,8738,8739,8740,8741)595596# flake8: noqa
modified:requests/packages/charade/euckrprober.py+42 added-42 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import EUCKRDistributionAnalysis31from .mbcssm import EUCKRSMModel323334class EUCKRProber(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(EUCKRSMModel)38 self._mDistributionAnalyzer = EUCKRDistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "EUC-KR"1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import EUCKRDistributionAnalysis31from .mbcssm import EUCKRSMModel323334class EUCKRProber(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(EUCKRSMModel)38 self._mDistributionAnalyzer = EUCKRDistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "EUC-KR"
modified:requests/packages/charade/euctwfreq.py+9 added-7 removed
11 unmodified lines
12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# EUCTW frequency table29# Converted from big5 work 30# by Taiwan's Mandarin Promotion Council 29# Converted from big5 work30# by Taiwan's Mandarin Promotion Council31# <http:#www.edu.tw:81/mandr/>3233# 128 --> 0.4226134# 256 --> 0.57851
2 unmodified lines
37# 2048 --> 0.9758338#39# Idea Distribution Ratio = 0.74851/(1-0.74851) =2.9840# Random Distribution Ration = 512/(5401-512)=0.10541# 41#42# Typical Distribution Ratio about 25% of Ideal one, still much higher than RDR4344EUCTW_TYPICAL_DISTRIBUTION_RATIO = 0.754546# Char to FreqOrder table , 46# Char to FreqOrder table ,47EUCTW_TABLE_SIZE = 81024849EUCTWCharToFreqOrder = ( \49EUCTWCharToFreqOrder = (50 1,1800,1506, 255,1431, 198, 9, 82, 6,7310, 177, 202,3615,1256,2808, 110, # 2742513735, 33,3241, 261, 76, 44,2113, 16,2931,2184,1176, 659,3868, 26,3404,2643, # 2758521198,3869,3313,4060, 410,2211, 302, 590, 361,1963, 8, 204, 58,4296,7311,1931, # 277453 63,7312,7313, 317,1614, 75, 222, 159,4061,2412,1480,7314,3500,3068, 224,2809, # 2790
369 unmodified lines
4238678,8679,8680,8681,8682,8683,8684,8685,8686,8687,8688,8689,8690,8691,8692,8693, # 86944248694,8695,8696,8697,8698,8699,8700,8701,8702,8703,8704,8705,8706,8707,8708,8709, # 87104258710,8711,8712,8713,8714,8715,8716,8717,8718,8719,8720,8721,8722,8723,8724,8725, # 87264268726,8727,8728,8729,8730,8731,8732,8733,8734,8735,8736,8737,8738,8739,8740,8741) # 8742427428# flake8: noqa
modified:requests/packages/charade/euctwprober.py+41 added-42 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import EUCTWDistributionAnalysis31from .mbcssm import EUCTWSMModel323334class EUCTWProber(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(EUCTWSMModel)38 self._mDistributionAnalyzer = EUCTWDistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "EUC-TW"1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import EUCTWDistributionAnalysis31from .mbcssm import EUCTWSMModel3233class EUCTWProber(MultiByteCharSetProber):34 def __init__(self):35 MultiByteCharSetProber.__init__(self)36 self._mCodingSM = CodingStateMachine(EUCTWSMModel)37 self._mDistributionAnalyzer = EUCTWDistributionAnalysis()38 self.reset()3940 def get_charset_name(self):41 return "EUC-TW"
modified:requests/packages/charade/gb2312freq.py+5 added-4 removed
11 unmodified lines
12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA
9 unmodified lines
35# 6768 --> 1.00 -- 0.0236#37# Ideal Distribution Ratio = 0.79135/(1-0.79135) = 3.7938# Random Distribution Ration = 512 / (3755 - 512) = 0.15739# 39#40# Typical Distribution Ratio about 25% of Ideal one, still much higher that RDR4142GB2312_TYPICAL_DISTRIBUTION_RATIO = 0.94344GB2312_TABLE_SIZE = 37604546GB2312CharToFreqOrder = ( \46GB2312CharToFreqOrder = (471671, 749,1443,2364,3924,3807,2330,3921,1704,3463,2691,1511,1515, 572,3191,2205,482361, 224,2558, 479,1711, 963,3162, 440,4060,1905,2966,2947,3580,2647,3961,3842,492204, 869,4207, 970,2678,5626,2944,2956,1479,4048, 514,3595, 588,1346,2820,3409,50 249,4088,1746,1873,2047,1774, 581,1813, 358,1174,3590,1014,1561,4844,2245, 670,
417 unmodified lines
4683990,5971,5557,5558,5772,6477,6095,2787,4641,5972,5121,6096,6097,6272,6763,3703,4695867,5507,6273,4206,6274,4789,6098,6764,3619,3646,3833,3804,2394,3788,4936,3978,4704866,4899,6099,6100,5559,6478,6765,3599,5868,6101,5869,5870,6275,6766,4527,6767)471472# flake8: noqa
modified:requests/packages/charade/gb2312prober.py+41 added-42 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import GB2312DistributionAnalysis31from .mbcssm import GB2312SMModel323334class GB2312Prober(MultiByteCharSetProber):35 def __init__(self):36 MultiByteCharSetProber.__init__(self)37 self._mCodingSM = CodingStateMachine(GB2312SMModel)38 self._mDistributionAnalyzer = GB2312DistributionAnalysis()39 self.reset()4041 def get_charset_name(self):42 return "GB2312"1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .mbcharsetprober import MultiByteCharSetProber29from .codingstatemachine import CodingStateMachine30from .chardistribution import GB2312DistributionAnalysis31from .mbcssm import GB2312SMModel3233class GB2312Prober(MultiByteCharSetProber):34 def __init__(self):35 MultiByteCharSetProber.__init__(self)36 self._mCodingSM = CodingStateMachine(GB2312SMModel)37 self._mDistributionAnalyzer = GB2312DistributionAnalysis()38 self.reset()3940 def get_charset_name(self):41 return "GB2312"
modified:requests/packages/charade/hebrewprober.py+283 added-281 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Shy Shalom6# Portions created by the Initial Developer are Copyright (C) 20057# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .charsetprober import CharSetProber29from . import constants3031# This prober doesn't actually recognize a language or a charset.32# It is a helper prober for the use of the Hebrew model probers3334### General ideas of the Hebrew charset recognition ###35#36# Four main charsets exist in Hebrew:37# "ISO-8859-8" - Visual Hebrew38# "windows-1255" - Logical Hebrew39# "ISO-8859-8-I" - Logical Hebrew40# "x-mac-hebrew" - ?? Logical Hebrew ??41#42# Both "ISO" charsets use a completely identical set of code points, whereas43# "windows-1255" and "x-mac-hebrew" are two different proper supersets of44# these code points. windows-1255 defines additional characters in the range45# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific46# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.47# x-mac-hebrew defines similar additional code points but with a different48# mapping.49#50# As far as an average Hebrew text with no diacritics is concerned, all four51# charsets are identical with respect to code points. Meaning that for the52# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters53# (including final letters).54#55# The dominant difference between these charsets is their directionality.56# "Visual" directionality means that the text is ordered as if the renderer is57# not aware of a BIDI rendering algorithm. The renderer sees the text and58# draws it from left to right. The text itself when ordered naturally is read59# backwards. A buffer of Visual Hebrew generally looks like so:60# "[last word of first line spelled backwards] [whole line ordered backwards61# and spelled backwards] [first word of first line spelled backwards]62# [end of line] [last word of second line] ... etc' "63# adding punctuation marks, numbers and English text to visual text is64# naturally also "visual" and from left to right.65#66# "Logical" directionality means the text is ordered "naturally" according to67# the order it is read. It is the responsibility of the renderer to display68# the text from right to left. A BIDI algorithm is used to place general69# punctuation marks, numbers and English text in the text.70#71# Texts in x-mac-hebrew are almost impossible to find on the Internet. From72# what little evidence I could find, it seems that its general directionality73# is Logical.74#75# To sum up all of the above, the Hebrew probing mechanism knows about two76# charsets:77# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are78# backwards while line order is natural. For charset recognition purposes79# the line order is unimportant (In fact, for this implementation, even80# word order is unimportant).81# Logical Hebrew - "windows-1255" - normal, naturally ordered text.82#83# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be84# specifically identified.85# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew86# that contain special punctuation marks or diacritics is displayed with87# some unconverted characters showing as question marks. This problem might88# be corrected using another model prober for x-mac-hebrew. Due to the fact89# that x-mac-hebrew texts are so rare, writing another model prober isn't90# worth the effort and performance hit.91#92#### The Prober ####93#94# The prober is divided between two SBCharSetProbers and a HebrewProber,95# all of which are managed, created, fed data, inquired and deleted by the96# SBCSGroupProber. The two SBCharSetProbers identify that the text is in97# fact some kind of Hebrew, Logical or Visual. The final decision about which98# one is it is made by the HebrewProber by combining final-letter scores99# with the scores of the two SBCharSetProbers to produce a final answer.100#101# The SBCSGroupProber is responsible for stripping the original text of HTML102# tags, English characters, numbers, low-ASCII punctuation characters, spaces103# and new lines. It reduces any sequence of such characters to a single space.104# The buffer fed to each prober in the SBCS group prober is pure text in105# high-ASCII.106# The two SBCharSetProbers (model probers) share the same language model:107# Win1255Model.108# The first SBCharSetProber uses the model normally as any other109# SBCharSetProber does, to recognize windows-1255, upon which this model was110# built. The second SBCharSetProber is told to make the pair-of-letter111# lookup in the language model backwards. This in practice exactly simulates112# a visual Hebrew model using the windows-1255 logical Hebrew model.113#114# The HebrewProber is not using any language model. All it does is look for115# final-letter evidence suggesting the text is either logical Hebrew or visual116# Hebrew. Disjointed from the model probers, the results of the HebrewProber117# alone are meaningless. HebrewProber always returns 0.00 as confidence118# since it never identifies a charset by itself. Instead, the pointer to the119# HebrewProber is passed to the model probers as a helper "Name Prober".120# When the Group prober receives a positive identification from any prober,121# it asks for the name of the charset identified. If the prober queried is a122# Hebrew model prober, the model prober forwards the call to the123# HebrewProber to make the final decision. In the HebrewProber, the124# decision is made according to the final-letters scores maintained and Both125# model probers scores. The answer is returned in the form of the name of the126# charset identified, either "windows-1255" or "ISO-8859-8".127128# windows-1255 / ISO-8859-8 code points of interest129FINAL_KAF = '\xea'130NORMAL_KAF = '\xeb'131FINAL_MEM = '\xed'132NORMAL_MEM = '\xee'133FINAL_NUN = '\xef'134NORMAL_NUN = '\xf0'135FINAL_PE = '\xf3'136NORMAL_PE = '\xf4'137FINAL_TSADI = '\xf5'138NORMAL_TSADI = '\xf6'139140# Minimum Visual vs Logical final letter score difference.141# If the difference is below this, don't rely solely on the final letter score142# distance.143MIN_FINAL_CHAR_DISTANCE = 5144145# Minimum Visual vs Logical model score difference.146# If the difference is below this, don't rely at all on the model score147# distance.148MIN_MODEL_DISTANCE = 0.01149150VISUAL_HEBREW_NAME = "ISO-8859-8"151LOGICAL_HEBREW_NAME = "windows-1255"152153154class HebrewProber(CharSetProber):155 def __init__(self):156 CharSetProber.__init__(self)157 self._mLogicalProber = None158 self._mVisualProber = None159 self.reset()160161 def reset(self):162 self._mFinalCharLogicalScore = 0163 self._mFinalCharVisualScore = 0164 # The two last characters seen in the previous buffer,165 # mPrev and mBeforePrev are initialized to space in order to simulate a166 # word delimiter at the beginning of the data167 self._mPrev = ' '168 self._mBeforePrev = ' '169 # These probers are owned by the group prober.170171 def set_model_probers(self, logicalProber, visualProber):172 self._mLogicalProber = logicalProber173 self._mVisualProber = visualProber174175 def is_final(self, c):176 return c in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE, FINAL_TSADI]177178 def is_non_final(self, c):179 # The normal Tsadi is not a good Non-Final letter due to words like180 # 'lechotet' (to chat) containing an apostrophe after the tsadi. This181 # apostrophe is converted to a space in FilterWithoutEnglishLetters182 # causing the Non-Final tsadi to appear at an end of a word even183 # though this is not the case in the original text.184 # The letters Pe and Kaf rarely display a related behavior of not being185 # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'186 # for example legally end with a Non-Final Pe or Kaf. However, the187 # benefit of these letters as Non-Final letters outweighs the damage188 # since these words are quite rare.189 return c in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]190191 def feed(self, aBuf):192 # Final letter analysis for logical-visual decision.193 # Look for evidence that the received buffer is either logical Hebrew194 # or visual Hebrew.195 # The following cases are checked:196 # 1) A word longer than 1 letter, ending with a final letter. This is197 # an indication that the text is laid out "naturally" since the final198 # letter really appears at the end. +1 for logical score.199 # 2) A word longer than 1 letter, ending with a Non-Final letter. In200 # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,201 # should not end with the Non-Final form of that letter. Exceptions202 # to this rule are mentioned above in isNonFinal(). This is an203 # indication that the text is laid out backwards. +1 for visual204 # score205 # 3) A word longer than 1 letter, starting with a final letter. Final206 # letters should not appear at the beginning of a word. This is an207 # indication that the text is laid out backwards. +1 for visual208 # score.209 #210 # The visual score and logical score are accumulated throughout the211 # text and are finally checked against each other in GetCharSetName().212 # No checking for final letters in the middle of words is done since213 # that case is not an indication for either Logical or Visual text.214 #215 # We automatically filter out all 7-bit characters (replace them with216 # spaces) so the word boundary detection works properly. [MAP]217218 if self.get_state() == constants.eNotMe:219 # Both model probers say it's not them. No reason to continue.220 return constants.eNotMe221222 aBuf = self.filter_high_bit_only(aBuf)223224 for cur in aBuf:225 if cur == ' ':226 # We stand on a space - a word just ended227 if self._mBeforePrev != ' ':228 # next-to-last char was not a space so self._mPrev is not a229 # 1 letter word230 if self.is_final(self._mPrev):231 # case (1) [-2:not space][-1:final letter][cur:space]232 self._mFinalCharLogicalScore += 1233 elif self.is_non_final(self._mPrev):234 # case (2) [-2:not space]235 # [-1:Non-Final letter][cur:space]236 self._mFinalCharVisualScore += 1237 else:238 # Not standing on a space239 if ((self._mBeforePrev == ' ') and240 (self.is_final(self._mPrev)) and (cur != ' ')):241 # case (3) [-2:space][-1:final letter][cur:not space]242 self._mFinalCharVisualScore += 1243 self._mBeforePrev = self._mPrev244 self._mPrev = cur245246 # Forever detecting, till the end or until both model probers return247 # eNotMe (handled above)248 return constants.eDetecting249250 def get_charset_name(self):251 # Make the decision: is it Logical or Visual?252 # If the final letter score distance is dominant enough, rely on it.253 finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore254 if finalsub >= MIN_FINAL_CHAR_DISTANCE:255 return LOGICAL_HEBREW_NAME256 if finalsub <= -MIN_FINAL_CHAR_DISTANCE:257 return VISUAL_HEBREW_NAME258259 # It's not dominant enough, try to rely on the model scores instead.260 modelsub = (self._mLogicalProber.get_confidence()261 - self._mVisualProber.get_confidence())262 if modelsub > MIN_MODEL_DISTANCE:263 return LOGICAL_HEBREW_NAME264 if modelsub < -MIN_MODEL_DISTANCE:265 return VISUAL_HEBREW_NAME266267 # Still no good, back to final letter distance, maybe it'll save268 # the day.269 if finalsub < 0.0:270 return VISUAL_HEBREW_NAME271272 # (finalsub > 0 - Logical) or (don't know what to do) default to273 # Logical.274 return LOGICAL_HEBREW_NAME275276 def get_state(self):277 # Remain active as long as any of the model probers are active.278 if (self._mLogicalProber.get_state() == constants.eNotMe) and \279 (self._mVisualProber.get_state() == constants.eNotMe):280 return constants.eNotMe281 return constants.eDetecting1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Shy Shalom6# Portions created by the Initial Developer are Copyright (C) 20057# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .charsetprober import CharSetProber29from .constants import eNotMe, eDetecting30from .compat import wrap_ord3132# This prober doesn't actually recognize a language or a charset.33# It is a helper prober for the use of the Hebrew model probers3435### General ideas of the Hebrew charset recognition ###36#37# Four main charsets exist in Hebrew:38# "ISO-8859-8" - Visual Hebrew39# "windows-1255" - Logical Hebrew40# "ISO-8859-8-I" - Logical Hebrew41# "x-mac-hebrew" - ?? Logical Hebrew ??42#43# Both "ISO" charsets use a completely identical set of code points, whereas44# "windows-1255" and "x-mac-hebrew" are two different proper supersets of45# these code points. windows-1255 defines additional characters in the range46# 0x80-0x9F as some misc punctuation marks as well as some Hebrew-specific47# diacritics and additional 'Yiddish' ligature letters in the range 0xc0-0xd6.48# x-mac-hebrew defines similar additional code points but with a different49# mapping.50#51# As far as an average Hebrew text with no diacritics is concerned, all four52# charsets are identical with respect to code points. Meaning that for the53# main Hebrew alphabet, all four map the same values to all 27 Hebrew letters54# (including final letters).55#56# The dominant difference between these charsets is their directionality.57# "Visual" directionality means that the text is ordered as if the renderer is58# not aware of a BIDI rendering algorithm. The renderer sees the text and59# draws it from left to right. The text itself when ordered naturally is read60# backwards. A buffer of Visual Hebrew generally looks like so:61# "[last word of first line spelled backwards] [whole line ordered backwards62# and spelled backwards] [first word of first line spelled backwards]63# [end of line] [last word of second line] ... etc' "64# adding punctuation marks, numbers and English text to visual text is65# naturally also "visual" and from left to right.66#67# "Logical" directionality means the text is ordered "naturally" according to68# the order it is read. It is the responsibility of the renderer to display69# the text from right to left. A BIDI algorithm is used to place general70# punctuation marks, numbers and English text in the text.71#72# Texts in x-mac-hebrew are almost impossible to find on the Internet. From73# what little evidence I could find, it seems that its general directionality74# is Logical.75#76# To sum up all of the above, the Hebrew probing mechanism knows about two77# charsets:78# Visual Hebrew - "ISO-8859-8" - backwards text - Words and sentences are79# backwards while line order is natural. For charset recognition purposes80# the line order is unimportant (In fact, for this implementation, even81# word order is unimportant).82# Logical Hebrew - "windows-1255" - normal, naturally ordered text.83#84# "ISO-8859-8-I" is a subset of windows-1255 and doesn't need to be85# specifically identified.86# "x-mac-hebrew" is also identified as windows-1255. A text in x-mac-hebrew87# that contain special punctuation marks or diacritics is displayed with88# some unconverted characters showing as question marks. This problem might89# be corrected using another model prober for x-mac-hebrew. Due to the fact90# that x-mac-hebrew texts are so rare, writing another model prober isn't91# worth the effort and performance hit.92#93#### The Prober ####94#95# The prober is divided between two SBCharSetProbers and a HebrewProber,96# all of which are managed, created, fed data, inquired and deleted by the97# SBCSGroupProber. The two SBCharSetProbers identify that the text is in98# fact some kind of Hebrew, Logical or Visual. The final decision about which99# one is it is made by the HebrewProber by combining final-letter scores100# with the scores of the two SBCharSetProbers to produce a final answer.101#102# The SBCSGroupProber is responsible for stripping the original text of HTML103# tags, English characters, numbers, low-ASCII punctuation characters, spaces104# and new lines. It reduces any sequence of such characters to a single space.105# The buffer fed to each prober in the SBCS group prober is pure text in106# high-ASCII.107# The two SBCharSetProbers (model probers) share the same language model:108# Win1255Model.109# The first SBCharSetProber uses the model normally as any other110# SBCharSetProber does, to recognize windows-1255, upon which this model was111# built. The second SBCharSetProber is told to make the pair-of-letter112# lookup in the language model backwards. This in practice exactly simulates113# a visual Hebrew model using the windows-1255 logical Hebrew model.114#115# The HebrewProber is not using any language model. All it does is look for116# final-letter evidence suggesting the text is either logical Hebrew or visual117# Hebrew. Disjointed from the model probers, the results of the HebrewProber118# alone are meaningless. HebrewProber always returns 0.00 as confidence119# since it never identifies a charset by itself. Instead, the pointer to the120# HebrewProber is passed to the model probers as a helper "Name Prober".121# When the Group prober receives a positive identification from any prober,122# it asks for the name of the charset identified. If the prober queried is a123# Hebrew model prober, the model prober forwards the call to the124# HebrewProber to make the final decision. In the HebrewProber, the125# decision is made according to the final-letters scores maintained and Both126# model probers scores. The answer is returned in the form of the name of the127# charset identified, either "windows-1255" or "ISO-8859-8".128129# windows-1255 / ISO-8859-8 code points of interest130FINAL_KAF = 0xea131NORMAL_KAF = 0xeb132FINAL_MEM = 0xed133NORMAL_MEM = 0xee134FINAL_NUN = 0xef135NORMAL_NUN = 0xf0136FINAL_PE = 0xf3137NORMAL_PE = 0xf4138FINAL_TSADI = 0xf5139NORMAL_TSADI = 0xf6140141# Minimum Visual vs Logical final letter score difference.142# If the difference is below this, don't rely solely on the final letter score143# distance.144MIN_FINAL_CHAR_DISTANCE = 5145146# Minimum Visual vs Logical model score difference.147# If the difference is below this, don't rely at all on the model score148# distance.149MIN_MODEL_DISTANCE = 0.01150151VISUAL_HEBREW_NAME = "ISO-8859-8"152LOGICAL_HEBREW_NAME = "windows-1255"153154155class HebrewProber(CharSetProber):156 def __init__(self):157 CharSetProber.__init__(self)158 self._mLogicalProber = None159 self._mVisualProber = None160 self.reset()161162 def reset(self):163 self._mFinalCharLogicalScore = 0164 self._mFinalCharVisualScore = 0165 # The two last characters seen in the previous buffer,166 # mPrev and mBeforePrev are initialized to space in order to simulate167 # a word delimiter at the beginning of the data168 self._mPrev = ' '169 self._mBeforePrev = ' '170 # These probers are owned by the group prober.171172 def set_model_probers(self, logicalProber, visualProber):173 self._mLogicalProber = logicalProber174 self._mVisualProber = visualProber175176 def is_final(self, c):177 return wrap_ord(c) in [FINAL_KAF, FINAL_MEM, FINAL_NUN, FINAL_PE,178 FINAL_TSADI]179180 def is_non_final(self, c):181 # The normal Tsadi is not a good Non-Final letter due to words like182 # 'lechotet' (to chat) containing an apostrophe after the tsadi. This183 # apostrophe is converted to a space in FilterWithoutEnglishLetters184 # causing the Non-Final tsadi to appear at an end of a word even185 # though this is not the case in the original text.186 # The letters Pe and Kaf rarely display a related behavior of not being187 # a good Non-Final letter. Words like 'Pop', 'Winamp' and 'Mubarak'188 # for example legally end with a Non-Final Pe or Kaf. However, the189 # benefit of these letters as Non-Final letters outweighs the damage190 # since these words are quite rare.191 return wrap_ord(c) in [NORMAL_KAF, NORMAL_MEM, NORMAL_NUN, NORMAL_PE]192193 def feed(self, aBuf):194 # Final letter analysis for logical-visual decision.195 # Look for evidence that the received buffer is either logical Hebrew196 # or visual Hebrew.197 # The following cases are checked:198 # 1) A word longer than 1 letter, ending with a final letter. This is199 # an indication that the text is laid out "naturally" since the200 # final letter really appears at the end. +1 for logical score.201 # 2) A word longer than 1 letter, ending with a Non-Final letter. In202 # normal Hebrew, words ending with Kaf, Mem, Nun, Pe or Tsadi,203 # should not end with the Non-Final form of that letter. Exceptions204 # to this rule are mentioned above in isNonFinal(). This is an205 # indication that the text is laid out backwards. +1 for visual206 # score207 # 3) A word longer than 1 letter, starting with a final letter. Final208 # letters should not appear at the beginning of a word. This is an209 # indication that the text is laid out backwards. +1 for visual210 # score.211 #212 # The visual score and logical score are accumulated throughout the213 # text and are finally checked against each other in GetCharSetName().214 # No checking for final letters in the middle of words is done since215 # that case is not an indication for either Logical or Visual text.216 #217 # We automatically filter out all 7-bit characters (replace them with218 # spaces) so the word boundary detection works properly. [MAP]219220 if self.get_state() == eNotMe:221 # Both model probers say it's not them. No reason to continue.222 return eNotMe223224 aBuf = self.filter_high_bit_only(aBuf)225226 for cur in aBuf:227 if cur == ' ':228 # We stand on a space - a word just ended229 if self._mBeforePrev != ' ':230 # next-to-last char was not a space so self._mPrev is not a231 # 1 letter word232 if self.is_final(self._mPrev):233 # case (1) [-2:not space][-1:final letter][cur:space]234 self._mFinalCharLogicalScore += 1235 elif self.is_non_final(self._mPrev):236 # case (2) [-2:not space][-1:Non-Final letter][237 # cur:space]238 self._mFinalCharVisualScore += 1239 else:240 # Not standing on a space241 if ((self._mBeforePrev == ' ') and242 (self.is_final(self._mPrev)) and (cur != ' ')):243 # case (3) [-2:space][-1:final letter][cur:not space]244 self._mFinalCharVisualScore += 1245 self._mBeforePrev = self._mPrev246 self._mPrev = cur247248 # Forever detecting, till the end or until both model probers return249 # eNotMe (handled above)250 return eDetecting251252 def get_charset_name(self):253 # Make the decision: is it Logical or Visual?254 # If the final letter score distance is dominant enough, rely on it.255 finalsub = self._mFinalCharLogicalScore - self._mFinalCharVisualScore256 if finalsub >= MIN_FINAL_CHAR_DISTANCE:257 return LOGICAL_HEBREW_NAME258 if finalsub <= -MIN_FINAL_CHAR_DISTANCE:259 return VISUAL_HEBREW_NAME260261 # It's not dominant enough, try to rely on the model scores instead.262 modelsub = (self._mLogicalProber.get_confidence()263 - self._mVisualProber.get_confidence())264 if modelsub > MIN_MODEL_DISTANCE:265 return LOGICAL_HEBREW_NAME266 if modelsub < -MIN_MODEL_DISTANCE:267 return VISUAL_HEBREW_NAME268269 # Still no good, back to final letter distance, maybe it'll save the270 # day.271 if finalsub < 0.0:272 return VISUAL_HEBREW_NAME273274 # (finalsub > 0 - Logical) or (don't know what to do) default to275 # Logical.276 return LOGICAL_HEBREW_NAME277278 def get_state(self):279 # Remain active as long as any of the model probers are active.280 if (self._mLogicalProber.get_state() == eNotMe) and \281 (self._mVisualProber.get_state() == eNotMe):282 return eNotMe283 return eDetecting
modified:requests/packages/charade/jisfreq.py+9 added-7 removed
11 unmodified lines
12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA
1 unmodified line
2728# Sampling from about 20M text materials include literature and computer technology29#30# Japanese frequency table, applied to both S-JIS and EUC-JP31# They are sorted in order. 31# They are sorted in order.3233# 128 --> 0.7709434# 256 --> 0.8571035# 512 --> 0.92635
1 unmodified line
37# 2048 --> 0.9943138#39# Ideal Distribution Ratio = 0.92635 / (1-0.92635) = 12.5840# Random Distribution Ration = 512 / (2965+62+83+86-512) = 0.19141# 42# Typical Distribution Ratio, 25% of IDR 41#42# Typical Distribution Ratio, 25% of IDR4344JIS_TYPICAL_DISTRIBUTION_RATIO = 3.04546# Char to FreqOrder table , 46# Char to FreqOrder table ,47JIS_TABLE_SIZE = 43684849JISCharToFreqOrder = ( \49JISCharToFreqOrder = (50 40, 1, 6, 182, 152, 180, 295,2127, 285, 381,3295,4304,3068,4606,3165,3510, # 16513511,1822,2785,4607,1193,2226,5070,4608, 171,2996,1247, 18, 179,5071, 856,1661, # 32521262,5072, 619, 127,3431,3512,3230,1899,1700, 232, 228,1294,1298, 284, 283,2041, # 48532042,1061,1062, 48, 49, 44, 45, 433, 434,1040,1041, 996, 787,2997,1255,4305, # 64
510 unmodified lines
5648208,8209,8210,8211,8212,8213,8214,8215,8216,8217,8218,8219,8220,8221,8222,8223, # 82245658224,8225,8226,8227,8228,8229,8230,8231,8232,8233,8234,8235,8236,8237,8238,8239, # 82405668240,8241,8242,8243,8244,8245,8246,8247,8248,8249,8250,8251,8252,8253,8254,8255, # 82565678256,8257,8258,8259,8260,8261,8262,8263,8264,8265,8266,8267,8268,8269,8270,8271) # 8272568569# flake8: noqa
modified:requests/packages/charade/jpcntx.py+219 added-563 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .compat import wrap_ord2930NUM_OF_CATEGORY = 631DONT_KNOW = -132ENOUGH_REL_THRESHOLD = 10033MAX_REL_THRESHOLD = 100034MINIMUM_DATA_THRESHOLD = 43536# This is hiragana 2-char sequence table, the number in each cell represents37# its frequency category38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 1,440 0, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 2, 0, 2, 1, 0, 0, 1, 2, 1, 0, 1,441 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 1, 0, 0, 0, 0,442 0, 1, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, 2),443444 (0, 4, 0, 4, 0, 4, 0, 3, 0, 4, 4, 3, 4, 2, 4, 3, 2, 0, 4, 4, 4, 3, 5, 3,445 5, 3, 3, 2, 4, 2, 4, 3, 4, 3, 1, 4, 0, 2, 3, 4, 4, 4, 3, 3, 3, 4,446 4, 4, 3, 4, 1, 3, 4, 3, 2, 1, 2, 1, 3, 3, 3, 4, 4, 3, 3, 5, 0, 4,447 0, 3, 0, 4, 3, 3, 3, 2, 1, 0, 3, 0, 0, 3, 3),448449 (0, 4, 0, 3, 0, 3, 0, 3, 0, 3, 5, 5, 3, 3, 3, 3, 4, 3, 4, 3, 3, 3, 4, 4,450 4, 3, 3, 3, 3, 4, 3, 5, 3, 3, 1, 3, 2, 4, 5, 5, 5, 5, 4, 3, 4, 5,451 5, 3, 2, 2, 3, 3, 3, 3, 2, 3, 3, 1, 2, 3, 2, 4, 3, 3, 3, 4, 0, 4,452 0, 2, 0, 4, 3, 2, 2, 1, 2, 0, 3, 0, 0, 4, 1),453)454455456class JapaneseContextAnalysis:457 def __init__(self):458 self.reset()459460 def reset(self):461 # total sequence received462 self._mTotalRel = 0463 # category counters, each interger counts sequence in its category464 self._mRelSample = [0] * NUM_OF_CATEGORY465 # if last byte in current buffer is not the last byte of a character,466 # we need to know how many bytes to skip in next buffer467 self._mNeedToSkipCharNum = 0468 # The order of previous char469 self._mLastCharOrder = -1470 # If this flag is set to constants.True, detection is done and471 # conclusion has been made472 self._mDone = False473474 def feed(self, aBuf, aLen):475 if self._mDone:476 return477478 # The buffer we got is byte oriented, and a character may span in more479 # than one buffers. In case the last one or two byte in last buffer is480 # not complete, we record how many byte needed to complete that481 # character and skip these bytes here. We can choose to record those482 # bytes as well and analyse the character once it is complete, but483 # since a character will not make much difference, by simply skipping484 # this character will simply our logic and improve performance.485 i = self._mNeedToSkipCharNum486 while i < aLen:487 order, charLen = self.get_order(aBuf[i:i + 2])488 i += charLen489 if i > aLen:490 self._mNeedToSkipCharNum = i - aLen491 self._mLastCharOrder = -1492 else:493 if (order != -1) and (self._mLastCharOrder != -1):494 self._mTotalRel += 1495 if self._mTotalRel > MAX_REL_THRESHOLD:496 self._mDone = True497 break498 self._mRelSample[499 jp2CharContext[self._mLastCharOrder][order]500 ] += 1501 self._mLastCharOrder = order502503 def got_enough_data(self):504 return self._mTotalRel > ENOUGH_REL_THRESHOLD505506 def get_confidence(self):507 # This is just one way to calculate confidence. It works well for me.508 if self._mTotalRel > MINIMUM_DATA_THRESHOLD:509 return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel510 else:511 return DONT_KNOW512513 def get_order(self, aStr):514 return -1, 1515516517class SJISContextAnalysis(JapaneseContextAnalysis):518 def get_order(self, aStr):519 if not aStr:520 return -1, 1521 # find out current char's byte length522 char = wrap_ord(aStr[0])523 try:524 if (((char >= 0x81) and (char <= 0x9F)) or525 ((char >= 0xE0) and (char <= 0xFC))):526 charLen = 2527 else:528 charLen = 1529 except UnicodeDecodeError:530 return -1, 1531532 # return its order if it is hiragana533 if len(aStr) > 1:534 char_1 = wrap_ord(aStr[1])535 if ((char == 202) and (0x9F <= char_1 <= 0xF1)):536 return char_1 - 0x9F, charLen537538 return -1, charLen539540541class EUCJPContextAnalysis(JapaneseContextAnalysis):542 def get_order(self, aStr):543 if not aStr:544 return -1, 1545 # find out current char's byte length546 char = wrap_ord(aStr[0])547 try:548 if (char == 0x8E) or (0xA1 <= char <= 0xFE):549 charLen = 2550 elif aStr[0] == 0x8F:551 charLen = 3552 else:553 charLen = 1554 except UnicodeDecodeError:555 return -1, 1556557 # return its order if it is hiragana558 if len(aStr) > 1:559 char_1 = wrap_ord(aStr[1])560 if (char == 0xA4) and (0xA1 <= char_1 <= 0xF3):561 return char_1 - 0xA1, charLen562563 return -1, charLen1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .compat import wrap_ord2930NUM_OF_CATEGORY = 631DONT_KNOW = -132ENOUGH_REL_THRESHOLD = 10033MAX_REL_THRESHOLD = 100034MINIMUM_DATA_THRESHOLD = 43536# This is hiragana 2-char sequence table, the number in each cell represents its frequency category37jp2CharContext = (38(0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,1),39(2,4,0,4,0,3,0,4,0,3,4,4,4,2,4,3,3,4,3,2,3,3,4,2,3,3,3,2,4,1,4,3,3,1,5,4,3,4,3,4,3,5,3,0,3,5,4,2,0,3,1,0,3,3,0,3,3,0,1,1,0,4,3,0,3,3,0,4,0,2,0,3,5,5,5,5,4,0,4,1,0,3,4),40(0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0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,1,3,4,3,2,1,2,1,3,3,3,4,4,3,3,5,0,4,0,3,0,4,3,3,3,2,1,0,3,0,0,3,3),120(0,4,0,3,0,3,0,3,0,3,5,5,3,3,3,3,4,3,4,3,3,3,4,4,4,3,3,3,3,4,3,5,3,3,1,3,2,4,5,5,5,5,4,3,4,5,5,3,2,2,3,3,3,3,2,3,3,1,2,3,2,4,3,3,3,4,0,4,0,2,0,4,3,2,2,1,2,0,3,0,0,4,1),121)122123class JapaneseContextAnalysis:124 def __init__(self):125 self.reset()126127 def reset(self):128 self._mTotalRel = 0 # total sequence received129 # category counters, each interger counts sequence in its category130 self._mRelSample = [0] * NUM_OF_CATEGORY131 # if last byte in current buffer is not the last byte of a character,132 # we need to know how many bytes to skip in next buffer133 self._mNeedToSkipCharNum = 0134 self._mLastCharOrder = -1 # The order of previous char135 # If this flag is set to True, detection is done and conclusion has136 # been made137 self._mDone = False138139 def feed(self, aBuf, aLen):140 if self._mDone:141 return142143 # The buffer we got is byte oriented, and a character may span in more than one144 # buffers. In case the last one or two byte in last buffer is not145 # complete, we record how many byte needed to complete that character146 # and skip these bytes here. We can choose to record those bytes as147 # well and analyse the character once it is complete, but since a148 # character will not make much difference, by simply skipping149 # this character will simply our logic and improve performance.150 i = self._mNeedToSkipCharNum151 while i < aLen:152 order, charLen = self.get_order(aBuf[i:i + 2])153 i += charLen154 if i > aLen:155 self._mNeedToSkipCharNum = i - aLen156 self._mLastCharOrder = -1157 else:158 if (order != -1) and (self._mLastCharOrder != -1):159 self._mTotalRel += 1160 if self._mTotalRel > MAX_REL_THRESHOLD:161 self._mDone = True162 break163 self._mRelSample[jp2CharContext[self._mLastCharOrder][order]] += 1164 self._mLastCharOrder = order165166 def got_enough_data(self):167 return self._mTotalRel > ENOUGH_REL_THRESHOLD168169 def get_confidence(self):170 # This is just one way to calculate confidence. It works well for me.171 if self._mTotalRel > MINIMUM_DATA_THRESHOLD:172 return (self._mTotalRel - self._mRelSample[0]) / self._mTotalRel173 else:174 return DONT_KNOW175176 def get_order(self, aBuf):177 return -1, 1178179class SJISContextAnalysis(JapaneseContextAnalysis):180 def get_order(self, aBuf):181 if not aBuf:182 return -1, 1183 # find out current char's byte length184 first_char = wrap_ord(aBuf[0])185 if ((0x81 <= first_char <= 0x9F) or (0xE0 <= first_char <= 0xFC)):186 charLen = 2187 else:188 charLen = 1189190 # return its order if it is hiragana191 if len(aBuf) > 1:192 second_char = wrap_ord(aBuf[1])193 if (first_char == 202) and (0x9F <= second_char <= 0xF1):194 return second_char - 0x9F, charLen195196 return -1, charLen197198class EUCJPContextAnalysis(JapaneseContextAnalysis):199 def get_order(self, aBuf):200 if not aBuf:201 return -1, 1202 # find out current char's byte length203 first_char = wrap_ord(aBuf[0])204 if (first_char == 0x8E) or (0xA1 <= first_char <= 0xFE):205 charLen = 2206 elif first_char == 0x8F:207 charLen = 3208 else:209 charLen = 1210211 # return its order if it is hiragana212 if len(aBuf) > 1:213 second_char = wrap_ord(aBuf[1])214 if (first_char == 0xA4) and (0xA1 <= second_char <= 0xF3):215 return second_char - 0xA1, charLen216217 return -1, charLen218219# flake8: noqa
modified:requests/packages/charade/langbulgarianmodel.py+229 added-262 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# Character Mapping Table:34# this table is modified base on win1251BulgarianCharToOrderMap, so35# only number <64 is sure valid3637Latin5_BulgarianCharToOrderMap = (38255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 255, # 0039255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, # 1040253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, # 2041252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, # 3042253, 77, 90, 99, 100, 72, 109, 107, 101, 79, 185, 81, 102, 76, 94, 82, # 4043110, 186, 108, 91, 74, 119, 84, 96, 111, 187, 115, 253, 253, 253, 253, 253, # 5044253, 65, 69, 70, 66, 63, 68, 112, 103, 92, 194, 104, 95, 86, 87, 71, # 6045116, 195, 85, 93, 97, 113, 196, 197, 198, 199, 200, 253, 253, 253, 253, 253, # 7046194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, # 8047210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, # 9048 81, 226, 227, 228, 229, 230, 105, 231, 232, 233, 234, 235, 236, 45, 237, 238, # a049 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b050 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61, 239, 67, 240, 60, 56, # c051 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d052 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52, 241, 42, 16, # e053 62, 242, 243, 244, 58, 245, 98, 246, 247, 248, 249, 250, 251, 91, 252, 253, # f054)5556win1251BulgarianCharToOrderMap = (57255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 255, 255, 254, 255, 255, # 0058255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, # 1059253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, 253, # 2060252, 252, 252, 252, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, # 3061253, 77, 90, 99, 100, 72, 109, 107, 101, 79, 185, 81, 102, 76, 94, 82, # 4062110, 186, 108, 91, 74, 119, 84, 96, 111, 187, 115, 253, 253, 253, 253, 253, # 5063253, 65, 69, 70, 66, 63, 68, 112, 103, 92, 194, 104, 95, 86, 87, 71, # 6064116, 195, 85, 93, 97, 113, 196, 197, 198, 199, 200, 253, 253, 253, 253, 253, # 7065206, 207, 208, 209, 210, 211, 212, 213, 120, 214, 215, 216, 217, 218, 219, 220, # 8066221, 78, 64, 83, 121, 98, 117, 105, 222, 223, 224, 225, 226, 227, 228, 229, # 9067 88, 230, 231, 232, 233, 122, 89, 106, 234, 235, 236, 237, 238, 45, 239, 240, # a068 73, 80, 118, 114, 241, 242, 243, 244, 245, 62, 58, 246, 247, 248, 249, 250, # b069 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c070 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61, 251, 67, 252, 60, 56, # d071 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e072 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52, 253, 42, 16, # f073)7475# Model Table: 76# total sequences: 100%77# first 512 sequences: 96.9392%78# first 1024 sequences:3.0618%79# rest sequences: 0.2992%80# negative sequences: 0.0020%81BulgarianLangModel = (82 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3,83 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,84 3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 0, 0, 1,246)247248Latin5BulgarianModel = {249 'charToOrderMap': Latin5_BulgarianCharToOrderMap,250 'precedenceMatrix': BulgarianLangModel,251 'mTypicalPositiveRatio': 0.969392,252 'keepEnglishLetter': False,253 'charsetName': "ISO-8859-5"254}255256Win1251BulgarianModel = {257 'charToOrderMap': win1251BulgarianCharToOrderMap,258 'precedenceMatrix': BulgarianLangModel,259 'mTypicalPositiveRatio': 0.969392,260 'keepEnglishLetter': False,261 'charsetName': "windows-1251"262}1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# Character Mapping Table:34# this table is modified base on win1251BulgarianCharToOrderMap, so35# only number <64 is sure valid3637Latin5_BulgarianCharToOrderMap = (38255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0039255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1040253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2041252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3042253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 4043110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 5044253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 6045116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 7046194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209, # 8047210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225, # 9048 81,226,227,228,229,230,105,231,232,233,234,235,236, 45,237,238, # a049 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # b050 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,239, 67,240, 60, 56, # c051 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # d052 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,241, 42, 16, # e053 62,242,243,244, 58,245, 98,246,247,248,249,250,251, 91,252,253, # f054)5556win1251BulgarianCharToOrderMap = (57255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0058255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1059253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2060252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3061253, 77, 90, 99,100, 72,109,107,101, 79,185, 81,102, 76, 94, 82, # 4062110,186,108, 91, 74,119, 84, 96,111,187,115,253,253,253,253,253, # 5063253, 65, 69, 70, 66, 63, 68,112,103, 92,194,104, 95, 86, 87, 71, # 6064116,195, 85, 93, 97,113,196,197,198,199,200,253,253,253,253,253, # 7065206,207,208,209,210,211,212,213,120,214,215,216,217,218,219,220, # 8066221, 78, 64, 83,121, 98,117,105,222,223,224,225,226,227,228,229, # 9067 88,230,231,232,233,122, 89,106,234,235,236,237,238, 45,239,240, # a068 73, 80,118,114,241,242,243,244,245, 62, 58,246,247,248,249,250, # b069 31, 32, 35, 43, 37, 44, 55, 47, 40, 59, 33, 46, 38, 36, 41, 30, # c070 39, 28, 34, 51, 48, 49, 53, 50, 54, 57, 61,251, 67,252, 60, 56, # d071 1, 18, 9, 20, 11, 3, 23, 15, 2, 26, 12, 10, 14, 6, 4, 13, # e072 7, 8, 5, 19, 29, 25, 22, 21, 27, 24, 17, 75, 52,253, 42, 16, # f073)7475# Model Table:76# total sequences: 100%77# first 512 sequences: 96.9392%78# first 1024 sequences:3.0618%79# rest sequences: 0.2992%80# negative sequences: 0.0020%81BulgarianLangModel = (820,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,3,3,3,3,3,833,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,2,2,3,2,2,1,2,2,843,1,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,0,1,850,0,0,0,0,0,0,0,0,0,1,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,863,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,3,3,3,3,3,3,3,0,3,1,0,870,1,0,0,0,0,0,0,0,0,1,1,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,883,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,890,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,903,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,1,3,2,3,3,3,3,3,3,3,3,0,3,0,0,910,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,923,3,3,3,3,3,3,3,3,3,3,2,3,2,2,1,3,3,3,3,2,2,2,1,1,2,0,1,0,1,0,0,930,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,1,943,3,3,3,3,3,3,2,3,2,2,3,3,1,1,2,3,3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0,1,0,2051,1,1,1,1,1,1,2,0,0,0,0,0,0,2,1,0,1,1,0,0,1,1,1,0,1,0,0,0,0,0,0,2062,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2070,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2081,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,0,1,1,1,1,1,0,1,0,0,2090,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,210)211212Latin5BulgarianModel = {213 'charToOrderMap': Latin5_BulgarianCharToOrderMap,214 'precedenceMatrix': BulgarianLangModel,215 'mTypicalPositiveRatio': 0.969392,216 'keepEnglishLetter': False,217 'charsetName': "ISO-8859-5"218}219220Win1251BulgarianModel = {221 'charToOrderMap': win1251BulgarianCharToOrderMap,222 'precedenceMatrix': BulgarianLangModel,223 'mTypicalPositiveRatio': 0.969392,224 'keepEnglishLetter': False,225 'charsetName': "windows-1251"226}227228229# flake8: noqa
modified:requests/packages/charade/langcyrillicmodel.py+331 added-329 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# KOI8-R language model29# Character Mapping Table:30KOI8R_CharToOrderMap = (31255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0032255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1033253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2034252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3035253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4036155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5037253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6038 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7039191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 8040207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 9041223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a042238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b043 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c044 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d045 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e046 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f047)4849win1251_CharToOrderMap = (50255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0051255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1052253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2053252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3054253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4055155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5056253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6057 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7058191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,59207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,60223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,61239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,62 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,63 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,64 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,65 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,66)6768latin5_CharToOrderMap = (69255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0070255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1071253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2072252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3073253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4074155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5075253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6076 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7077191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,78207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,79223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,80 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,81 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,82 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,83 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,84239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,85)8687macCyrillic_CharToOrderMap = (88255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0089255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1090253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2091252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3092253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4093155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5094253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6095 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7096 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,97 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,98191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,99207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,100223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,101239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,102 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,103 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,104)105106IBM855_CharToOrderMap = (107255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00108255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10109253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20110252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30111253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40112155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50113253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60114 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70115191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,116206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,117 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,118220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,119230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,120 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,121 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,122250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,123)124125IBM866_CharToOrderMap = (126255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00127255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10128253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20129252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30130253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40131155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50132253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60133 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70134 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,135 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,136 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,137191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,138207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,139223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,140 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,141239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,142)143144# Model Table: 145# total sequences: 100%146# first 512 sequences: 97.6601%147# first 1024 sequences: 2.3389%148# rest sequences: 0.1237%149# negative sequences: 0.0009% 150R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0,0,0,2770,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2780,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,279)280281Koi8rModel = {282 'charToOrderMap': KOI8R_CharToOrderMap,283 'precedenceMatrix': RussianLangModel,284 'mTypicalPositiveRatio': 0.976601,285 'keepEnglishLetter': False,286 'charsetName': "KOI8-R"287}288289Win1251CyrillicModel = {290 'charToOrderMap': win1251_CharToOrderMap,291 'precedenceMatrix': RussianLangModel,292 'mTypicalPositiveRatio': 0.976601,293 'keepEnglishLetter': False,294 'charsetName': "windows-1251"295}296297Latin5CyrillicModel = {298 'charToOrderMap': latin5_CharToOrderMap,299 'precedenceMatrix': RussianLangModel,300 'mTypicalPositiveRatio': 0.976601,301 'keepEnglishLetter': False,302 'charsetName': "ISO-8859-5"303}304305MacCyrillicModel = {306 'charToOrderMap': macCyrillic_CharToOrderMap,307 'precedenceMatrix': RussianLangModel,308 'mTypicalPositiveRatio': 0.976601,309 'keepEnglishLetter': False,310 'charsetName': "MacCyrillic"311};312313Ibm866Model = {314 'charToOrderMap': IBM866_CharToOrderMap,315 'precedenceMatrix': RussianLangModel,316 'mTypicalPositiveRatio': 0.976601,317 'keepEnglishLetter': False,318 'charsetName': "IBM866"319}320321Ibm855Model = {322 'charToOrderMap': IBM855_CharToOrderMap,323 'precedenceMatrix': RussianLangModel,324 'mTypicalPositiveRatio': 0.976601,325 'keepEnglishLetter': False,326 'charsetName': "IBM855"327}328329# flake8: noqa3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants2930# KOI8-R language model31# Character Mapping Table:32KOI8R_CharToOrderMap = (33255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0034255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1035253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2036252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3037253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4038155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5039253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6040 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7041191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206, # 8042207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222, # 9043223,224,225, 68,226,227,228,229,230,231,232,233,234,235,236,237, # a044238,239,240,241,242,243,244,245,246,247,248,249,250,251,252,253, # b045 27, 3, 21, 28, 13, 2, 39, 19, 26, 4, 23, 11, 8, 12, 5, 1, # c046 15, 16, 9, 7, 6, 14, 24, 10, 17, 18, 20, 25, 30, 29, 22, 54, # d047 59, 37, 44, 58, 41, 48, 53, 46, 55, 42, 60, 36, 49, 38, 31, 34, # e048 35, 43, 45, 32, 40, 52, 56, 33, 61, 62, 51, 57, 47, 63, 50, 70, # f049)5051win1251_CharToOrderMap = (52255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0053255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1054253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2055252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3056253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4057155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5058253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6059 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7060191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,61207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,62223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,63239,240,241,242,243,244,245,246, 68,247,248,249,250,251,252,253,64 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,65 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,66 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,67 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,68)6970latin5_CharToOrderMap = (71255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0072255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1073253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2074252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3075253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4076155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5077253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6078 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7079191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,80207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,81223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,82 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,83 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,84 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,85 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,86239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,87)8889macCyrillic_CharToOrderMap = (90255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0091255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1092253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2093252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3094253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 4095155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 5096253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 6097 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 7098 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,99 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,100191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,101207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,102223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,103239,240,241,242,243,244,245,246,247,248,249,250,251,252, 68, 16,104 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,105 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27,255,106)107108IBM855_CharToOrderMap = (109255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00110255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10111253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20112252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30113253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40114155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50115253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60116 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70117191,192,193,194, 68,195,196,197,198,199,200,201,202,203,204,205,118206,207,208,209,210,211,212,213,214,215,216,217, 27, 59, 54, 70,119 3, 37, 21, 44, 28, 58, 13, 41, 2, 48, 39, 53, 19, 46,218,219,120220,221,222,223,224, 26, 55, 4, 42,225,226,227,228, 23, 60,229,121230,231,232,233,234,235, 11, 36,236,237,238,239,240,241,242,243,122 8, 49, 12, 38, 5, 31, 1, 34, 15,244,245,246,247, 35, 16,248,123 43, 9, 45, 7, 32, 6, 40, 14, 52, 24, 56, 10, 33, 17, 61,249,124250, 18, 62, 20, 51, 25, 57, 30, 47, 29, 63, 22, 50,251,252,255,125)126127IBM866_CharToOrderMap = (128255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 00129255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 10130253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 20131252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 30132253,142,143,144,145,146,147,148,149,150,151,152, 74,153, 75,154, # 40133155,156,157,158,159,160,161,162,163,164,165,253,253,253,253,253, # 50134253, 71,172, 66,173, 65,174, 76,175, 64,176,177, 77, 72,178, 69, # 60135 67,179, 78, 73,180,181, 79,182,183,184,185,253,253,253,253,253, # 70136 37, 44, 33, 46, 41, 48, 56, 51, 42, 60, 36, 49, 38, 31, 34, 35,137 45, 32, 40, 52, 53, 55, 58, 50, 57, 63, 70, 62, 61, 47, 59, 43,138 3, 21, 10, 19, 13, 2, 24, 20, 4, 23, 11, 8, 12, 5, 1, 15,139191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,140207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,141223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,142 9, 7, 6, 14, 39, 26, 28, 22, 25, 29, 54, 18, 17, 30, 27, 16,143239, 68,240,241,242,243,244,245,246,247,248,249,250,251,252,255,144)145146# Model Table:147# total sequences: 100%148# first 512 sequences: 97.6601%149# first 1024 sequences: 2.3389%150# rest sequences: 0.1237%151# negative sequences: 0.0009%152RussianLangModel = (1530,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,1,3,3,3,3,1,3,3,3,2,3,2,3,3,1543,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,0,3,2,2,2,2,2,0,0,2,1553,3,3,2,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,2,3,2,0,1560,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1573,3,3,2,2,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,2,3,3,1,0,1580,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1593,2,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,1600,0,0,0,0,0,0,2,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1613,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,0,0,3,3,3,3,3,3,3,3,3,3,3,2,1,1620,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1633,3,3,3,3,3,3,3,2,2,2,3,1,3,3,1,3,3,3,3,2,2,3,0,2,2,2,3,3,2,1,0,1640,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1653,3,3,3,3,3,2,3,3,3,3,3,2,2,3,2,3,3,3,2,1,2,2,0,1,2,2,2,2,2,2,0,1660,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,2781,1,0,1,1,0,1,0,1,0,0,0,0,1,1,0,1,1,0,0,0,0,0,1,0,1,1,0,1,0,0,0,2790,1,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2800,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,281)282283Koi8rModel = {284 'charToOrderMap': KOI8R_CharToOrderMap,285 'precedenceMatrix': RussianLangModel,286 'mTypicalPositiveRatio': 0.976601,287 'keepEnglishLetter': False,288 'charsetName': "KOI8-R"289}290291Win1251CyrillicModel = {292 'charToOrderMap': win1251_CharToOrderMap,293 'precedenceMatrix': RussianLangModel,294 'mTypicalPositiveRatio': 0.976601,295 'keepEnglishLetter': False,296 'charsetName': "windows-1251"297}298299Latin5CyrillicModel = {300 'charToOrderMap': latin5_CharToOrderMap,301 'precedenceMatrix': RussianLangModel,302 'mTypicalPositiveRatio': 0.976601,303 'keepEnglishLetter': False,304 'charsetName': "ISO-8859-5"305}306307MacCyrillicModel = {308 'charToOrderMap': macCyrillic_CharToOrderMap,309 'precedenceMatrix': RussianLangModel,310 'mTypicalPositiveRatio': 0.976601,311 'keepEnglishLetter': False,312 'charsetName': "MacCyrillic"313};314315Ibm866Model = {316 'charToOrderMap': IBM866_CharToOrderMap,317 'precedenceMatrix': RussianLangModel,318 'mTypicalPositiveRatio': 0.976601,319 'keepEnglishLetter': False,320 'charsetName': "IBM866"321}322323Ibm855Model = {324 'charToOrderMap': IBM855_CharToOrderMap,325 'precedenceMatrix': RussianLangModel,326 'mTypicalPositiveRatio': 0.976601,327 'keepEnglishLetter': False,328 'charsetName': "IBM855"329}330331# flake8: noqa
modified:requests/packages/charade/langgreekmodel.py+227 added-225 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# Character Mapping Table:34Latin7_CharToOrderMap = (35255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0036255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1037253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2038252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3039253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4040 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5041253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6042 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7043255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8044255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9045253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a046253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b047110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c048 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d049124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e050 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f051)5253win1253_CharToOrderMap = (54255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0055255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1056253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2057252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3058253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4059 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5060253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6061 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7062255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8063255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9064253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a065253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b066110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c067 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d068124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e069 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f070)7172# Model Table: 73# total sequences: 100%74# first 512 sequences: 98.2851%75# first 1024 sequences:1.7001%76# rest sequences: 0.0359%77# negative sequences: 0.0148% 78GreekLangModel = (790,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,800,0,0,0,0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,207)208209Latin7GreekModel = {210 'charToOrderMap': Latin7_CharToOrderMap,211 'precedenceMatrix': GreekLangModel,212 'mTypicalPositiveRatio': 0.982851,213 'keepEnglishLetter': False,214 'charsetName': "ISO-8859-7"215}216217Win1253GreekModel = {218 'charToOrderMap': win1253_CharToOrderMap,219 'precedenceMatrix': GreekLangModel,220 'mTypicalPositiveRatio': 0.982851,221 'keepEnglishLetter': False,222 'charsetName': "windows-1253"223}224225# flake8: noqa3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants2930# 255: Control characters that usually does not exist in any text31# 254: Carriage/Return32# 253: symbol (punctuation) that does not belong to word33# 252: 0 - 93435# Character Mapping Table:36Latin7_CharToOrderMap = (37255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4042 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5043253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6044 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7045255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8046255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9047253,233, 90,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a048253,253,253,253,247,248, 61, 36, 46, 71, 73,253, 54,253,108,123, # b049110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c050 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d051124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e052 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f053)5455win1253_CharToOrderMap = (56255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0057255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1058253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2059252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3060253, 82,100,104, 94, 98,101,116,102,111,187,117, 92, 88,113, 85, # 4061 79,118,105, 83, 67,114,119, 95, 99,109,188,253,253,253,253,253, # 5062253, 72, 70, 80, 81, 60, 96, 93, 89, 68,120, 97, 77, 86, 69, 55, # 6063 78,115, 65, 66, 58, 76,106,103, 87,107,112,253,253,253,253,253, # 7064255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 8065255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 9066253,233, 61,253,253,253,253,253,253,253,253,253,253, 74,253,253, # a067253,253,253,253,247,253,253, 36, 46, 71, 73,253, 54,253,108,123, # b068110, 31, 51, 43, 41, 34, 91, 40, 52, 47, 44, 53, 38, 49, 59, 39, # c069 35, 48,250, 37, 33, 45, 56, 50, 84, 57,120,121, 17, 18, 22, 15, # d070124, 1, 29, 20, 21, 3, 32, 13, 25, 5, 11, 16, 10, 6, 30, 4, # e071 9, 8, 14, 7, 2, 12, 28, 23, 42, 24, 64, 75, 19, 26, 27,253, # f072)7374# Model Table:75# total sequences: 100%76# first 512 sequences: 98.2851%77# first 1024 sequences:1.7001%78# rest sequences: 0.0359%79# negative sequences: 0.0148%80GreekLangModel = (810,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,820,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,830,0,3,2,2,3,3,3,3,3,3,3,3,1,3,3,3,0,2,2,3,3,0,3,0,3,2,0,3,3,3,0,843,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,850,3,3,3,3,3,0,3,3,0,3,2,3,3,0,3,2,3,3,3,0,0,3,0,3,0,3,3,2,0,0,0,862,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,870,2,3,2,2,3,3,3,3,3,3,3,3,0,3,3,3,3,0,2,3,3,0,3,3,3,3,2,3,3,3,0,882,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,890,2,3,3,2,3,3,3,3,3,3,3,3,3,3,3,3,0,2,1,3,3,3,3,2,3,3,2,3,3,2,0,900,0,0,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,910,3,3,3,3,0,3,3,3,3,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,3,0,3,2,3,3,0,922,0,1,0,2,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,930,3,3,3,3,3,2,3,0,0,0,0,3,3,0,3,1,3,3,3,0,3,3,0,3,3,3,3,0,0,0,0,942,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2060,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2070,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2080,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,209)210211Latin7GreekModel = {212 'charToOrderMap': Latin7_CharToOrderMap,213 'precedenceMatrix': GreekLangModel,214 'mTypicalPositiveRatio': 0.982851,215 'keepEnglishLetter': False,216 'charsetName': "ISO-8859-7"217}218219Win1253GreekModel = {220 'charToOrderMap': win1253_CharToOrderMap,221 'precedenceMatrix': GreekLangModel,222 'mTypicalPositiveRatio': 0.982851,223 'keepEnglishLetter': False,224 'charsetName': "windows-1253"225}226227# flake8: noqa
modified:requests/packages/charade/langhebrewmodel.py+203 added-201 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Simon Montagu6# Portions created by the Initial Developer are Copyright (C) 20057# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Shoshannah Forbes - original C code (?)13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18# 19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23# 24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930# 255: Control characters that usually does not exist in any text31# 254: Carriage/Return32# 253: symbol (punctuation) that does not belong to word33# 252: 0 - 93435# Windows-1255 language model36# Character Mapping Table:37win1255_CharToOrderMap = (38255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0039255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1040253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2041252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3042253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 4043 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 5044253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 6045 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 7046124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,47215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,48 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,49106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,50 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,51238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,52 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,53 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,54)5556# Model Table: 57# total sequences: 100%58# first 512 sequences: 98.4004%59# first 1024 sequences: 1.5981%60# rest sequences: 0.087%61# negative sequences: 0.0015% 62HebrewLangModel = (630,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0,643,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1,653,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,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'keepEnglishLetter': False,198 'charsetName': "windows-1255"199}200201# flake8: noqa3#4# The Initial Developer of the Original Code is5# Simon Montagu6# Portions created by the Initial Developer are Copyright (C) 20057# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Shoshannah Forbes - original C code (?)13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18#19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23#24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930from . import constants3132# 255: Control characters that usually does not exist in any text33# 254: Carriage/Return34# 253: symbol (punctuation) that does not belong to word35# 252: 0 - 93637# Windows-1255 language model38# Character Mapping Table:39win1255_CharToOrderMap = (40255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0041255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1042253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2043252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3044253, 69, 91, 79, 80, 92, 89, 97, 90, 68,111,112, 82, 73, 95, 85, # 4045 78,121, 86, 71, 67,102,107, 84,114,103,115,253,253,253,253,253, # 5046253, 50, 74, 60, 61, 42, 76, 70, 64, 53,105, 93, 56, 65, 54, 49, # 6047 66,110, 51, 43, 44, 63, 81, 77, 98, 75,108,253,253,253,253,253, # 7048124,202,203,204,205, 40, 58,206,207,208,209,210,211,212,213,214,49215, 83, 52, 47, 46, 72, 32, 94,216,113,217,109,218,219,220,221,50 34,116,222,118,100,223,224,117,119,104,125,225,226, 87, 99,227,51106,122,123,228, 55,229,230,101,231,232,120,233, 48, 39, 57,234,52 30, 59, 41, 88, 33, 37, 36, 31, 29, 35,235, 62, 28,236,126,237,53238, 38, 45,239,240,241,242,243,127,244,245,246,247,248,249,250,54 9, 8, 20, 16, 3, 2, 24, 14, 22, 1, 25, 15, 4, 11, 6, 23,55 12, 19, 13, 26, 18, 27, 21, 17, 7, 10, 5,251,252,128, 96,253,56)5758# Model Table:59# total sequences: 100%60# first 512 sequences: 98.4004%61# first 1024 sequences: 1.5981%62# rest sequences: 0.087%63# negative sequences: 0.0015%64HebrewLangModel = (650,3,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,3,2,1,2,0,1,0,0,663,0,3,1,0,0,1,3,2,0,1,1,2,0,2,2,2,1,1,1,1,2,1,1,1,2,0,0,2,2,0,1,673,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,681,2,1,2,1,2,0,0,2,0,0,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,693,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,2,2,701,2,1,3,1,1,0,0,2,0,0,0,1,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,713,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,0,1,2,2,1,3,721,2,1,1,2,2,0,0,2,2,0,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,1,0,1,1,0,733,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,2,2,2,2,3,2,741,2,1,2,2,2,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,1,0,753,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,3,2,3,2,2,3,2,2,2,1,2,2,2,2,761,2,1,1,2,2,0,1,2,0,0,0,0,0,0,0,1,0,0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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1881,0,0,0,0,0,0,0,1,0,1,1,0,0,1,0,0,2,1,1,1,1,1,0,1,0,0,0,0,1,0,1,1890,1,1,1,2,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,0,0,0,0,0,0,0,1900,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1911,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1920,0,0,0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,1,1,1,1,1,0,1,0,0,0,1,1,0,0,193)194195Win1255HebrewModel = {196 'charToOrderMap': win1255_CharToOrderMap,197 'precedenceMatrix': HebrewLangModel,198 'mTypicalPositiveRatio': 0.984004,199 'keepEnglishLetter': False,200 'charsetName': "windows-1255"201}202203# flake8: noqa
modified:requests/packages/charade/langhungarianmodel.py+227 added-225 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# Character Mapping Table:34Latin2_HungarianCharToOrderMap = (35255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0036255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1037253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2038252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3039253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,40 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,41253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,42 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,43159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,44175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,45191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,46 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,47221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,48232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,49 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,50245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,51)5253win1250HungarianCharToOrderMap = (54255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0055255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1056253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2057252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3058253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,59 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,60253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,61 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,62161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,63177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,64191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,65 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,66221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,67232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,68 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,69245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,70)7172# Model Table: 73# total sequences: 100%74# first 512 sequences: 94.7368%75# first 1024 sequences:5.2623%76# rest sequences: 0.8894%77# negative sequences: 0.0009% 78HungarianLangModel = (790,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,803,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,813,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,820,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,833,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1,840,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,853,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3,3,3,3,1,3,3,2,2,0,3,2,3,860,0,0,0,0,0,0,0,0,0,3,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,873,3,3,3,3,3,2,3,3,3,2,3,3,2,3,3,3,3,3,2,3,3,2,2,3,2,3,2,0,3,2,2,880,0,0,0,0,0,0,0,0,0,2,0,0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0,0,0,0,0,1991,0,0,1,1,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2000,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,2010,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2020,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,2032,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,2040,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2051,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2060,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,207)208209Latin2HungarianModel = {210 'charToOrderMap': Latin2_HungarianCharToOrderMap,211 'precedenceMatrix': HungarianLangModel,212 'mTypicalPositiveRatio': 0.947368,213 'keepEnglishLetter': True,214 'charsetName': "ISO-8859-2"215}216217Win1250HungarianModel = {218 'charToOrderMap': win1250HungarianCharToOrderMap,219 'precedenceMatrix': HungarianLangModel,220 'mTypicalPositiveRatio': 0.947368,221 'keepEnglishLetter': True,222 'charsetName': "windows-1250"223}224225# flake8: noqa3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants2930# 255: Control characters that usually does not exist in any text31# 254: Carriage/Return32# 253: symbol (punctuation) that does not belong to word33# 252: 0 - 93435# Character Mapping Table:36Latin2_HungarianCharToOrderMap = (37255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,42 46, 71, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,43253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,44 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,45159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,46175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,47191,192,193,194,195,196,197, 75,198,199,200,201,202,203,204,205,48 79,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,49221, 51, 81,222, 78,223,224,225,226, 44,227,228,229, 61,230,231,50232,233,234, 58,235, 66, 59,236,237,238, 60, 69, 63,239,240,241,51 82, 14, 74,242, 70, 80,243, 72,244, 15, 83, 77, 84, 30, 76, 85,52245,246,247, 25, 73, 42, 24,248,249,250, 31, 56, 29,251,252,253,53)5455win1250HungarianCharToOrderMap = (56255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0057255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1058253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2059252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3060253, 28, 40, 54, 45, 32, 50, 49, 38, 39, 53, 36, 41, 34, 35, 47,61 46, 72, 43, 33, 37, 57, 48, 64, 68, 55, 52,253,253,253,253,253,62253, 2, 18, 26, 17, 1, 27, 12, 20, 9, 22, 7, 6, 13, 4, 8,63 23, 67, 10, 5, 3, 21, 19, 65, 62, 16, 11,253,253,253,253,253,64161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,65177,178,179,180, 78,181, 69,182,183,184,185,186,187,188,189,190,66191,192,193,194,195,196,197, 76,198,199,200,201,202,203,204,205,67 81,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,68221, 51, 83,222, 80,223,224,225,226, 44,227,228,229, 61,230,231,69232,233,234, 58,235, 66, 59,236,237,238, 60, 70, 63,239,240,241,70 84, 14, 75,242, 71, 82,243, 73,244, 15, 85, 79, 86, 30, 77, 87,71245,246,247, 25, 74, 42, 24,248,249,250, 31, 56, 29,251,252,253,72)7374# Model Table:75# total sequences: 100%76# first 512 sequences: 94.7368%77# first 1024 sequences:5.2623%78# rest sequences: 0.8894%79# negative sequences: 0.0009%80HungarianLangModel = (810,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,823,3,3,3,3,3,3,3,3,3,2,3,3,3,3,3,3,3,3,2,2,3,3,1,1,2,2,2,2,2,1,2,833,2,2,3,3,3,3,3,2,3,3,3,3,3,3,1,2,3,3,3,3,2,3,3,1,1,3,3,0,1,1,1,840,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,853,2,1,3,3,3,3,3,2,3,3,3,3,3,1,1,2,3,3,3,3,3,3,3,1,1,3,2,0,1,1,1,860,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,873,3,3,3,3,3,3,3,3,3,3,1,1,2,3,3,3,1,3,3,3,3,3,1,3,3,2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2,0,1,1,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,1991,0,0,1,1,1,1,1,0,0,2,1,0,1,0,0,0,1,0,1,0,0,0,0,0,0,1,0,0,0,0,0,2000,1,1,1,1,1,1,0,1,1,0,1,0,1,1,0,1,1,0,0,1,1,1,0,0,0,0,0,0,0,0,0,2011,0,0,1,1,1,0,0,0,0,1,0,2,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,2020,1,1,1,1,1,0,0,1,1,0,1,0,1,0,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,2030,0,0,1,0,0,0,0,0,0,1,1,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2040,1,1,1,0,1,0,0,1,1,0,1,0,1,1,0,1,1,1,0,1,1,1,0,0,0,0,0,0,0,0,0,2052,1,1,1,1,1,1,1,1,1,1,0,0,1,1,1,0,0,1,0,0,1,0,1,0,1,1,1,0,0,1,0,2060,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2071,0,0,1,1,1,1,0,0,0,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,2080,1,1,1,1,1,1,0,1,1,0,1,0,1,0,0,1,1,0,0,1,1,0,0,0,0,0,0,0,0,0,0,209)210211Latin2HungarianModel = {212 'charToOrderMap': Latin2_HungarianCharToOrderMap,213 'precedenceMatrix': HungarianLangModel,214 'mTypicalPositiveRatio': 0.947368,215 'keepEnglishLetter': True,216 'charsetName': "ISO-8859-2"217}218219Win1250HungarianModel = {220 'charToOrderMap': win1250HungarianCharToOrderMap,221 'precedenceMatrix': HungarianLangModel,222 'mTypicalPositiveRatio': 0.947368,223 'keepEnglishLetter': True,224 'charsetName': "windows-1250"225}226227# flake8: noqa
modified:requests/packages/charade/langthaimodel.py+200 added-200 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16# 17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21# 22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# The following result for thai was collected from a limited sample (1M). 3435# Character Mapping Table:36TIS620CharToOrderMap = (37255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 4042188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 5043253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 6044 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 7045209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,46223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,47236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,48 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,49 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,50 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,51 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,52 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,53)5455# Model Table: 56# total sequences: 100%57# first 512 sequences: 92.6386%58# first 1024 sequences:7.3177%59# rest sequences: 1.0230%60# negative sequences: 0.0436% 61ThaiLangModel = (620,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,630,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,643,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3,650,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0,1,1,663,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,3,3,2,3,2,3,3,2,2,2,673,1,2,3,0,3,3,2,2,1,2,3,3,1,2,0,1,3,0,1,0,0,1,0,0,0,0,0,0,0,1,1,683,3,2,2,3,3,3,3,1,2,3,3,3,3,3,2,2,2,2,3,3,2,2,3,3,2,2,3,2,3,2,2,693,3,1,2,3,1,2,2,3,3,1,0,2,1,0,0,3,1,2,1,0,0,1,0,0,0,0,0,0,1,0,1,703,3,3,3,3,3,2,2,3,3,3,3,2,3,2,2,3,3,2,2,3,2,2,2,2,1,1,3,1,2,1,1,713,2,1,0,2,1,0,1,0,1,1,0,1,1,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,723,3,3,2,3,2,3,3,2,2,3,2,3,3,2,3,1,1,2,3,2,2,2,3,2,2,2,2,2,1,2,1,732,2,1,1,3,3,2,1,0,1,2,2,0,1,3,0,0,0,1,1,0,0,0,0,0,2,3,0,0,2,1,1,743,3,2,3,3,2,0,0,3,3,0,3,3,0,2,2,3,1,2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,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1860,0,1,1,0,0,2,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1870,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1882,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1890,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190)191192TIS620ThaiModel = {193 'charToOrderMap': TIS620CharToOrderMap,194 'precedenceMatrix': ThaiLangModel,195 'mTypicalPositiveRatio': 0.926386,196 'keepEnglishLetter': False,197 'charsetName': "TIS-620"198}199200# flake8: noqa1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Communicator client code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728# 255: Control characters that usually does not exist in any text29# 254: Carriage/Return30# 253: symbol (punctuation) that does not belong to word31# 252: 0 - 93233# The following result for thai was collected from a limited sample (1M).3435# Character Mapping Table:36TIS620CharToOrderMap = (37255,255,255,255,255,255,255,255,255,255,254,255,255,254,255,255, # 0038255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, # 1039253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253, # 2040252,252,252,252,252,252,252,252,252,252,253,253,253,253,253,253, # 3041253,182,106,107,100,183,184,185,101, 94,186,187,108,109,110,111, # 4042188,189,190, 89, 95,112,113,191,192,193,194,253,253,253,253,253, # 5043253, 64, 72, 73,114, 74,115,116,102, 81,201,117, 90,103, 78, 82, # 6044 96,202, 91, 79, 84,104,105, 97, 98, 92,203,253,253,253,253,253, # 7045209,210,211,212,213, 88,214,215,216,217,218,219,220,118,221,222,46223,224, 99, 85, 83,225,226,227,228,229,230,231,232,233,234,235,47236, 5, 30,237, 24,238, 75, 8, 26, 52, 34, 51,119, 47, 58, 57,48 49, 53, 55, 43, 20, 19, 44, 14, 48, 3, 17, 25, 39, 62, 31, 54,49 45, 9, 16, 2, 61, 15,239, 12, 42, 46, 18, 21, 76, 4, 66, 63,50 22, 10, 1, 36, 23, 13, 40, 27, 32, 35, 86,240,241,242,243,244,51 11, 28, 41, 29, 33,245, 50, 37, 6, 7, 67, 77, 38, 93,246,247,52 68, 56, 59, 65, 69, 60, 70, 80, 71, 87,248,249,250,251,252,253,53)5455# Model Table:56# total sequences: 100%57# first 512 sequences: 92.6386%58# first 1024 sequences:7.3177%59# rest sequences: 1.0230%60# negative sequences: 0.0436%61ThaiLangModel = (620,1,3,3,3,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,0,0,3,3,3,0,3,3,3,3,630,3,3,0,0,0,1,3,0,3,3,2,3,3,0,1,2,3,3,3,3,0,2,0,2,0,0,3,2,1,2,2,643,0,3,3,2,3,0,0,3,3,0,3,3,0,3,3,3,3,3,3,3,3,3,0,3,2,3,0,2,2,2,3,650,2,3,0,0,0,0,1,0,1,2,3,1,1,3,2,2,0,1,1,0,0,1,0,0,0,0,0,0,0,1,1,663,3,3,2,3,3,3,3,3,3,3,3,3,3,3,2,2,2,2,2,2,2,3,3,2,3,2,3,3,2,2,2,673,1,2,3,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0,0,0,1782,0,0,0,0,2,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,1,0,1,0,0,0,0,0,0,0,0,1790,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1802,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1810,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,3,0,0,0,1822,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1830,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,1,0,0,0,0,1841,0,0,0,0,0,0,0,0,1,0,0,0,0,2,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,1850,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1860,0,1,1,0,0,2,1,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1870,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1882,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1890,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,190)191192TIS620ThaiModel = {193 'charToOrderMap': TIS620CharToOrderMap,194 'precedenceMatrix': ThaiLangModel,195 'mTypicalPositiveRatio': 0.926386,196 'keepEnglishLetter': False,197 'charsetName': "TIS-620"198}199200# flake8: noqa
modified:requests/packages/charade/latin1prober.py+139 added-142 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829from .charsetprober import CharSetProber30from .constants import eError, eNotMe31from .compat import wrap_ord3233FREQ_CAT_NUM = 43435UDF = 0 # undefined36OTH = 1 # other37ASC = 2 # ascii capital letter38ASS = 3 # ascii small letter39ACV = 4 # accent capital vowel40ACO = 5 # accent capital other41ASV = 6 # accent small vowel42ASO = 7 # accent small other43CLASS_NUM = 8 # total classes4445Latin1_CharToClass = (46 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 0747 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F48 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 1749 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F50 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 2751 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F52 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 3753 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F54 OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 4755 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F56 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 5757 ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F58 OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 6759 ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F60 ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 7761 ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F62 OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 8763 OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F64 UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 9765 OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F66 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A767 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF68 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B769 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF70 ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C771 ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF72 ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D773 ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF74 ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E775 ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF76 ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F777 ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF78)7980# 0 : illegal81# 1 : very unlikely82# 2 : normal83# 3 : very likely84Latin1ClassModel = (85 # UDF OTH ASC ASS ACV ACO ASV ASO86 0, 0, 0, 0, 0, 0, 0, 0, # UDF87 0, 3, 3, 3, 3, 3, 3, 3, # OTH88 0, 3, 3, 3, 3, 3, 3, 3, # ASC89 0, 3, 3, 3, 1, 1, 3, 3, # ASS90 0, 3, 3, 3, 1, 2, 1, 2, # ACV91 0, 3, 3, 3, 3, 3, 3, 3, # ACO92 0, 3, 1, 3, 1, 1, 1, 3, # ASV93 0, 3, 1, 3, 1, 1, 3, 3, # ASO94)959697class Latin1Prober(CharSetProber):98 def __init__(self):99 CharSetProber.__init__(self)100 self.reset()101102 def reset(self):103 self._mLastCharClass = OTH104 self._mFreqCounter = [0] * FREQ_CAT_NUM105 CharSetProber.reset(self)106107 def get_charset_name(self):108 return "windows-1252"109110 def feed(self, aBuf):111 aBuf = self.filter_with_english_letters(aBuf)112 for c in aBuf:113 try:114 charClass = Latin1_CharToClass[wrap_ord(c)]115 except IndexError:116 return eError117 freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)118 + charClass]119 if freq == 0:120 self._mState = eNotMe121 break122 self._mFreqCounter[freq] += 1123 self._mLastCharClass = charClass124125 return self.get_state()126127 def get_confidence(self):128 if self.get_state() == eNotMe:129 return 0.01130131 total = sum(self._mFreqCounter)132 if total < 0.01:133 confidence = 0.0134 else:135 confidence = ((self._mFreqCounter[3] / total)136 - (self._mFreqCounter[1] * 20.0 / total))137 if confidence < 0.0:138 confidence = 0.0139 # lower the confidence of latin1 so that other more accurate detector140 # can take priority.141 confidence = confidence * 0.5142 return confidence1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829from .charsetprober import CharSetProber30from .constants import eNotMe31from .compat import wrap_ord3233FREQ_CAT_NUM = 43435UDF = 0 # undefined36OTH = 1 # other37ASC = 2 # ascii capital letter38ASS = 3 # ascii small letter39ACV = 4 # accent capital vowel40ACO = 5 # accent capital other41ASV = 6 # accent small vowel42ASO = 7 # accent small other43CLASS_NUM = 8 # total classes4445Latin1_CharToClass = (46 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 00 - 0747 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 08 - 0F48 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 10 - 1749 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 18 - 1F50 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 20 - 2751 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 28 - 2F52 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 30 - 3753 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 38 - 3F54 OTH, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 40 - 4755 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 48 - 4F56 ASC, ASC, ASC, ASC, ASC, ASC, ASC, ASC, # 50 - 5757 ASC, ASC, ASC, OTH, OTH, OTH, OTH, OTH, # 58 - 5F58 OTH, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 60 - 6759 ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 68 - 6F60 ASS, ASS, ASS, ASS, ASS, ASS, ASS, ASS, # 70 - 7761 ASS, ASS, ASS, OTH, OTH, OTH, OTH, OTH, # 78 - 7F62 OTH, UDF, OTH, ASO, OTH, OTH, OTH, OTH, # 80 - 8763 OTH, OTH, ACO, OTH, ACO, UDF, ACO, UDF, # 88 - 8F64 UDF, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # 90 - 9765 OTH, OTH, ASO, OTH, ASO, UDF, ASO, ACO, # 98 - 9F66 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A0 - A767 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # A8 - AF68 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B0 - B769 OTH, OTH, OTH, OTH, OTH, OTH, OTH, OTH, # B8 - BF70 ACV, ACV, ACV, ACV, ACV, ACV, ACO, ACO, # C0 - C771 ACV, ACV, ACV, ACV, ACV, ACV, ACV, ACV, # C8 - CF72 ACO, ACO, ACV, ACV, ACV, ACV, ACV, OTH, # D0 - D773 ACV, ACV, ACV, ACV, ACV, ACO, ACO, ACO, # D8 - DF74 ASV, ASV, ASV, ASV, ASV, ASV, ASO, ASO, # E0 - E775 ASV, ASV, ASV, ASV, ASV, ASV, ASV, ASV, # E8 - EF76 ASO, ASO, ASV, ASV, ASV, ASV, ASV, OTH, # F0 - F777 ASV, ASV, ASV, ASV, ASV, ASO, ASO, ASO, # F8 - FF78)7980# 0 : illegal81# 1 : very unlikely82# 2 : normal83# 3 : very likely84Latin1ClassModel = (85 # UDF OTH ASC ASS ACV ACO ASV ASO86 0, 0, 0, 0, 0, 0, 0, 0, # UDF87 0, 3, 3, 3, 3, 3, 3, 3, # OTH88 0, 3, 3, 3, 3, 3, 3, 3, # ASC89 0, 3, 3, 3, 1, 1, 3, 3, # ASS90 0, 3, 3, 3, 1, 2, 1, 2, # ACV91 0, 3, 3, 3, 3, 3, 3, 3, # ACO92 0, 3, 1, 3, 1, 1, 1, 3, # ASV93 0, 3, 1, 3, 1, 1, 3, 3, # ASO94)959697class Latin1Prober(CharSetProber):98 def __init__(self):99 CharSetProber.__init__(self)100 self.reset()101102 def reset(self):103 self._mLastCharClass = OTH104 self._mFreqCounter = [0] * FREQ_CAT_NUM105 CharSetProber.reset(self)106107 def get_charset_name(self):108 return "windows-1252"109110 def feed(self, aBuf):111 aBuf = self.filter_with_english_letters(aBuf)112 for c in aBuf:113 charClass = Latin1_CharToClass[wrap_ord(c)]114 freq = Latin1ClassModel[(self._mLastCharClass * CLASS_NUM)115 + charClass]116 if freq == 0:117 self._mState = eNotMe118 break119 self._mFreqCounter[freq] += 1120 self._mLastCharClass = charClass121122 return self.get_state()123124 def get_confidence(self):125 if self.get_state() == eNotMe:126 return 0.01127128 total = sum(self._mFreqCounter)129 if total < 0.01:130 confidence = 0.0131 else:132 confidence = ((self._mFreqCounter[3] / total)133 - (self._mFreqCounter[1] * 20.0 / total))134 if confidence < 0.0:135 confidence = 0.0136 # lower the confidence of latin1 so that other more accurate137 # detector can take priority.138 confidence = confidence * 0.5139 return confidence
modified:requests/packages/charade/mbcharsetprober.py+86 added-86 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Proofpoint, Inc.13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18#19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23#24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930import sys31from . import constants32from .charsetprober import CharSetProber333435class MultiByteCharSetProber(CharSetProber):36 def __init__(self):37 CharSetProber.__init__(self)38 self._mDistributionAnalyzer = None39 self._mCodingSM = None40 self._mLastChar = ['\x00', '\x00']4142 def reset(self):43 CharSetProber.reset(self)44 if self._mCodingSM:45 self._mCodingSM.reset()46 if self._mDistributionAnalyzer:47 self._mDistributionAnalyzer.reset()48 self._mLastChar = ['\x00', '\x00']4950 def get_charset_name(self):51 pass5253 def feed(self, aBuf):54 aLen = len(aBuf)55 for i in range(0, aLen):56 codingState = self._mCodingSM.next_state(aBuf[i])57 if codingState == constants.eError:58 if constants._debug:59 sys.stderr.write(self.get_charset_name() +60 ' prober hit error at byte ' + str(i) +61 '\n')62 self._mState = constants.eNotMe63 break64 elif codingState == constants.eItsMe:65 self._mState = constants.eFoundIt66 break67 elif codingState == constants.eStart:68 charLen = self._mCodingSM.get_current_charlen()69 if i == 0:70 self._mLastChar[1] = aBuf[0]71 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72 else:73 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],74 charLen)7576 self._mLastChar[0] = aBuf[aLen - 1]7778 if self.get_state() == constants.eDetecting:79 if (self._mDistributionAnalyzer.got_enough_data() and80 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):81 self._mState = constants.eFoundIt8283 return self.get_state()8485 def get_confidence(self):86 return self._mDistributionAnalyzer.get_confidence()1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Proofpoint, Inc.13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18#19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23#24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930import sys31from . import constants32from .charsetprober import CharSetProber333435class MultiByteCharSetProber(CharSetProber):36 def __init__(self):37 CharSetProber.__init__(self)38 self._mDistributionAnalyzer = None39 self._mCodingSM = None40 self._mLastChar = [0, 0]4142 def reset(self):43 CharSetProber.reset(self)44 if self._mCodingSM:45 self._mCodingSM.reset()46 if self._mDistributionAnalyzer:47 self._mDistributionAnalyzer.reset()48 self._mLastChar = [0, 0]4950 def get_charset_name(self):51 pass5253 def feed(self, aBuf):54 aLen = len(aBuf)55 for i in range(0, aLen):56 codingState = self._mCodingSM.next_state(aBuf[i])57 if codingState == constants.eError:58 if constants._debug:59 sys.stderr.write(self.get_charset_name()60 + ' prober hit error at byte ' + str(i)61 + '\n')62 self._mState = constants.eNotMe63 break64 elif codingState == constants.eItsMe:65 self._mState = constants.eFoundIt66 break67 elif codingState == constants.eStart:68 charLen = self._mCodingSM.get_current_charlen()69 if i == 0:70 self._mLastChar[1] = aBuf[0]71 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72 else:73 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],74 charLen)7576 self._mLastChar[0] = aBuf[aLen - 1]7778 if self.get_state() == constants.eDetecting:79 if (self._mDistributionAnalyzer.got_enough_data() and80 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):81 self._mState = constants.eFoundIt8283 return self.get_state()8485 def get_confidence(self):86 return self._mDistributionAnalyzer.get_confidence()
modified:requests/packages/charade/mbcsgroupprober.py+52 added-52 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Proofpoint, Inc.13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18#19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23#24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930from .charsetgroupprober import CharSetGroupProber31from .utf8prober import UTF8Prober32from .sjisprober import SJISProber33from .eucjpprober import EUCJPProber34from .gb2312prober import GB2312Prober35from .euckrprober import EUCKRProber36from .big5prober import Big5Prober37from .euctwprober import EUCTWProber383940class MBCSGroupProber(CharSetGroupProber):41 def __init__(self):42 CharSetGroupProber.__init__(self)43 self._mProbers = [44 UTF8Prober(),45 SJISProber(),46 EUCJPProber(),47 GB2312Prober(),48 EUCKRProber(),49 Big5Prober(),50 EUCTWProber()51 ]52 self.reset()1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12# Proofpoint, Inc.13#14# This library is free software; you can redistribute it and/or15# modify it under the terms of the GNU Lesser General Public16# License as published by the Free Software Foundation; either17# version 2.1 of the License, or (at your option) any later version.18#19# This library is distributed in the hope that it will be useful,20# but WITHOUT ANY WARRANTY; without even the implied warranty of21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU22# Lesser General Public License for more details.23#24# You should have received a copy of the GNU Lesser General Public25# License along with this library; if not, write to the Free Software26# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA27# 02110-1301 USA28######################### END LICENSE BLOCK #########################2930from .charsetgroupprober import CharSetGroupProber31from .utf8prober import UTF8Prober32from .sjisprober import SJISProber33from .eucjpprober import EUCJPProber34from .gb2312prober import GB2312Prober35from .euckrprober import EUCKRProber36from .big5prober import Big5Prober37from .euctwprober import EUCTWProber383940class MBCSGroupProber(CharSetGroupProber):41 def __init__(self):42 CharSetGroupProber.__init__(self)43 self._mProbers = [44 UTF8Prober(),45 SJISProber(),46 EUCJPProber(),47 GB2312Prober(),48 EUCKRProber(),49 Big5Prober(),50 EUCTWProber()51 ]52 self.reset()
modified:requests/packages/charade/mbcssm.py+535 added-529 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart, eError, eItsMe2930# BIG53132BIG5_cls = (33 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07 #allow 0x00 as legal value34 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f35 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 1736 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f37 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 2738 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f39 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 3740 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f41 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 4742 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f43 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 5744 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f45 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 6746 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f47 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 7748 2, 2, 2, 2, 2, 2, 2, 1, # 78 - 7f49 4, 4, 4, 4, 4, 4, 4, 4, # 80 - 8750 4, 4, 4, 4, 4, 4, 4, 4, # 88 - 8f51 4, 4, 4, 4, 4, 4, 4, 4, # 90 - 9752 4, 4, 4, 4, 4, 4, 4, 4, # 98 - 9f53 4, 3, 3, 3, 3, 3, 3, 3, # a0 - a754 3, 3, 3, 3, 3, 3, 3, 3, # a8 - af55 3, 3, 3, 3, 3, 3, 3, 3, # b0 - b756 3, 3, 3, 3, 3, 3, 3, 3, # b8 - bf57 3, 3, 3, 3, 3, 3, 3, 3, # c0 - c758 3, 3, 3, 3, 3, 3, 3, 3, # c8 - cf59 3, 3, 3, 3, 3, 3, 3, 3, # d0 - d760 3, 3, 3, 3, 3, 3, 3, 3, # d8 - df61 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e762 3, 3, 3, 3, 3, 3, 3, 3, # e8 - ef63 3, 3, 3, 3, 3, 3, 3, 3, # f0 - f764 3, 3, 3, 3, 3, 3, 3, 0) # f8 - ff6566BIG5_st = (67 eError, eStart, eStart, 3, eError, eError, eError, eError, # 00-0768 eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, # 08-0f69 eError, eStart, eStart, eStart, eStart, eStart, eStart, eStart, # 10-1770)7172Big5CharLenTable = (0, 1, 1, 2, 0)7374Big5SMModel = {'classTable': BIG5_cls,75 'classFactor': 5,76 'stateTable': BIG5_st,77 'charLenTable': Big5CharLenTable,78 'name': 'Big5'}7980# EUC-JP8182EUCJP_cls = (83 4, 4, 4, 4, 4, 4, 4, 4, # 00 - 0784 4, 4, 4, 4, 4, 4, 5, 5, # 08 - 0f85 4, 4, 4, 4, 4, 4, 4, 4, # 10 - 1786 4, 4, 4, 5, 4, 4, 4, 4, # 18 - 1f87 4, 4, 4, 4, 4, 4, 4, 4, # 20 - 2788 4, 4, 4, 4, 4, 4, 4, 4, # 28 - 2f89 4, 4, 4, 4, 4, 4, 4, 4, # 30 - 3790 4, 4, 4, 4, 4, 4, 4, 4, # 38 - 3f91 4, 4, 4, 4, 4, 4, 4, 4, # 40 - 4792 4, 4, 4, 4, 4, 4, 4, 4, # 48 - 4f93 4, 4, 4, 4, 4, 4, 4, 4, # 50 - 5794 4, 4, 4, 4, 4, 4, 4, 4, # 58 - 5f95 4, 4, 4, 4, 4, 4, 4, 4, # 60 - 6796 4, 4, 4, 4, 4, 4, 4, 4, # 68 - 6f97 4, 4, 4, 4, 4, 4, 4, 4, # 70 - 7798 4, 4, 4, 4, 4, 4, 4, 4, # 78 - 7f99 5, 5, 5, 5, 5, 5, 5, 5, # 80 - 87100 5, 5, 5, 5, 5, 5, 1, 3, # 88 - 8f101 5, 5, 5, 5, 5, 5, 5, 5, # 90 - 97102 5, 5, 5, 5, 5, 5, 5, 5, # 98 - 9f103 5, 2, 2, 2, 2, 2, 2, 2, # a0 - a7104 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af105 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7106 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf107 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7108 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf109 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7110 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df111 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7112 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef113 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7114 0, 0, 0, 0, 0, 0, 0, 5) # f8 - ff115116EUCJP_st = (117 3, 4, 3, 5, eStart, eError, eError, eError, # 00-07118 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f119 eItsMe, eItsMe, eStart, eError, eStart, eError, eError, eError, # 10-17120 eError, eError, eStart, eError, eError, eError, 3, eError, # 18-1f121 3, eError, eError, eError, eStart, eStart, eStart, eStart, # 20-27122)123124EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)125126EUCJPSMModel = {'classTable': EUCJP_cls,127 'classFactor': 6,128 'stateTable': EUCJP_st,129 'charLenTable': EUCJPCharLenTable,130 'name': 'EUC-JP'}131132# EUC-KR133134EUCKR_cls = (135 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07136 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f137 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17138 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f139 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27140 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f141 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37142 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f143 1, 1, 1, 1, 1, 1, 1, 1, # 40 - 47144 1, 1, 1, 1, 1, 1, 1, 1, # 48 - 4f145 1, 1, 1, 1, 1, 1, 1, 1, # 50 - 57146 1, 1, 1, 1, 1, 1, 1, 1, # 58 - 5f147 1, 1, 1, 1, 1, 1, 1, 1, # 60 - 67148 1, 1, 1, 1, 1, 1, 1, 1, # 68 - 6f149 1, 1, 1, 1, 1, 1, 1, 1, # 70 - 77150 1, 1, 1, 1, 1, 1, 1, 1, # 78 - 7f151 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87152 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f153 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97154 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f155 0, 2, 2, 2, 2, 2, 2, 2, # a0 - a7156 2, 2, 2, 2, 2, 3, 3, 3, # a8 - af157 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7158 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf159 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7160 2, 3, 2, 2, 2, 2, 2, 2, # c8 - cf161 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7162 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df163 2, 2, 2, 2, 2, 2, 2, 2, # e0 - e7164 2, 2, 2, 2, 2, 2, 2, 2, # e8 - ef165 2, 2, 2, 2, 2, 2, 2, 2, # f0 - f7166 2, 2, 2, 2, 2, 2, 2, 0, # f8 - ff167)168169EUCKR_st = (170 eError, eStart, 3, eError, eError, eError, eError, eError, # 00-07171 eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, eStart, eStart, # 08-0f172)173174EUCKRCharLenTable = (0, 1, 2, 0)175176EUCKRSMModel = {'classTable': EUCKR_cls,177 'classFactor': 4,178 'stateTable': EUCKR_st,179 'charLenTable': EUCKRCharLenTable,180 'name': 'EUC-KR'}181182# EUC-TW183184EUCTW_cls = (185 2, 2, 2, 2, 2, 2, 2, 2, # 00 - 07186 2, 2, 2, 2, 2, 2, 0, 0, # 08 - 0f187 2, 2, 2, 2, 2, 2, 2, 2, # 10 - 17188 2, 2, 2, 0, 2, 2, 2, 2, # 18 - 1f189 2, 2, 2, 2, 2, 2, 2, 2, # 20 - 27190 2, 2, 2, 2, 2, 2, 2, 2, # 28 - 2f191 2, 2, 2, 2, 2, 2, 2, 2, # 30 - 37192 2, 2, 2, 2, 2, 2, 2, 2, # 38 - 3f193 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47194 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f195 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57196 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f197 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67198 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f199 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77200 2, 2, 2, 2, 2, 2, 2, 2, # 78 - 7f201 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87202 0, 0, 0, 0, 0, 0, 6, 0, # 88 - 8f203 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97204 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f205 0, 3, 4, 4, 4, 4, 4, 4, # a0 - a7206 5, 5, 1, 1, 1, 1, 1, 1, # a8 - af207 1, 1, 1, 1, 1, 1, 1, 1, # b0 - b7208 1, 1, 1, 1, 1, 1, 1, 1, # b8 - bf209 1, 1, 3, 1, 3, 3, 3, 3, # c0 - c7210 3, 3, 3, 3, 3, 3, 3, 3, # c8 - cf211 3, 3, 3, 3, 3, 3, 3, 3, # d0 - d7212 3, 3, 3, 3, 3, 3, 3, 3, # d8 - df213 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e7214 3, 3, 3, 3, 3, 3, 3, 3, # e8 - ef215 3, 3, 3, 3, 3, 3, 3, 3, # f0 - f7216 3, 3, 3, 3, 3, 3, 3, 0, # f8 - ff217)218219EUCTW_st = (220 eError, eError, eStart, 3, 3, 3, 4, eError, # 00-07221 eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 08-0f222 eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eStart, eError, # 10-17223 eStart, eStart, eStart, eError, eError, eError, eError, eError, # 18-1f224 5, eError, eError, eError, eStart, eError, eStart, eStart, # 20-27225 eStart, eError, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f226)227228EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)229230EUCTWSMModel = {'classTable': EUCTW_cls,231 'classFactor': 7,232 'stateTable': EUCTW_st,233 'charLenTable': EUCTWCharLenTable,234 'name': 'x-euc-tw'}235236# GB2312237238GB2312_cls = (239 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07240 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f241 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17242 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f243 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27244 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f245 3, 3, 3, 3, 3, 3, 3, 3, # 30 - 37246 3, 3, 1, 1, 1, 1, 1, 1, # 38 - 3f247 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47248 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f249 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57250 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f251 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67252 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f253 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77254 2, 2, 2, 2, 2, 2, 2, 4, # 78 - 7f255 5, 6, 6, 6, 6, 6, 6, 6, # 80 - 87256 6, 6, 6, 6, 6, 6, 6, 6, # 88 - 8f257 6, 6, 6, 6, 6, 6, 6, 6, # 90 - 97258 6, 6, 6, 6, 6, 6, 6, 6, # 98 - 9f259 6, 6, 6, 6, 6, 6, 6, 6, # a0 - a7260 6, 6, 6, 6, 6, 6, 6, 6, # a8 - af261 6, 6, 6, 6, 6, 6, 6, 6, # b0 - b7262 6, 6, 6, 6, 6, 6, 6, 6, # b8 - bf263 6, 6, 6, 6, 6, 6, 6, 6, # c0 - c7264 6, 6, 6, 6, 6, 6, 6, 6, # c8 - cf265 6, 6, 6, 6, 6, 6, 6, 6, # d0 - d7266 6, 6, 6, 6, 6, 6, 6, 6, # d8 - df267 6, 6, 6, 6, 6, 6, 6, 6, # e0 - e7268 6, 6, 6, 6, 6, 6, 6, 6, # e8 - ef269 6, 6, 6, 6, 6, 6, 6, 6, # f0 - f7270 6, 6, 6, 6, 6, 6, 6, 0, # f8 - ff271)272273GB2312_st = (274 eError, eStart, eStart, eStart, eStart, eStart, 3, eError, # 00-07275 eError, eError, eError, eError, eError, eError, eItsMe, eItsMe, # 08-0f276 eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eError, eError, eStart, # 10-17277 4, eError, eStart, eStart, eError, eError, eError, eError, # 18-1f278 eError, eError, 5, eError, eError, eError, eItsMe, eError, # 20-27279 eError, eError, eStart, eStart, eStart, eStart, eStart, eStart, # 28-2f280)281282# To be accurate, the length of class 6 can be either 2 or 4.283# But it is not necessary to discriminate between the two since284# it is used for frequency analysis only, and we are validing285# each code range there as well. So it is safe to set it to be286# 2 here.287GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)288289GB2312SMModel = {'classTable': GB2312_cls,290 'classFactor': 7,291 'stateTable': GB2312_st,292 'charLenTable': GB2312CharLenTable,293 'name': 'GB2312'}294295# Shift_JIS296297SJIS_cls = (298 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07299 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f300 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17301 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f302 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27303 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f304 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37305 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f306 2, 2, 2, 2, 2, 2, 2, 2, # 40 - 47307 2, 2, 2, 2, 2, 2, 2, 2, # 48 - 4f308 2, 2, 2, 2, 2, 2, 2, 2, # 50 - 57309 2, 2, 2, 2, 2, 2, 2, 2, # 58 - 5f310 2, 2, 2, 2, 2, 2, 2, 2, # 60 - 67311 2, 2, 2, 2, 2, 2, 2, 2, # 68 - 6f312 2, 2, 2, 2, 2, 2, 2, 2, # 70 - 77313 2, 2, 2, 2, 2, 2, 2, 1, # 78 - 7f314 3, 3, 3, 3, 3, 3, 3, 3, # 80 - 87315 3, 3, 3, 3, 3, 3, 3, 3, # 88 - 8f316 3, 3, 3, 3, 3, 3, 3, 3, # 90 - 97317 3, 3, 3, 3, 3, 3, 3, 3, # 98 - 9f318 #0xa0 is illegal in sjis encoding, but some pages does319 #contain such byte. We need to be more error forgiven.320 2, 2, 2, 2, 2, 2, 2, 2, # a0 - a7321 2, 2, 2, 2, 2, 2, 2, 2, # a8 - af322 2, 2, 2, 2, 2, 2, 2, 2, # b0 - b7323 2, 2, 2, 2, 2, 2, 2, 2, # b8 - bf324 2, 2, 2, 2, 2, 2, 2, 2, # c0 - c7325 2, 2, 2, 2, 2, 2, 2, 2, # c8 - cf326 2, 2, 2, 2, 2, 2, 2, 2, # d0 - d7327 2, 2, 2, 2, 2, 2, 2, 2, # d8 - df328 3, 3, 3, 3, 3, 3, 3, 3, # e0 - e7329 3, 3, 3, 3, 3, 4, 4, 4, # e8 - ef330 4, 4, 4, 4, 4, 4, 4, 4, # f0 - f7331 4, 4, 4, 4, 4, 0, 0, 0) # f8 - ff332333SJIS_st = (334 eError, eStart, eStart, 3, eError, eError, eError, eError, # 00-07335 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f336 eItsMe, eItsMe, eError, eError, eStart, eStart, eStart, eStart, # 10-17337)338339SJISCharLenTable = (0, 1, 1, 2, 0, 0)340341SJISSMModel = {'classTable': SJIS_cls,342 'classFactor': 6,343 'stateTable': SJIS_st,344 'charLenTable': SJISCharLenTable,345 'name': 'Shift_JIS'}346347# UCS2-BE348349UCS2BE_cls = (350 0, 0, 0, 0, 0, 0, 0, 0, # 00 - 07351 0, 0, 1, 0, 0, 2, 0, 0, # 08 - 0f352 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17353 0, 0, 0, 3, 0, 0, 0, 0, # 18 - 1f354 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27355 0, 3, 3, 3, 3, 3, 0, 0, # 28 - 2f356 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37357 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f358 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 47359 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f360 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57361 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f362 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67363 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f364 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77365 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f366 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87367 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f368 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97369 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f370 0, 0, 0, 0, 0, 0, 0, 0, # a0 - a7371 0, 0, 0, 0, 0, 0, 0, 0, # a8 - af372 0, 0, 0, 0, 0, 0, 0, 0, # b0 - b7373 0, 0, 0, 0, 0, 0, 0, 0, # b8 - bf374 0, 0, 0, 0, 0, 0, 0, 0, # c0 - c7375 0, 0, 0, 0, 0, 0, 0, 0, # c8 - cf376 0, 0, 0, 0, 0, 0, 0, 0, # d0 - d7377 0, 0, 0, 0, 0, 0, 0, 0, # d8 - df378 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7379 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef380 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7381 0, 0, 0, 0, 0, 0, 4, 5, # f8 - ff382)383384UCS2BE_st = (385 5, 7, 7, eError, 4, 3, eError, eError, # 00-07386 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f387 eItsMe, eItsMe, 6, 6, 6, 6, eError, eError, # 10-17388 6, 6, 6, 6, 6, eItsMe, 6, 6, # 18-1f389 6, 6, 6, 6, 5, 7, 7, eError, # 20-27390 5, 8, 6, 6, eError, 6, 6, 6, # 28-2f391 6, 6, 6, 6, eError, eError, eStart, eStart, # 30-37392)393394UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)395396UCS2BESMModel = {'classTable': UCS2BE_cls,397 'classFactor': 6,398 'stateTable': UCS2BE_st,399 'charLenTable': UCS2BECharLenTable,400 'name': 'UTF-16BE'}401402# UCS2-LE403404UCS2LE_cls = (405 0, 0, 0, 0, 0, 0, 0, 0, # 00 - 07406 0, 0, 1, 0, 0, 2, 0, 0, # 08 - 0f407 0, 0, 0, 0, 0, 0, 0, 0, # 10 - 17408 0, 0, 0, 3, 0, 0, 0, 0, # 18 - 1f409 0, 0, 0, 0, 0, 0, 0, 0, # 20 - 27410 0, 3, 3, 3, 3, 3, 0, 0, # 28 - 2f411 0, 0, 0, 0, 0, 0, 0, 0, # 30 - 37412 0, 0, 0, 0, 0, 0, 0, 0, # 38 - 3f413 0, 0, 0, 0, 0, 0, 0, 0, # 40 - 47414 0, 0, 0, 0, 0, 0, 0, 0, # 48 - 4f415 0, 0, 0, 0, 0, 0, 0, 0, # 50 - 57416 0, 0, 0, 0, 0, 0, 0, 0, # 58 - 5f417 0, 0, 0, 0, 0, 0, 0, 0, # 60 - 67418 0, 0, 0, 0, 0, 0, 0, 0, # 68 - 6f419 0, 0, 0, 0, 0, 0, 0, 0, # 70 - 77420 0, 0, 0, 0, 0, 0, 0, 0, # 78 - 7f421 0, 0, 0, 0, 0, 0, 0, 0, # 80 - 87422 0, 0, 0, 0, 0, 0, 0, 0, # 88 - 8f423 0, 0, 0, 0, 0, 0, 0, 0, # 90 - 97424 0, 0, 0, 0, 0, 0, 0, 0, # 98 - 9f425 0, 0, 0, 0, 0, 0, 0, 0, # a0 - a7426 0, 0, 0, 0, 0, 0, 0, 0, # a8 - af427 0, 0, 0, 0, 0, 0, 0, 0, # b0 - b7428 0, 0, 0, 0, 0, 0, 0, 0, # b8 - bf429 0, 0, 0, 0, 0, 0, 0, 0, # c0 - c7430 0, 0, 0, 0, 0, 0, 0, 0, # c8 - cf431 0, 0, 0, 0, 0, 0, 0, 0, # d0 - d7432 0, 0, 0, 0, 0, 0, 0, 0, # d8 - df433 0, 0, 0, 0, 0, 0, 0, 0, # e0 - e7434 0, 0, 0, 0, 0, 0, 0, 0, # e8 - ef435 0, 0, 0, 0, 0, 0, 0, 0, # f0 - f7436 0, 0, 0, 0, 0, 0, 4, 5, # f8 - ff437)438439UCS2LE_st = (440 6, 6, 7, 6, 4, 3, eError, eError, # 00-07441 eError, eError, eError, eError, eItsMe, eItsMe, eItsMe, eItsMe, # 08-0f442 eItsMe, eItsMe, 5, 5, 5, eError, eItsMe, eError, # 10-17443 5, 5, 5, eError, 5, eError, 6, 6, # 18-1f444 7, 6, 8, 8, 5, 5, 5, eError, # 20-27445 5, 5, 5, eError, eError, eError, 5, 5, # 28-2f446 5, 5, 5, eError, 5, eError, eStart, eStart, # 30-37447)448449UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)450451UCS2LESMModel = {'classTable': UCS2LE_cls,452 'classFactor': 6,453 'stateTable': UCS2LE_st,454 'charLenTable': UCS2LECharLenTable,455 'name': 'UTF-16LE'}456457# UTF-8458459UTF8_cls = (460 1, 1, 1, 1, 1, 1, 1, 1, # 00 - 07 #allow 0x00 as a legal value461 1, 1, 1, 1, 1, 1, 0, 0, # 08 - 0f462 1, 1, 1, 1, 1, 1, 1, 1, # 10 - 17463 1, 1, 1, 0, 1, 1, 1, 1, # 18 - 1f464 1, 1, 1, 1, 1, 1, 1, 1, # 20 - 27465 1, 1, 1, 1, 1, 1, 1, 1, # 28 - 2f466 1, 1, 1, 1, 1, 1, 1, 1, # 30 - 37467 1, 1, 1, 1, 1, 1, 1, 1, # 38 - 3f468 1, 1, 1, 1, 1, 1, 1, 1, # 40 - 47469 1, 1, 1, 1, 1, 1, 1, 1, # 48 - 4f470 1, 1, 1, 1, 1, 1, 1, 1, # 50 - 57471 1, 1, 1, 1, 1, 1, 1, 1, # 58 - 5f472 1, 1, 1, 1, 1, 1, 1, 1, # 60 - 67473 1, 1, 1, 1, 1, 1, 1, 1, # 68 - 6f474 1, 1, 1, 1, 1, 1, 1, 1, # 70 - 77475 1, 1, 1, 1, 1, 1, 1, 1, # 78 - 7f476 2, 2, 2, 2, 3, 3, 3, 3, # 80 - 87477 4, 4, 4, 4, 4, 4, 4, 4, # 88 - 8f478 4, 4, 4, 4, 4, 4, 4, 4, # 90 - 97479 4, 4, 4, 4, 4, 4, 4, 4, # 98 - 9f480 5, 5, 5, 5, 5, 5, 5, 5, # a0 - a7481 5, 5, 5, 5, 5, 5, 5, 5, # a8 - af482 5, 5, 5, 5, 5, 5, 5, 5, # b0 - b7483 5, 5, 5, 5, 5, 5, 5, 5, # b8 - bf484 0, 0, 6, 6, 6, 6, 6, 6, # c0 - c7485 6, 6, 6, 6, 6, 6, 6, 6, # c8 - cf486 6, 6, 6, 6, 6, 6, 6, 6, # d0 - d7487 6, 6, 6, 6, 6, 6, 6, 6, # d8 - df488 7, 8, 8, 8, 8, 8, 8, 8, # e0 - e7489 8, 8, 8, 8, 8, 9, 8, 8, # e8 - ef490 10, 11, 11, 11, 11, 11, 11, 11, # f0 - f7491 12, 13, 13, 13, 14, 15, 0, 0, # f8 - ff492)493494UTF8_st = (495 eError, eStart, eError, eError, eError, eError, 12, 10, # 00-07496 9, 11, 8, 7, 6, 5, 4, 3, # 08-0f497 eError, eError, eError, eError, eError, eError, eError, eError, # 10-17498 eError, eError, eError, eError, eError, eError, eError, eError, # 18-1f499 eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 20-27500 eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, eItsMe, # 28-2f501 eError, eError, 5, 5, 5, 5, eError, eError, # 30-37502 eError, eError, eError, eError, eError, eError, eError, eError, # 38-3f503 eError, eError, eError, 5, 5, 5, eError, eError, # 40-47504 eError, eError, eError, eError, eError, eError, eError, eError, # 48-4f505 eError, eError, 7, 7, 7, 7, eError, eError, # 50-57506 eError, eError, eError, eError, eError, eError, eError, eError, # 58-5f507 eError, eError, eError, eError, 7, 7, eError, eError, # 60-67508 eError, eError, eError, eError, eError, eError, eError, eError, # 68-6f509 eError, eError, 9, 9, 9, 9, eError, eError, # 70-77510 eError, eError, eError, eError, eError, eError, eError, eError, # 78-7f511 eError, eError, eError, eError, eError, 9, eError, eError, # 80-87512 eError, eError, eError, eError, eError, eError, eError, eError, # 88-8f513 eError, eError, 12, 12, 12, 12, eError, eError, # 90-97514 eError, eError, eError, eError, eError, eError, eError, eError, # 98-9f515 eError, eError, eError, eError, eError, 12, eError, eError, # a0-a7516 eError, eError, eError, eError, eError, eError, eError, eError, # a8-af517 eError, eError, 12, 12, 12, eError, eError, eError, # b0-b7518 eError, eError, eError, eError, eError, eError, eError, eError, # b8-bf519 eError, eError, eStart, eStart, eStart, eStart, eError, eError, # c0-c7520 eError, eError, eError, eError, eError, eError, eError, eError, # c8-cf521)522523UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)524525UTF8SMModel = {'classTable': UTF8_cls,526 'classFactor': 16,527 'stateTable': UTF8_st,528 'charLenTable': UTF8CharLenTable,529 'name': 'UTF-8'}1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from .constants import eStart, eError, eItsMe2930# BIG53132BIG5_cls = (33 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as legal value34 1,1,1,1,1,1,0,0, # 08 - 0f35 1,1,1,1,1,1,1,1, # 10 - 1736 1,1,1,0,1,1,1,1, # 18 - 1f37 1,1,1,1,1,1,1,1, # 20 - 2738 1,1,1,1,1,1,1,1, # 28 - 2f39 1,1,1,1,1,1,1,1, # 30 - 3740 1,1,1,1,1,1,1,1, # 38 - 3f41 2,2,2,2,2,2,2,2, # 40 - 4742 2,2,2,2,2,2,2,2, # 48 - 4f43 2,2,2,2,2,2,2,2, # 50 - 5744 2,2,2,2,2,2,2,2, # 58 - 5f45 2,2,2,2,2,2,2,2, # 60 - 6746 2,2,2,2,2,2,2,2, # 68 - 6f47 2,2,2,2,2,2,2,2, # 70 - 7748 2,2,2,2,2,2,2,1, # 78 - 7f49 4,4,4,4,4,4,4,4, # 80 - 8750 4,4,4,4,4,4,4,4, # 88 - 8f51 4,4,4,4,4,4,4,4, # 90 - 9752 4,4,4,4,4,4,4,4, # 98 - 9f53 4,3,3,3,3,3,3,3, # a0 - a754 3,3,3,3,3,3,3,3, # a8 - af55 3,3,3,3,3,3,3,3, # b0 - b756 3,3,3,3,3,3,3,3, # b8 - bf57 3,3,3,3,3,3,3,3, # c0 - c758 3,3,3,3,3,3,3,3, # c8 - cf59 3,3,3,3,3,3,3,3, # d0 - d760 3,3,3,3,3,3,3,3, # d8 - df61 3,3,3,3,3,3,3,3, # e0 - e762 3,3,3,3,3,3,3,3, # e8 - ef63 3,3,3,3,3,3,3,3, # f0 - f764 3,3,3,3,3,3,3,0 # f8 - ff65)6667BIG5_st = (68 eError,eStart,eStart, 3,eError,eError,eError,eError,#00-0769 eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,#08-0f70 eError,eStart,eStart,eStart,eStart,eStart,eStart,eStart#10-1771)7273Big5CharLenTable = (0, 1, 1, 2, 0)7475Big5SMModel = {'classTable': BIG5_cls,76 'classFactor': 5,77 'stateTable': BIG5_st,78 'charLenTable': Big5CharLenTable,79 'name': 'Big5'}8081# EUC-JP8283EUCJP_cls = (84 4,4,4,4,4,4,4,4, # 00 - 0785 4,4,4,4,4,4,5,5, # 08 - 0f86 4,4,4,4,4,4,4,4, # 10 - 1787 4,4,4,5,4,4,4,4, # 18 - 1f88 4,4,4,4,4,4,4,4, # 20 - 2789 4,4,4,4,4,4,4,4, # 28 - 2f90 4,4,4,4,4,4,4,4, # 30 - 3791 4,4,4,4,4,4,4,4, # 38 - 3f92 4,4,4,4,4,4,4,4, # 40 - 4793 4,4,4,4,4,4,4,4, # 48 - 4f94 4,4,4,4,4,4,4,4, # 50 - 5795 4,4,4,4,4,4,4,4, # 58 - 5f96 4,4,4,4,4,4,4,4, # 60 - 6797 4,4,4,4,4,4,4,4, # 68 - 6f98 4,4,4,4,4,4,4,4, # 70 - 7799 4,4,4,4,4,4,4,4, # 78 - 7f100 5,5,5,5,5,5,5,5, # 80 - 87101 5,5,5,5,5,5,1,3, # 88 - 8f102 5,5,5,5,5,5,5,5, # 90 - 97103 5,5,5,5,5,5,5,5, # 98 - 9f104 5,2,2,2,2,2,2,2, # a0 - a7105 2,2,2,2,2,2,2,2, # a8 - af106 2,2,2,2,2,2,2,2, # b0 - b7107 2,2,2,2,2,2,2,2, # b8 - bf108 2,2,2,2,2,2,2,2, # c0 - c7109 2,2,2,2,2,2,2,2, # c8 - cf110 2,2,2,2,2,2,2,2, # d0 - d7111 2,2,2,2,2,2,2,2, # d8 - df112 0,0,0,0,0,0,0,0, # e0 - e7113 0,0,0,0,0,0,0,0, # e8 - ef114 0,0,0,0,0,0,0,0, # f0 - f7115 0,0,0,0,0,0,0,5 # f8 - ff116)117118EUCJP_st = (119 3, 4, 3, 5,eStart,eError,eError,eError,#00-07120 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f121 eItsMe,eItsMe,eStart,eError,eStart,eError,eError,eError,#10-17122 eError,eError,eStart,eError,eError,eError, 3,eError,#18-1f123 3,eError,eError,eError,eStart,eStart,eStart,eStart#20-27124)125126EUCJPCharLenTable = (2, 2, 2, 3, 1, 0)127128EUCJPSMModel = {'classTable': EUCJP_cls,129 'classFactor': 6,130 'stateTable': EUCJP_st,131 'charLenTable': EUCJPCharLenTable,132 'name': 'EUC-JP'}133134# EUC-KR135136EUCKR_cls = (137 1,1,1,1,1,1,1,1, # 00 - 07138 1,1,1,1,1,1,0,0, # 08 - 0f139 1,1,1,1,1,1,1,1, # 10 - 17140 1,1,1,0,1,1,1,1, # 18 - 1f141 1,1,1,1,1,1,1,1, # 20 - 27142 1,1,1,1,1,1,1,1, # 28 - 2f143 1,1,1,1,1,1,1,1, # 30 - 37144 1,1,1,1,1,1,1,1, # 38 - 3f145 1,1,1,1,1,1,1,1, # 40 - 47146 1,1,1,1,1,1,1,1, # 48 - 4f147 1,1,1,1,1,1,1,1, # 50 - 57148 1,1,1,1,1,1,1,1, # 58 - 5f149 1,1,1,1,1,1,1,1, # 60 - 67150 1,1,1,1,1,1,1,1, # 68 - 6f151 1,1,1,1,1,1,1,1, # 70 - 77152 1,1,1,1,1,1,1,1, # 78 - 7f153 0,0,0,0,0,0,0,0, # 80 - 87154 0,0,0,0,0,0,0,0, # 88 - 8f155 0,0,0,0,0,0,0,0, # 90 - 97156 0,0,0,0,0,0,0,0, # 98 - 9f157 0,2,2,2,2,2,2,2, # a0 - a7158 2,2,2,2,2,3,3,3, # a8 - af159 2,2,2,2,2,2,2,2, # b0 - b7160 2,2,2,2,2,2,2,2, # b8 - bf161 2,2,2,2,2,2,2,2, # c0 - c7162 2,3,2,2,2,2,2,2, # c8 - cf163 2,2,2,2,2,2,2,2, # d0 - d7164 2,2,2,2,2,2,2,2, # d8 - df165 2,2,2,2,2,2,2,2, # e0 - e7166 2,2,2,2,2,2,2,2, # e8 - ef167 2,2,2,2,2,2,2,2, # f0 - f7168 2,2,2,2,2,2,2,0 # f8 - ff169)170171EUCKR_st = (172 eError,eStart, 3,eError,eError,eError,eError,eError,#00-07173 eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,eStart #08-0f174)175176EUCKRCharLenTable = (0, 1, 2, 0)177178EUCKRSMModel = {'classTable': EUCKR_cls,179 'classFactor': 4,180 'stateTable': EUCKR_st,181 'charLenTable': EUCKRCharLenTable,182 'name': 'EUC-KR'}183184# EUC-TW185186EUCTW_cls = (187 2,2,2,2,2,2,2,2, # 00 - 07188 2,2,2,2,2,2,0,0, # 08 - 0f189 2,2,2,2,2,2,2,2, # 10 - 17190 2,2,2,0,2,2,2,2, # 18 - 1f191 2,2,2,2,2,2,2,2, # 20 - 27192 2,2,2,2,2,2,2,2, # 28 - 2f193 2,2,2,2,2,2,2,2, # 30 - 37194 2,2,2,2,2,2,2,2, # 38 - 3f195 2,2,2,2,2,2,2,2, # 40 - 47196 2,2,2,2,2,2,2,2, # 48 - 4f197 2,2,2,2,2,2,2,2, # 50 - 57198 2,2,2,2,2,2,2,2, # 58 - 5f199 2,2,2,2,2,2,2,2, # 60 - 67200 2,2,2,2,2,2,2,2, # 68 - 6f201 2,2,2,2,2,2,2,2, # 70 - 77202 2,2,2,2,2,2,2,2, # 78 - 7f203 0,0,0,0,0,0,0,0, # 80 - 87204 0,0,0,0,0,0,6,0, # 88 - 8f205 0,0,0,0,0,0,0,0, # 90 - 97206 0,0,0,0,0,0,0,0, # 98 - 9f207 0,3,4,4,4,4,4,4, # a0 - a7208 5,5,1,1,1,1,1,1, # a8 - af209 1,1,1,1,1,1,1,1, # b0 - b7210 1,1,1,1,1,1,1,1, # b8 - bf211 1,1,3,1,3,3,3,3, # c0 - c7212 3,3,3,3,3,3,3,3, # c8 - cf213 3,3,3,3,3,3,3,3, # d0 - d7214 3,3,3,3,3,3,3,3, # d8 - df215 3,3,3,3,3,3,3,3, # e0 - e7216 3,3,3,3,3,3,3,3, # e8 - ef217 3,3,3,3,3,3,3,3, # f0 - f7218 3,3,3,3,3,3,3,0 # f8 - ff219)220221EUCTW_st = (222 eError,eError,eStart, 3, 3, 3, 4,eError,#00-07223 eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f224 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eStart,eError,#10-17225 eStart,eStart,eStart,eError,eError,eError,eError,eError,#18-1f226 5,eError,eError,eError,eStart,eError,eStart,eStart,#20-27227 eStart,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f228)229230EUCTWCharLenTable = (0, 0, 1, 2, 2, 2, 3)231232EUCTWSMModel = {'classTable': EUCTW_cls,233 'classFactor': 7,234 'stateTable': EUCTW_st,235 'charLenTable': EUCTWCharLenTable,236 'name': 'x-euc-tw'}237238# GB2312239240GB2312_cls = (241 1,1,1,1,1,1,1,1, # 00 - 07242 1,1,1,1,1,1,0,0, # 08 - 0f243 1,1,1,1,1,1,1,1, # 10 - 17244 1,1,1,0,1,1,1,1, # 18 - 1f245 1,1,1,1,1,1,1,1, # 20 - 27246 1,1,1,1,1,1,1,1, # 28 - 2f247 3,3,3,3,3,3,3,3, # 30 - 37248 3,3,1,1,1,1,1,1, # 38 - 3f249 2,2,2,2,2,2,2,2, # 40 - 47250 2,2,2,2,2,2,2,2, # 48 - 4f251 2,2,2,2,2,2,2,2, # 50 - 57252 2,2,2,2,2,2,2,2, # 58 - 5f253 2,2,2,2,2,2,2,2, # 60 - 67254 2,2,2,2,2,2,2,2, # 68 - 6f255 2,2,2,2,2,2,2,2, # 70 - 77256 2,2,2,2,2,2,2,4, # 78 - 7f257 5,6,6,6,6,6,6,6, # 80 - 87258 6,6,6,6,6,6,6,6, # 88 - 8f259 6,6,6,6,6,6,6,6, # 90 - 97260 6,6,6,6,6,6,6,6, # 98 - 9f261 6,6,6,6,6,6,6,6, # a0 - a7262 6,6,6,6,6,6,6,6, # a8 - af263 6,6,6,6,6,6,6,6, # b0 - b7264 6,6,6,6,6,6,6,6, # b8 - bf265 6,6,6,6,6,6,6,6, # c0 - c7266 6,6,6,6,6,6,6,6, # c8 - cf267 6,6,6,6,6,6,6,6, # d0 - d7268 6,6,6,6,6,6,6,6, # d8 - df269 6,6,6,6,6,6,6,6, # e0 - e7270 6,6,6,6,6,6,6,6, # e8 - ef271 6,6,6,6,6,6,6,6, # f0 - f7272 6,6,6,6,6,6,6,0 # f8 - ff273)274275GB2312_st = (276 eError,eStart,eStart,eStart,eStart,eStart, 3,eError,#00-07277 eError,eError,eError,eError,eError,eError,eItsMe,eItsMe,#08-0f278 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eError,eError,eStart,#10-17279 4,eError,eStart,eStart,eError,eError,eError,eError,#18-1f280 eError,eError, 5,eError,eError,eError,eItsMe,eError,#20-27281 eError,eError,eStart,eStart,eStart,eStart,eStart,eStart #28-2f282)283284# To be accurate, the length of class 6 can be either 2 or 4.285# But it is not necessary to discriminate between the two since286# it is used for frequency analysis only, and we are validing287# each code range there as well. So it is safe to set it to be288# 2 here.289GB2312CharLenTable = (0, 1, 1, 1, 1, 1, 2)290291GB2312SMModel = {'classTable': GB2312_cls,292 'classFactor': 7,293 'stateTable': GB2312_st,294 'charLenTable': GB2312CharLenTable,295 'name': 'GB2312'}296297# Shift_JIS298299SJIS_cls = (300 1,1,1,1,1,1,1,1, # 00 - 07301 1,1,1,1,1,1,0,0, # 08 - 0f302 1,1,1,1,1,1,1,1, # 10 - 17303 1,1,1,0,1,1,1,1, # 18 - 1f304 1,1,1,1,1,1,1,1, # 20 - 27305 1,1,1,1,1,1,1,1, # 28 - 2f306 1,1,1,1,1,1,1,1, # 30 - 37307 1,1,1,1,1,1,1,1, # 38 - 3f308 2,2,2,2,2,2,2,2, # 40 - 47309 2,2,2,2,2,2,2,2, # 48 - 4f310 2,2,2,2,2,2,2,2, # 50 - 57311 2,2,2,2,2,2,2,2, # 58 - 5f312 2,2,2,2,2,2,2,2, # 60 - 67313 2,2,2,2,2,2,2,2, # 68 - 6f314 2,2,2,2,2,2,2,2, # 70 - 77315 2,2,2,2,2,2,2,1, # 78 - 7f316 3,3,3,3,3,3,3,3, # 80 - 87317 3,3,3,3,3,3,3,3, # 88 - 8f318 3,3,3,3,3,3,3,3, # 90 - 97319 3,3,3,3,3,3,3,3, # 98 - 9f320 #0xa0 is illegal in sjis encoding, but some pages does321 #contain such byte. We need to be more error forgiven.322 2,2,2,2,2,2,2,2, # a0 - a7323 2,2,2,2,2,2,2,2, # a8 - af324 2,2,2,2,2,2,2,2, # b0 - b7325 2,2,2,2,2,2,2,2, # b8 - bf326 2,2,2,2,2,2,2,2, # c0 - c7327 2,2,2,2,2,2,2,2, # c8 - cf328 2,2,2,2,2,2,2,2, # d0 - d7329 2,2,2,2,2,2,2,2, # d8 - df330 3,3,3,3,3,3,3,3, # e0 - e7331 3,3,3,3,3,4,4,4, # e8 - ef332 4,4,4,4,4,4,4,4, # f0 - f7333 4,4,4,4,4,0,0,0 # f8 - ff334)335336337SJIS_st = (338 eError,eStart,eStart, 3,eError,eError,eError,eError,#00-07339 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f340 eItsMe,eItsMe,eError,eError,eStart,eStart,eStart,eStart #10-17341)342343SJISCharLenTable = (0, 1, 1, 2, 0, 0)344345SJISSMModel = {'classTable': SJIS_cls,346 'classFactor': 6,347 'stateTable': SJIS_st,348 'charLenTable': SJISCharLenTable,349 'name': 'Shift_JIS'}350351# UCS2-BE352353UCS2BE_cls = (354 0,0,0,0,0,0,0,0, # 00 - 07355 0,0,1,0,0,2,0,0, # 08 - 0f356 0,0,0,0,0,0,0,0, # 10 - 17357 0,0,0,3,0,0,0,0, # 18 - 1f358 0,0,0,0,0,0,0,0, # 20 - 27359 0,3,3,3,3,3,0,0, # 28 - 2f360 0,0,0,0,0,0,0,0, # 30 - 37361 0,0,0,0,0,0,0,0, # 38 - 3f362 0,0,0,0,0,0,0,0, # 40 - 47363 0,0,0,0,0,0,0,0, # 48 - 4f364 0,0,0,0,0,0,0,0, # 50 - 57365 0,0,0,0,0,0,0,0, # 58 - 5f366 0,0,0,0,0,0,0,0, # 60 - 67367 0,0,0,0,0,0,0,0, # 68 - 6f368 0,0,0,0,0,0,0,0, # 70 - 77369 0,0,0,0,0,0,0,0, # 78 - 7f370 0,0,0,0,0,0,0,0, # 80 - 87371 0,0,0,0,0,0,0,0, # 88 - 8f372 0,0,0,0,0,0,0,0, # 90 - 97373 0,0,0,0,0,0,0,0, # 98 - 9f374 0,0,0,0,0,0,0,0, # a0 - a7375 0,0,0,0,0,0,0,0, # a8 - af376 0,0,0,0,0,0,0,0, # b0 - b7377 0,0,0,0,0,0,0,0, # b8 - bf378 0,0,0,0,0,0,0,0, # c0 - c7379 0,0,0,0,0,0,0,0, # c8 - cf380 0,0,0,0,0,0,0,0, # d0 - d7381 0,0,0,0,0,0,0,0, # d8 - df382 0,0,0,0,0,0,0,0, # e0 - e7383 0,0,0,0,0,0,0,0, # e8 - ef384 0,0,0,0,0,0,0,0, # f0 - f7385 0,0,0,0,0,0,4,5 # f8 - ff386)387388UCS2BE_st = (389 5, 7, 7,eError, 4, 3,eError,eError,#00-07390 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f391 eItsMe,eItsMe, 6, 6, 6, 6,eError,eError,#10-17392 6, 6, 6, 6, 6,eItsMe, 6, 6,#18-1f393 6, 6, 6, 6, 5, 7, 7,eError,#20-27394 5, 8, 6, 6,eError, 6, 6, 6,#28-2f395 6, 6, 6, 6,eError,eError,eStart,eStart #30-37396)397398UCS2BECharLenTable = (2, 2, 2, 0, 2, 2)399400UCS2BESMModel = {'classTable': UCS2BE_cls,401 'classFactor': 6,402 'stateTable': UCS2BE_st,403 'charLenTable': UCS2BECharLenTable,404 'name': 'UTF-16BE'}405406# UCS2-LE407408UCS2LE_cls = (409 0,0,0,0,0,0,0,0, # 00 - 07410 0,0,1,0,0,2,0,0, # 08 - 0f411 0,0,0,0,0,0,0,0, # 10 - 17412 0,0,0,3,0,0,0,0, # 18 - 1f413 0,0,0,0,0,0,0,0, # 20 - 27414 0,3,3,3,3,3,0,0, # 28 - 2f415 0,0,0,0,0,0,0,0, # 30 - 37416 0,0,0,0,0,0,0,0, # 38 - 3f417 0,0,0,0,0,0,0,0, # 40 - 47418 0,0,0,0,0,0,0,0, # 48 - 4f419 0,0,0,0,0,0,0,0, # 50 - 57420 0,0,0,0,0,0,0,0, # 58 - 5f421 0,0,0,0,0,0,0,0, # 60 - 67422 0,0,0,0,0,0,0,0, # 68 - 6f423 0,0,0,0,0,0,0,0, # 70 - 77424 0,0,0,0,0,0,0,0, # 78 - 7f425 0,0,0,0,0,0,0,0, # 80 - 87426 0,0,0,0,0,0,0,0, # 88 - 8f427 0,0,0,0,0,0,0,0, # 90 - 97428 0,0,0,0,0,0,0,0, # 98 - 9f429 0,0,0,0,0,0,0,0, # a0 - a7430 0,0,0,0,0,0,0,0, # a8 - af431 0,0,0,0,0,0,0,0, # b0 - b7432 0,0,0,0,0,0,0,0, # b8 - bf433 0,0,0,0,0,0,0,0, # c0 - c7434 0,0,0,0,0,0,0,0, # c8 - cf435 0,0,0,0,0,0,0,0, # d0 - d7436 0,0,0,0,0,0,0,0, # d8 - df437 0,0,0,0,0,0,0,0, # e0 - e7438 0,0,0,0,0,0,0,0, # e8 - ef439 0,0,0,0,0,0,0,0, # f0 - f7440 0,0,0,0,0,0,4,5 # f8 - ff441)442443UCS2LE_st = (444 6, 6, 7, 6, 4, 3,eError,eError,#00-07445 eError,eError,eError,eError,eItsMe,eItsMe,eItsMe,eItsMe,#08-0f446 eItsMe,eItsMe, 5, 5, 5,eError,eItsMe,eError,#10-17447 5, 5, 5,eError, 5,eError, 6, 6,#18-1f448 7, 6, 8, 8, 5, 5, 5,eError,#20-27449 5, 5, 5,eError,eError,eError, 5, 5,#28-2f450 5, 5, 5,eError, 5,eError,eStart,eStart #30-37451)452453UCS2LECharLenTable = (2, 2, 2, 2, 2, 2)454455UCS2LESMModel = {'classTable': UCS2LE_cls,456 'classFactor': 6,457 'stateTable': UCS2LE_st,458 'charLenTable': UCS2LECharLenTable,459 'name': 'UTF-16LE'}460461# UTF-8462463UTF8_cls = (464 1,1,1,1,1,1,1,1, # 00 - 07 #allow 0x00 as a legal value465 1,1,1,1,1,1,0,0, # 08 - 0f466 1,1,1,1,1,1,1,1, # 10 - 17467 1,1,1,0,1,1,1,1, # 18 - 1f468 1,1,1,1,1,1,1,1, # 20 - 27469 1,1,1,1,1,1,1,1, # 28 - 2f470 1,1,1,1,1,1,1,1, # 30 - 37471 1,1,1,1,1,1,1,1, # 38 - 3f472 1,1,1,1,1,1,1,1, # 40 - 47473 1,1,1,1,1,1,1,1, # 48 - 4f474 1,1,1,1,1,1,1,1, # 50 - 57475 1,1,1,1,1,1,1,1, # 58 - 5f476 1,1,1,1,1,1,1,1, # 60 - 67477 1,1,1,1,1,1,1,1, # 68 - 6f478 1,1,1,1,1,1,1,1, # 70 - 77479 1,1,1,1,1,1,1,1, # 78 - 7f480 2,2,2,2,3,3,3,3, # 80 - 87481 4,4,4,4,4,4,4,4, # 88 - 8f482 4,4,4,4,4,4,4,4, # 90 - 97483 4,4,4,4,4,4,4,4, # 98 - 9f484 5,5,5,5,5,5,5,5, # a0 - a7485 5,5,5,5,5,5,5,5, # a8 - af486 5,5,5,5,5,5,5,5, # b0 - b7487 5,5,5,5,5,5,5,5, # b8 - bf488 0,0,6,6,6,6,6,6, # c0 - c7489 6,6,6,6,6,6,6,6, # c8 - cf490 6,6,6,6,6,6,6,6, # d0 - d7491 6,6,6,6,6,6,6,6, # d8 - df492 7,8,8,8,8,8,8,8, # e0 - e7493 8,8,8,8,8,9,8,8, # e8 - ef494 10,11,11,11,11,11,11,11, # f0 - f7495 12,13,13,13,14,15,0,0 # f8 - ff496)497498UTF8_st = (499 eError,eStart,eError,eError,eError,eError, 12, 10,#00-07500 9, 11, 8, 7, 6, 5, 4, 3,#08-0f501 eError,eError,eError,eError,eError,eError,eError,eError,#10-17502 eError,eError,eError,eError,eError,eError,eError,eError,#18-1f503 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#20-27504 eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,eItsMe,#28-2f505 eError,eError, 5, 5, 5, 5,eError,eError,#30-37506 eError,eError,eError,eError,eError,eError,eError,eError,#38-3f507 eError,eError,eError, 5, 5, 5,eError,eError,#40-47508 eError,eError,eError,eError,eError,eError,eError,eError,#48-4f509 eError,eError, 7, 7, 7, 7,eError,eError,#50-57510 eError,eError,eError,eError,eError,eError,eError,eError,#58-5f511 eError,eError,eError,eError, 7, 7,eError,eError,#60-67512 eError,eError,eError,eError,eError,eError,eError,eError,#68-6f513 eError,eError, 9, 9, 9, 9,eError,eError,#70-77514 eError,eError,eError,eError,eError,eError,eError,eError,#78-7f515 eError,eError,eError,eError,eError, 9,eError,eError,#80-87516 eError,eError,eError,eError,eError,eError,eError,eError,#88-8f517 eError,eError, 12, 12, 12, 12,eError,eError,#90-97518 eError,eError,eError,eError,eError,eError,eError,eError,#98-9f519 eError,eError,eError,eError,eError, 12,eError,eError,#a0-a7520 eError,eError,eError,eError,eError,eError,eError,eError,#a8-af521 eError,eError, 12, 12, 12,eError,eError,eError,#b0-b7522 eError,eError,eError,eError,eError,eError,eError,eError,#b8-bf523 eError,eError,eStart,eStart,eStart,eStart,eError,eError,#c0-c7524 eError,eError,eError,eError,eError,eError,eError,eError #c8-cf525)526527UTF8CharLenTable = (0, 1, 0, 0, 0, 0, 2, 3, 3, 3, 4, 4, 5, 5, 6, 6)528529UTF8SMModel = {'classTable': UTF8_cls,530 'classFactor': 16,531 'stateTable': UTF8_st,532 'charLenTable': UTF8CharLenTable,533 'name': 'UTF-8'}534535# flake8: noqa
modified:requests/packages/charade/sbcharsetprober.py+120 added-124 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829import sys30from . import constants31from .charsetprober import CharSetProber32from .compat import wrap_ord3334SAMPLE_SIZE = 6435SB_ENOUGH_REL_THRESHOLD = 102436POSITIVE_SHORTCUT_THRESHOLD = 0.9537NEGATIVE_SHORTCUT_THRESHOLD = 0.0538SYMBOL_CAT_ORDER = 25039NUMBER_OF_SEQ_CAT = 440POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 141#NEGATIVE_CAT = 0424344class SingleByteCharSetProber(CharSetProber):45 def __init__(self, model, reversed=False, nameProber=None):46 CharSetProber.__init__(self)47 self._mModel = model48 # TRUE if we need to reverse every pair in the model lookup49 self._mReversed = reversed50 # Optional auxiliary prober for name decision51 self._mNameProber = nameProber52 self.reset()5354 def reset(self):55 CharSetProber.reset(self)56 self._mLastOrder = 255 # char order of last character57 self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT58 self._mTotalSeqs = 059 self._mTotalChar = 060 self._mFreqChar = 0 # characters that fall in our sampling range6162 def get_charset_name(self):63 if self._mNameProber:64 return self._mNameProber.get_charset_name()65 else:66 return self._mModel['charsetName']6768 def feed(self, aBuf):69 if not self._mModel['keepEnglishLetter']:70 aBuf = self.filter_without_english_letters(aBuf)71 aLen = len(aBuf)72 if not aLen:73 return self.get_state()74 for c in aBuf:75 try:76 order = self._mModel['charToOrderMap'][wrap_ord(c)]77 except IndexError:78 return constants.eError79 if order < SYMBOL_CAT_ORDER:80 self._mTotalChar += 181 if order < SAMPLE_SIZE:82 self._mFreqChar += 183 if self._mLastOrder < SAMPLE_SIZE:84 self._mTotalSeqs += 185 if not self._mReversed:86 i = (self._mLastOrder * SAMPLE_SIZE) + order87 else: # reverse the order of the letters in the lookup88 i = (order * SAMPLE_SIZE) + self._mLastOrder89 model = self._mModel['precedenceMatrix'][i]90 self._mSeqCounters[model] += 191 self._mLastOrder = order9293 if self.get_state() == constants.eDetecting:94 if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:95 cf = self.get_confidence()96 if cf > POSITIVE_SHORTCUT_THRESHOLD:97 if constants._debug:98 sys.stderr.write('%s confidence = %s, we have a'99 ' winner\n' %100 (self._mModel['charsetName'],101 cf))102 self._mState = constants.eFoundIt103 elif cf < NEGATIVE_SHORTCUT_THRESHOLD:104 if constants._debug:105 sys.stderr.write('%s confidence = %s, below negative'106 ' shortcut threshhold %s\n' %107 (self._mModel['charsetName'], cf,108 NEGATIVE_SHORTCUT_THRESHOLD))109 self._mState = constants.eNotMe110111 return self.get_state()112113 def get_confidence(self):114 r = 0.01115 if self._mTotalSeqs > 0:116 #print(self._mSeqCounters[POSITIVE_CAT], self._mTotalSeqs,117 # self._mModel['mTypicalPositiveRatio'])118 r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs119 / self._mModel['mTypicalPositiveRatio'])120 #print(r, self._mFreqChar, self._mTotalChar)121 r = r * self._mFreqChar / self._mTotalChar122 if r >= 1.0:123 r = 0.99124 return r1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829import sys30from . import constants31from .charsetprober import CharSetProber32from .compat import wrap_ord3334SAMPLE_SIZE = 6435SB_ENOUGH_REL_THRESHOLD = 102436POSITIVE_SHORTCUT_THRESHOLD = 0.9537NEGATIVE_SHORTCUT_THRESHOLD = 0.0538SYMBOL_CAT_ORDER = 25039NUMBER_OF_SEQ_CAT = 440POSITIVE_CAT = NUMBER_OF_SEQ_CAT - 141#NEGATIVE_CAT = 0424344class SingleByteCharSetProber(CharSetProber):45 def __init__(self, model, reversed=False, nameProber=None):46 CharSetProber.__init__(self)47 self._mModel = model48 # TRUE if we need to reverse every pair in the model lookup49 self._mReversed = reversed50 # Optional auxiliary prober for name decision51 self._mNameProber = nameProber52 self.reset()5354 def reset(self):55 CharSetProber.reset(self)56 # char order of last character57 self._mLastOrder = 25558 self._mSeqCounters = [0] * NUMBER_OF_SEQ_CAT59 self._mTotalSeqs = 060 self._mTotalChar = 061 # characters that fall in our sampling range62 self._mFreqChar = 06364 def get_charset_name(self):65 if self._mNameProber:66 return self._mNameProber.get_charset_name()67 else:68 return self._mModel['charsetName']6970 def feed(self, aBuf):71 if not self._mModel['keepEnglishLetter']:72 aBuf = self.filter_without_english_letters(aBuf)73 aLen = len(aBuf)74 if not aLen:75 return self.get_state()76 for c in aBuf:77 order = self._mModel['charToOrderMap'][wrap_ord(c)]78 if order < SYMBOL_CAT_ORDER:79 self._mTotalChar += 180 if order < SAMPLE_SIZE:81 self._mFreqChar += 182 if self._mLastOrder < SAMPLE_SIZE:83 self._mTotalSeqs += 184 if not self._mReversed:85 i = (self._mLastOrder * SAMPLE_SIZE) + order86 model = self._mModel['precedenceMatrix'][i]87 else: # reverse the order of the letters in the lookup88 i = (order * SAMPLE_SIZE) + self._mLastOrder89 model = self._mModel['precedenceMatrix'][i]90 self._mSeqCounters[model] += 191 self._mLastOrder = order9293 if self.get_state() == constants.eDetecting:94 if self._mTotalSeqs > SB_ENOUGH_REL_THRESHOLD:95 cf = self.get_confidence()96 if cf > POSITIVE_SHORTCUT_THRESHOLD:97 if constants._debug:98 sys.stderr.write('%s confidence = %s, we have a'99 'winner\n' %100 (self._mModel['charsetName'], cf))101 self._mState = constants.eFoundIt102 elif cf < NEGATIVE_SHORTCUT_THRESHOLD:103 if constants._debug:104 sys.stderr.write('%s confidence = %s, below negative'105 'shortcut threshhold %s\n' %106 (self._mModel['charsetName'], cf,107 NEGATIVE_SHORTCUT_THRESHOLD))108 self._mState = constants.eNotMe109110 return self.get_state()111112 def get_confidence(self):113 r = 0.01114 if self._mTotalSeqs > 0:115 r = ((1.0 * self._mSeqCounters[POSITIVE_CAT]) / self._mTotalSeqs116 / self._mModel['mTypicalPositiveRatio'])117 r = r * self._mFreqChar / self._mTotalChar118 if r >= 1.0:119 r = 0.99120 return r
modified:requests/packages/charade/sbcsgroupprober.py+69 added-69 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829from .charsetgroupprober import CharSetGroupProber30from .sbcharsetprober import SingleByteCharSetProber31from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,32 Latin5CyrillicModel, MacCyrillicModel,33 Ibm866Model, Ibm855Model)34from .langgreekmodel import Latin7GreekModel, Win1253GreekModel35from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel36from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel37from .langthaimodel import TIS620ThaiModel38from .langhebrewmodel import Win1255HebrewModel39from .hebrewprober import HebrewProber404142class SBCSGroupProber(CharSetGroupProber):43 def __init__(self):44 CharSetGroupProber.__init__(self)45 self._mProbers = [46 SingleByteCharSetProber(Win1251CyrillicModel),47 SingleByteCharSetProber(Koi8rModel),48 SingleByteCharSetProber(Latin5CyrillicModel),49 SingleByteCharSetProber(MacCyrillicModel),50 SingleByteCharSetProber(Ibm866Model),51 SingleByteCharSetProber(Ibm855Model),52 SingleByteCharSetProber(Latin7GreekModel),53 SingleByteCharSetProber(Win1253GreekModel),54 SingleByteCharSetProber(Latin5BulgarianModel),55 SingleByteCharSetProber(Win1251BulgarianModel),56 SingleByteCharSetProber(Latin2HungarianModel),57 SingleByteCharSetProber(Win1250HungarianModel),58 SingleByteCharSetProber(TIS620ThaiModel),59 ]60 hebrewProber = HebrewProber()61 logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,62 False, hebrewProber)63 visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,64 hebrewProber)65 hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)66 self._mProbers.extend([hebrewProber, logicalHebrewProber,67 visualHebrewProber])6869 self.reset()1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829from .charsetgroupprober import CharSetGroupProber30from .sbcharsetprober import SingleByteCharSetProber31from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,32 Latin5CyrillicModel, MacCyrillicModel,33 Ibm866Model, Ibm855Model)34from .langgreekmodel import Latin7GreekModel, Win1253GreekModel35from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel36from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel37from .langthaimodel import TIS620ThaiModel38from .langhebrewmodel import Win1255HebrewModel39from .hebrewprober import HebrewProber404142class SBCSGroupProber(CharSetGroupProber):43 def __init__(self):44 CharSetGroupProber.__init__(self)45 self._mProbers = [46 SingleByteCharSetProber(Win1251CyrillicModel),47 SingleByteCharSetProber(Koi8rModel),48 SingleByteCharSetProber(Latin5CyrillicModel),49 SingleByteCharSetProber(MacCyrillicModel),50 SingleByteCharSetProber(Ibm866Model),51 SingleByteCharSetProber(Ibm855Model),52 SingleByteCharSetProber(Latin7GreekModel),53 SingleByteCharSetProber(Win1253GreekModel),54 SingleByteCharSetProber(Latin5BulgarianModel),55 SingleByteCharSetProber(Win1251BulgarianModel),56 SingleByteCharSetProber(Latin2HungarianModel),57 SingleByteCharSetProber(Win1250HungarianModel),58 SingleByteCharSetProber(TIS620ThaiModel),59 ]60 hebrewProber = HebrewProber()61 logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,62 False, hebrewProber)63 visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,64 hebrewProber)65 hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)66 self._mProbers.extend([hebrewProber, logicalHebrewProber,67 visualHebrewProber])6869 self.reset()
modified:requests/packages/charade/sjisprober.py+91 added-90 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728import sys29from .mbcharsetprober import MultiByteCharSetProber30from .codingstatemachine import CodingStateMachine31from .chardistribution import SJISDistributionAnalysis32from .jpcntx import SJISContextAnalysis33from .mbcssm import SJISSMModel34from . import constants353637class SJISProber(MultiByteCharSetProber):38 def __init__(self):39 MultiByteCharSetProber.__init__(self)40 self._mCodingSM = CodingStateMachine(SJISSMModel)41 self._mDistributionAnalyzer = SJISDistributionAnalysis()42 self._mContextAnalyzer = SJISContextAnalysis()43 self.reset()4445 def reset(self):46 MultiByteCharSetProber.reset(self)47 self._mContextAnalyzer.reset()4849 def get_charset_name(self):50 return "SHIFT_JIS"5152 def feed(self, aBuf):53 aLen = len(aBuf)54 for i in range(0, aLen):55 codingState = self._mCodingSM.next_state(aBuf[i])56 if codingState == constants.eError:57 if constants._debug:58 sys.stderr.write(self.get_charset_name() + ' prober hit'59 'error at byte ' + str(i) + '\n')60 self._mState = constants.eNotMe61 break62 elif codingState == constants.eItsMe:63 self._mState = constants.eFoundIt64 break65 elif codingState == constants.eStart:66 charLen = self._mCodingSM.get_current_charlen()67 if i == 0:68 self._mLastChar[1] = aBuf[0]69 self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],70 charLen)71 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)72 else:73 self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 3 -74 charLen], charLen)75 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],76 charLen)7778 self._mLastChar[0] = aBuf[aLen - 1]7980 if self.get_state() == constants.eDetecting:81 if (self._mContextAnalyzer.got_enough_data() and82 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):83 self._mState = constants.eFoundIt8485 return self.get_state()8687 def get_confidence(self):88 contxtCf = self._mContextAnalyzer.get_confidence()89 distribCf = self._mDistributionAnalyzer.get_confidence()90 return max(contxtCf, distribCf)1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728import sys29from .mbcharsetprober import MultiByteCharSetProber30from .codingstatemachine import CodingStateMachine31from .chardistribution import SJISDistributionAnalysis32from .jpcntx import SJISContextAnalysis33from .mbcssm import SJISSMModel34from . import constants353637class SJISProber(MultiByteCharSetProber):38 def __init__(self):39 MultiByteCharSetProber.__init__(self)40 self._mCodingSM = CodingStateMachine(SJISSMModel)41 self._mDistributionAnalyzer = SJISDistributionAnalysis()42 self._mContextAnalyzer = SJISContextAnalysis()43 self.reset()4445 def reset(self):46 MultiByteCharSetProber.reset(self)47 self._mContextAnalyzer.reset()4849 def get_charset_name(self):50 return "SHIFT_JIS"5152 def feed(self, aBuf):53 aLen = len(aBuf)54 for i in range(0, aLen):55 codingState = self._mCodingSM.next_state(aBuf[i])56 if codingState == constants.eError:57 if constants._debug:58 sys.stderr.write(self.get_charset_name()59 + ' prober hit error at byte ' + str(i)60 + '\n')61 self._mState = constants.eNotMe62 break63 elif codingState == constants.eItsMe:64 self._mState = constants.eFoundIt65 break66 elif codingState == constants.eStart:67 charLen = self._mCodingSM.get_current_charlen()68 if i == 0:69 self._mLastChar[1] = aBuf[0]70 self._mContextAnalyzer.feed(self._mLastChar[2 - charLen:],71 charLen)72 self._mDistributionAnalyzer.feed(self._mLastChar, charLen)73 else:74 self._mContextAnalyzer.feed(aBuf[i + 1 - charLen:i + 375 - charLen], charLen)76 self._mDistributionAnalyzer.feed(aBuf[i - 1:i + 1],77 charLen)7879 self._mLastChar[0] = aBuf[aLen - 1]8081 if self.get_state() == constants.eDetecting:82 if (self._mContextAnalyzer.got_enough_data() and83 (self.get_confidence() > constants.SHORTCUT_THRESHOLD)):84 self._mState = constants.eFoundIt8586 return self.get_state()8788 def get_confidence(self):89 contxtCf = self._mContextAnalyzer.get_confidence()90 distribCf = self._mDistributionAnalyzer.get_confidence()91 return max(contxtCf, distribCf)
modified:requests/packages/charade/universaldetector.py+171 added-173 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829import sys30from . import constants31from .latin1prober import Latin1Prober # windows-125232from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets33from .sbcsgroupprober import SBCSGroupProber # single-byte character sets34from .escprober import EscCharSetProber # ISO-2122, etc.35import re36import logging3738logger = logging.getLogger(__name__)3940MINIMUM_THRESHOLD = 0.2041ePureAscii = 042eEscAscii = 143eHighbyte = 2444546class UniversalDetector:47 def __init__(self):48 self._highBitDetector = re.compile(b'[\x80-\xFF]')49 self._escDetector = re.compile(b'(\033|~{)')50 self._mEscCharSetProber = None51 self._mCharSetProbers = []52 self.reset()5354 def reset(self):55 self.result = {'encoding': None, 'confidence': 0.0}56 self.done = False57 self._mStart = True58 self._mGotData = False59 self._mInputState = ePureAscii60 self._mLastChar = b''61 if self._mEscCharSetProber:62 self._mEscCharSetProber.reset()63 for prober in self._mCharSetProbers:64 prober.reset()6566 def feed(self, aBuf):67 if self.done:68 return6970 charmap = (71 # EF BB BF UTF-8 with BOM72 ('\xEF\xBB\xBF', {'encoding': "UTF-8", 'confidence': 1.0}),73 # FF FE 00 00 UTF-32, little-endian BOM74 ('\xFF\xFE\x00\x00', {'encoding': "UTF-32LE", 'confidence': 1.0}),75 # 00 00 FE FF UTF-32, big-endian BOM76 ('\x00\x00\xFE\xFF', {'encoding': "UTF-32BE", 'confidence': 1.0}),77 # FE FF 00 00 UCS-4, unusual octet order BOM (3412)78 ('\xFE\xFF\x00\x00', {'encoding': "X-ISO-10646-UCS-4-3412",79 'confidence': 1.0}),80 # 00 00 FF FE UCS-4, unusual octet order BOM (2143)81 ('\x00\x00\xFF\xFE', {'encoding': "X-ISO-10646-UCS-4-2143",82 'confidence': 1.0}),83 # FF FE UTF-16, little endian BOM84 ('\xFF\xFE', {'encoding': "UTF-16LE", 'confidence': 1.0}),85 # FE FF UTF-16, big endian BOM86 ('\xFE\xFF', {'encoding': "UTF-16BE", 'confidence': 1.0}),87 )8889 aLen = len(aBuf)90 if not aLen:91 return9293 if not self._mGotData:94 # If the data starts with BOM, we know it is UTF95 for chunk, result in charmap:96 if aBuf[:len(chunk)] == chunk:97 self.result = result98 break99100 self._mGotData = True101 if self.result['encoding'] and (self.result['confidence'] > 0.0):102 self.done = True103 return104105 if self._mInputState == ePureAscii:106 if self._highBitDetector.search(aBuf):107 self._mInputState = eHighbyte108 elif ((self._mInputState == ePureAscii) and109 self._escDetector.search(self._mLastChar + aBuf)):110 self._mInputState = eEscAscii111112 self._mLastChar = aBuf[-1:]113114 if self._mInputState == eEscAscii:115 if not self._mEscCharSetProber:116 self._mEscCharSetProber = EscCharSetProber()117 if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:118 self.result = {119 'encoding': self._mEscCharSetProber.get_charset_name(),120 'confidence': self._mEscCharSetProber.get_confidence(),121 }122 self.done = True123 elif self._mInputState == eHighbyte:124 if not self._mCharSetProbers:125 self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),126 Latin1Prober()]127 for prober in self._mCharSetProbers:128 try:129 if prober.feed(aBuf) == constants.eFoundIt:130 self.result = {'encoding': prober.get_charset_name(),131 'confidence': prober.get_confidence()}132 self.done = True133 break134 except (UnicodeDecodeError, UnicodeEncodeError) as e:135 logger.exception(e)136137 def close(self):138 if self.done:139 return140 if not self._mGotData:141 if constants._debug:142 sys.stderr.write('no data received!\n')143 return144 self.done = True145146 if self._mInputState == ePureAscii:147 self.result = {'encoding': 'ascii', 'confidence': 1.0}148 return self.result149150 if self._mInputState == eHighbyte:151 proberConfidence = None152 maxProberConfidence = 0.0153 maxProber = None154 for prober in self._mCharSetProbers:155 if not prober:156 continue157 proberConfidence = prober.get_confidence()158 if proberConfidence > maxProberConfidence:159 maxProberConfidence = proberConfidence160 maxProber = prober161 if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):162 self.result = {'encoding': maxProber.get_charset_name(),163 'confidence': maxProber.get_confidence()}164 return self.result165166 if constants._debug:167 sys.stderr.write('no probers hit minimum threshhold\n')168 for prober in self._mCharSetProbers[0].mProbers:169 if not prober:170 continue171 sys.stderr.write('%s confidence = %s\n' %172 (prober.get_charset_name(),173 prober.get_confidence()))1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is Mozilla Universal charset detector code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 20017# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11# Shy Shalom - original C code12#13# This library is free software; you can redistribute it and/or14# modify it under the terms of the GNU Lesser General Public15# License as published by the Free Software Foundation; either16# version 2.1 of the License, or (at your option) any later version.17#18# This library is distributed in the hope that it will be useful,19# but WITHOUT ANY WARRANTY; without even the implied warranty of20# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU21# Lesser General Public License for more details.22#23# You should have received a copy of the GNU Lesser General Public24# License along with this library; if not, write to the Free Software25# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA26# 02110-1301 USA27######################### END LICENSE BLOCK #########################2829from . import constants30import sys31from .latin1prober import Latin1Prober # windows-125232from .mbcsgroupprober import MBCSGroupProber # multi-byte character sets33from .sbcsgroupprober import SBCSGroupProber # single-byte character sets34from .escprober import EscCharSetProber # ISO-2122, etc.35import re3637MINIMUM_THRESHOLD = 0.2038ePureAscii = 039eEscAscii = 140eHighbyte = 2414243class UniversalDetector:44 def __init__(self):45 self._highBitDetector = re.compile(b'[\x80-\xFF]')46 self._escDetector = re.compile(b'(\033|~{)')47 self._mEscCharSetProber = None48 self._mCharSetProbers = []49 self.reset()5051 def reset(self):52 self.result = {'encoding': None, 'confidence': 0.0}53 self.done = False54 self._mStart = True55 self._mGotData = False56 self._mInputState = ePureAscii57 self._mLastChar = b''58 if self._mEscCharSetProber:59 self._mEscCharSetProber.reset()60 for prober in self._mCharSetProbers:61 prober.reset()6263 def feed(self, aBuf):64 if self.done:65 return6667 aLen = len(aBuf)68 if not aLen:69 return7071 if not self._mGotData:72 # If the data starts with BOM, we know it is UTF73 if aBuf[:3] == '\xEF\xBB\xBF':74 # EF BB BF UTF-8 with BOM75 self.result = {'encoding': "UTF-8", 'confidence': 1.0}76 elif aBuf[:4] == '\xFF\xFE\x00\x00':77 # FF FE 00 00 UTF-32, little-endian BOM78 self.result = {'encoding': "UTF-32LE", 'confidence': 1.0}79 elif aBuf[:4] == '\x00\x00\xFE\xFF':80 # 00 00 FE FF UTF-32, big-endian BOM81 self.result = {'encoding': "UTF-32BE", 'confidence': 1.0}82 elif aBuf[:4] == '\xFE\xFF\x00\x00':83 # FE FF 00 00 UCS-4, unusual octet order BOM (3412)84 self.result = {85 'encoding': "X-ISO-10646-UCS-4-3412",86 'confidence': 1.087 }88 elif aBuf[:4] == '\x00\x00\xFF\xFE':89 # 00 00 FF FE UCS-4, unusual octet order BOM (2143)90 self.result = {91 'encoding': "X-ISO-10646-UCS-4-2143",92 'confidence': 1.093 }94 elif aBuf[:2] == '\xFF\xFE':95 # FF FE UTF-16, little endian BOM96 self.result = {'encoding': "UTF-16LE", 'confidence': 1.0}97 elif aBuf[:2] == '\xFE\xFF':98 # FE FF UTF-16, big endian BOM99 self.result = {'encoding': "UTF-16BE", 'confidence': 1.0}100101 self._mGotData = True102 if self.result['encoding'] and (self.result['confidence'] > 0.0):103 self.done = True104 return105106 if self._mInputState == ePureAscii:107 if self._highBitDetector.search(aBuf):108 self._mInputState = eHighbyte109 elif ((self._mInputState == ePureAscii) and110 self._escDetector.search(self._mLastChar + aBuf)):111 self._mInputState = eEscAscii112113 self._mLastChar = aBuf[-1:]114115 if self._mInputState == eEscAscii:116 if not self._mEscCharSetProber:117 self._mEscCharSetProber = EscCharSetProber()118 if self._mEscCharSetProber.feed(aBuf) == constants.eFoundIt:119 self.result = {120 'encoding': self._mEscCharSetProber.get_charset_name(),121 'confidence': self._mEscCharSetProber.get_confidence()122 }123 self.done = True124 elif self._mInputState == eHighbyte:125 if not self._mCharSetProbers:126 self._mCharSetProbers = [MBCSGroupProber(), SBCSGroupProber(),127 Latin1Prober()]128 for prober in self._mCharSetProbers:129 if prober.feed(aBuf) == constants.eFoundIt:130 self.result = {'encoding': prober.get_charset_name(),131 'confidence': prober.get_confidence()}132 self.done = True133 break134135 def close(self):136 if self.done:137 return138 if not self._mGotData:139 if constants._debug:140 sys.stderr.write('no data received!\n')141 return142 self.done = True143144 if self._mInputState == ePureAscii:145 self.result = {'encoding': 'ascii', 'confidence': 1.0}146 return self.result147148 if self._mInputState == eHighbyte:149 proberConfidence = None150 maxProberConfidence = 0.0151 maxProber = None152 for prober in self._mCharSetProbers:153 if not prober:154 continue155 proberConfidence = prober.get_confidence()156 if proberConfidence > maxProberConfidence:157 maxProberConfidence = proberConfidence158 maxProber = prober159 if maxProber and (maxProberConfidence > MINIMUM_THRESHOLD):160 self.result = {'encoding': maxProber.get_charset_name(),161 'confidence': maxProber.get_confidence()}162 return self.result163164 if constants._debug:165 sys.stderr.write('no probers hit minimum threshhold\n')166 for prober in self._mCharSetProbers[0].mProbers:167 if not prober:168 continue169 sys.stderr.write('%s confidence = %s\n' %170 (prober.get_charset_name(),171 prober.get_confidence()))
modified:requests/packages/charade/utf8prober.py+76 added-76 removed
1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants29from .charsetprober import CharSetProber30from .codingstatemachine import CodingStateMachine31from .mbcssm import UTF8SMModel3233ONE_CHAR_PROB = 0.5343536class UTF8Prober(CharSetProber):37 def __init__(self):38 CharSetProber.__init__(self)39 self._mCodingSM = CodingStateMachine(UTF8SMModel)40 self.reset()4142 def reset(self):43 CharSetProber.reset(self)44 self._mCodingSM.reset()45 self._mNumOfMBChar = 04647 def get_charset_name(self):48 return "utf-8"4950 def feed(self, aBuf):51 for c in aBuf:52 codingState = self._mCodingSM.next_state(c)53 if codingState == constants.eError:54 self._mState = constants.eNotMe55 break56 elif codingState == constants.eItsMe:57 self._mState = constants.eFoundIt58 break59 elif codingState == constants.eStart:60 if self._mCodingSM.get_current_charlen() >= 2:61 self._mNumOfMBChar += 16263 if self.get_state() == constants.eDetecting:64 if self.get_confidence() > constants.SHORTCUT_THRESHOLD:65 self._mState = constants.eFoundIt6667 return self.get_state()6869 def get_confidence(self):70 unlike = 0.9971 if self._mNumOfMBChar < 6:72 for i in range(0, self._mNumOfMBChar):73 unlike = unlike * ONE_CHAR_PROB74 return 1.0 - unlike75 else:76 return unlike1######################## BEGIN LICENSE BLOCK ########################2# The Original Code is mozilla.org code.3#4# The Initial Developer of the Original Code is5# Netscape Communications Corporation.6# Portions created by the Initial Developer are Copyright (C) 19987# the Initial Developer. All Rights Reserved.8#9# Contributor(s):10# Mark Pilgrim - port to Python11#12# This library is free software; you can redistribute it and/or13# modify it under the terms of the GNU Lesser General Public14# License as published by the Free Software Foundation; either15# version 2.1 of the License, or (at your option) any later version.16#17# This library is distributed in the hope that it will be useful,18# but WITHOUT ANY WARRANTY; without even the implied warranty of19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU20# Lesser General Public License for more details.21#22# You should have received a copy of the GNU Lesser General Public23# License along with this library; if not, write to the Free Software24# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA25# 02110-1301 USA26######################### END LICENSE BLOCK #########################2728from . import constants29from .charsetprober import CharSetProber30from .codingstatemachine import CodingStateMachine31from .mbcssm import UTF8SMModel3233ONE_CHAR_PROB = 0.5343536class UTF8Prober(CharSetProber):37 def __init__(self):38 CharSetProber.__init__(self)39 self._mCodingSM = CodingStateMachine(UTF8SMModel)40 self.reset()4142 def reset(self):43 CharSetProber.reset(self)44 self._mCodingSM.reset()45 self._mNumOfMBChar = 04647 def get_charset_name(self):48 return "utf-8"4950 def feed(self, aBuf):51 for c in aBuf:52 codingState = self._mCodingSM.next_state(c)53 if codingState == constants.eError:54 self._mState = constants.eNotMe55 break56 elif codingState == constants.eItsMe:57 self._mState = constants.eFoundIt58 break59 elif codingState == constants.eStart:60 if self._mCodingSM.get_current_charlen() >= 2:61 self._mNumOfMBChar += 16263 if self.get_state() == constants.eDetecting:64 if self.get_confidence() > constants.SHORTCUT_THRESHOLD:65 self._mState = constants.eFoundIt6667 return self.get_state()6869 def get_confidence(self):70 unlike = 0.9971 if self._mNumOfMBChar < 6:72 for i in range(0, self._mNumOfMBChar):73 unlike = unlike * ONE_CHAR_PROB74 return 1.0 - unlike75 else:76 return unlike
added:requests/packages/t.py
added:requests/compat.py.orig+123 added
1# -*- coding: utf-8 -*-23"""4pythoncompat5"""678import sys910# -------11# Pythons12# -------1314# Syntax sugar.15_ver = sys.version_info1617#: Python 2.x?18is_py2 = (_ver[0] == 2)1920#: Python 3.x?21is_py3 = (_ver[0] == 3)2223#: Python 3.0.x24is_py30 = (is_py3 and _ver[1] == 0)2526#: Python 3.1.x27is_py31 = (is_py3 and _ver[1] == 1)2829#: Python 3.2.x30is_py32 = (is_py3 and _ver[1] == 2)3132#: Python 3.3.x33is_py33 = (is_py3 and _ver[1] == 3)3435#: Python 3.4.x36is_py34 = (is_py3 and _ver[1] == 4)3738#: Python 2.7.x39is_py27 = (is_py2 and _ver[1] == 7)4041#: Python 2.6.x42is_py26 = (is_py2 and _ver[1] == 6)4344#: Python 2.5.x45is_py25 = (is_py2 and _ver[1] == 5)4647#: Python 2.4.x48is_py24 = (is_py2 and _ver[1] == 4) # I'm assuming this is not by choice.495051# ---------52# Platforms53# ---------545556# Syntax sugar.57_ver = sys.version.lower()5859is_pypy = ('pypy' in _ver)60is_jython = ('jython' in _ver)61is_ironpython = ('iron' in _ver)6263# Assume CPython, if nothing else.64is_cpython = not any((is_pypy, is_jython, is_ironpython))6566# Windows-based system.67is_windows = 'win32' in str(sys.platform).lower()6869# Standard Linux 2+ system.70is_linux = ('linux' in str(sys.platform).lower())71is_osx = ('darwin' in str(sys.platform).lower())72is_hpux = ('hpux' in str(sys.platform).lower()) # Complete guess.73is_solaris = ('solar==' in str(sys.platform).lower()) # Complete guess.7475try:76 import simplejson as json77except ImportError:78 import json7980# ---------81# Specifics82# ---------8384try:85 import cchardet as chardet86except ImportError:87 from .packages import chardet888990if is_py2:91 from urllib import quote, unquote, quote_plus, unquote_plus, urlencode92 from urlparse import urlparse, urlunparse, urljoin, urlsplit, urldefrag93 from urllib2 import parse_http_list94 import cookielib95 from Cookie import Morsel96 from StringIO import StringIO97 from .packages.urllib3.packages.ordered_dict import OrderedDict9899 builtin_str = str100 bytes = str101 str = unicode102 basestring = basestring103 numeric_types = (int, long, float)104105106107elif is_py3:108 from urllib.parse import urlparse, urlunparse, urljoin, urlsplit, urlencode, quote, unquote, quote_plus, unquote_plus, urldefrag109 from urllib.request import parse_http_list110 from http import cookiejar as cookielib111 from http.cookies import Morsel112 from io import StringIO113<<<<<<< HEAD114=======115 from .packages import chardet116>>>>>>> 8f86ff633a2646442f2d8976046b5c0025e772c1117 from collections import OrderedDict118119 builtin_str = str120 str = str121 bytes = bytes122 basestring = (str, bytes)123 numeric_types = (int, float)
added:t.py+4 added
1from requests.packages import chardet23with open('test', 'rb') as f:4 print(chardet.detect(f.read()))
added:t2.py+6 added
1import requests23r = requests.get('http://readability.com')4r.encoding = None56print(r.text)
added:test+13 added
1{2 "url": "http://httpbin.org/get",3 "headers": {4 "Content-Length": "",5 "Connection": "keep-alive",6 "Accept": "*/*",7 "User-Agent": "curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5",8 "Host": "httpbin.org",9 "Content-Type": ""10 },11 "args": {},12 "origin": "184.72.18.219"13}