sbcsgroupprober.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ######################## BEGIN LICENSE BLOCK ########################
  2. # The Original Code is Mozilla Universal charset detector code.
  3. #
  4. # The Initial Developer of the Original Code is
  5. # Netscape Communications Corporation.
  6. # Portions created by the Initial Developer are Copyright (C) 2001
  7. # the Initial Developer. All Rights Reserved.
  8. #
  9. # Contributor(s):
  10. # Mark Pilgrim - port to Python
  11. # Shy Shalom - original C code
  12. #
  13. # This library is free software; you can redistribute it and/or
  14. # modify it under the terms of the GNU Lesser General Public
  15. # License as published by the Free Software Foundation; either
  16. # 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 of
  20. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  21. # Lesser General Public License for more details.
  22. #
  23. # You should have received a copy of the GNU Lesser General Public
  24. # License along with this library; if not, write to the Free Software
  25. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  26. # 02110-1301 USA
  27. ######################### END LICENSE BLOCK #########################
  28. from .charsetgroupprober import CharSetGroupProber
  29. from .sbcharsetprober import SingleByteCharSetProber
  30. from .langcyrillicmodel import (Win1251CyrillicModel, Koi8rModel,
  31. Latin5CyrillicModel, MacCyrillicModel,
  32. Ibm866Model, Ibm855Model)
  33. from .langgreekmodel import Latin7GreekModel, Win1253GreekModel
  34. from .langbulgarianmodel import Latin5BulgarianModel, Win1251BulgarianModel
  35. from .langhungarianmodel import Latin2HungarianModel, Win1250HungarianModel
  36. from .langthaimodel import TIS620ThaiModel
  37. from .langhebrewmodel import Win1255HebrewModel
  38. from .hebrewprober import HebrewProber
  39. class SBCSGroupProber(CharSetGroupProber):
  40. def __init__(self):
  41. CharSetGroupProber.__init__(self)
  42. self._mProbers = [
  43. SingleByteCharSetProber(Win1251CyrillicModel),
  44. SingleByteCharSetProber(Koi8rModel),
  45. SingleByteCharSetProber(Latin5CyrillicModel),
  46. SingleByteCharSetProber(MacCyrillicModel),
  47. SingleByteCharSetProber(Ibm866Model),
  48. SingleByteCharSetProber(Ibm855Model),
  49. SingleByteCharSetProber(Latin7GreekModel),
  50. SingleByteCharSetProber(Win1253GreekModel),
  51. SingleByteCharSetProber(Latin5BulgarianModel),
  52. SingleByteCharSetProber(Win1251BulgarianModel),
  53. SingleByteCharSetProber(Latin2HungarianModel),
  54. SingleByteCharSetProber(Win1250HungarianModel),
  55. SingleByteCharSetProber(TIS620ThaiModel),
  56. ]
  57. hebrewProber = HebrewProber()
  58. logicalHebrewProber = SingleByteCharSetProber(Win1255HebrewModel,
  59. False, hebrewProber)
  60. visualHebrewProber = SingleByteCharSetProber(Win1255HebrewModel, True,
  61. hebrewProber)
  62. hebrewProber.set_model_probers(logicalHebrewProber, visualHebrewProber)
  63. self._mProbers.extend([hebrewProber, logicalHebrewProber,
  64. visualHebrewProber])
  65. self.reset()