Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- ckpts/universal/global_step40/zero/11.attention.dense.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step40/zero/11.mlp.dense_h_to_4h_swiglu.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step40/zero/13.attention.dense.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step40/zero/13.attention.dense.weight/fp32.pt +3 -0
- ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/exp_avg.pt +3 -0
- ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/exp_avg_sq.pt +3 -0
- ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/fp32.pt +3 -0
- venv/lib/python3.10/site-packages/chardet/__main__.py +6 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/big5prober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/chardistribution.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/charsetgroupprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/charsetprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/codingstatemachine.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/cp949prober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/enums.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/eucjpprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/euckrprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/euctwfreq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/gb2312freq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/gb2312prober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/hebrewprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/jisfreq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/johabfreq.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/johabprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/jpcntx.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langbulgarianmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langgreekmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langhebrewmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langhungarianmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langrussianmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langthaimodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/langturkishmodel.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/macromanprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/mbcharsetprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/mbcsgroupprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/mbcssm.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/resultdict.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/sbcsgroupprober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/universaldetector.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/utf1632prober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/utf8prober.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/__pycache__/version.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/charsetprober.py +147 -0
- venv/lib/python3.10/site-packages/chardet/cli/__init__.py +0 -0
- venv/lib/python3.10/site-packages/chardet/cli/__pycache__/__init__.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/cli/__pycache__/chardetect.cpython-310.pyc +0 -0
- venv/lib/python3.10/site-packages/chardet/cli/chardetect.py +112 -0
- venv/lib/python3.10/site-packages/chardet/cp949prober.py +49 -0
- venv/lib/python3.10/site-packages/chardet/euckrprober.py +47 -0
ckpts/universal/global_step40/zero/11.attention.dense.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:f0421e19daec55c0fbc3e02b18b7c5591455dafa36286faa25731b1ca83304ba
|
3 |
+
size 16778396
|
ckpts/universal/global_step40/zero/11.mlp.dense_h_to_4h_swiglu.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:9d4abffcf0e986d390a94975c98d8013ddd8e38eb20a8979c3ca4520a9c8a046
|
3 |
+
size 33555612
|
ckpts/universal/global_step40/zero/13.attention.dense.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:30e59dd1f97dad63a93e11d7dece2ca3f04192bb3b8b1ad090455f120999b526
|
3 |
+
size 16778411
|
ckpts/universal/global_step40/zero/13.attention.dense.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:c549c52af7cf2d933091f3aad3903a5fa065aa407b731d90dc5cc2cefd8b9c03
|
3 |
+
size 16778317
|
ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/exp_avg.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:a288bb3792b7bf8841d378a259cfa53e765e4aba6a7058339193d3f87ea9b013
|
3 |
+
size 33555612
|
ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/exp_avg_sq.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:51c8bef8d79968f61473c3e4c624544ce4def727b70eb9dd2fc0dd7dff376ff1
|
3 |
+
size 33555627
|
ckpts/universal/global_step40/zero/6.mlp.dense_h_to_4h.weight/fp32.pt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4d2458e48b66000adb139907ffc454accbba80d7e289d9406f7a4d358832e3e4
|
3 |
+
size 33555533
|
venv/lib/python3.10/site-packages/chardet/__main__.py
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""Wrapper so people can run python -m chardet"""
|
2 |
+
|
3 |
+
from .cli.chardetect import main
|
4 |
+
|
5 |
+
if __name__ == "__main__":
|
6 |
+
main()
|
venv/lib/python3.10/site-packages/chardet/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (3.16 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/big5prober.cpython-310.pyc
ADDED
Binary file (1.14 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/chardistribution.cpython-310.pyc
ADDED
Binary file (6.56 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/charsetgroupprober.cpython-310.pyc
ADDED
Binary file (2.41 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/charsetprober.cpython-310.pyc
ADDED
Binary file (3.81 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/codingstatemachine.cpython-310.pyc
ADDED
Binary file (3.05 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/cp949prober.cpython-310.pyc
ADDED
Binary file (1.15 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/enums.cpython-310.pyc
ADDED
Binary file (2.64 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/eucjpprober.cpython-310.pyc
ADDED
Binary file (2.58 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/euckrprober.cpython-310.pyc
ADDED
Binary file (1.15 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/euctwfreq.cpython-310.pyc
ADDED
Binary file (27.2 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/gb2312freq.cpython-310.pyc
ADDED
Binary file (19.1 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/gb2312prober.cpython-310.pyc
ADDED
Binary file (1.16 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/hebrewprober.cpython-310.pyc
ADDED
Binary file (3.4 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/jisfreq.cpython-310.pyc
ADDED
Binary file (22.1 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/johabfreq.cpython-310.pyc
ADDED
Binary file (139 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/johabprober.cpython-310.pyc
ADDED
Binary file (1.15 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/jpcntx.cpython-310.pyc
ADDED
Binary file (38 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langbulgarianmodel.cpython-310.pyc
ADDED
Binary file (47.9 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langgreekmodel.cpython-310.pyc
ADDED
Binary file (46.1 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langhebrewmodel.cpython-310.pyc
ADDED
Binary file (44.5 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langhungarianmodel.cpython-310.pyc
ADDED
Binary file (47.9 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langrussianmodel.cpython-310.pyc
ADDED
Binary file (61 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langthaimodel.cpython-310.pyc
ADDED
Binary file (44.7 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/langturkishmodel.cpython-310.pyc
ADDED
Binary file (44.6 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/macromanprober.cpython-310.pyc
ADDED
Binary file (4.69 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/mbcharsetprober.cpython-310.pyc
ADDED
Binary file (2.3 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/mbcsgroupprober.cpython-310.pyc
ADDED
Binary file (1.24 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/mbcssm.cpython-310.pyc
ADDED
Binary file (20.9 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/resultdict.cpython-310.pyc
ADDED
Binary file (559 Bytes). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/sbcsgroupprober.cpython-310.pyc
ADDED
Binary file (1.72 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/universaldetector.cpython-310.pyc
ADDED
Binary file (7.11 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/utf1632prober.cpython-310.pyc
ADDED
Binary file (6.08 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/utf8prober.cpython-310.pyc
ADDED
Binary file (2.09 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/__pycache__/version.cpython-310.pyc
ADDED
Binary file (424 Bytes). View file
|
|
venv/lib/python3.10/site-packages/chardet/charsetprober.py
ADDED
@@ -0,0 +1,147 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
|
29 |
+
import logging
|
30 |
+
import re
|
31 |
+
from typing import Optional, Union
|
32 |
+
|
33 |
+
from .enums import LanguageFilter, ProbingState
|
34 |
+
|
35 |
+
INTERNATIONAL_WORDS_PATTERN = re.compile(
|
36 |
+
b"[a-zA-Z]*[\x80-\xFF]+[a-zA-Z]*[^a-zA-Z\x80-\xFF]?"
|
37 |
+
)
|
38 |
+
|
39 |
+
|
40 |
+
class CharSetProber:
|
41 |
+
|
42 |
+
SHORTCUT_THRESHOLD = 0.95
|
43 |
+
|
44 |
+
def __init__(self, lang_filter: LanguageFilter = LanguageFilter.NONE) -> None:
|
45 |
+
self._state = ProbingState.DETECTING
|
46 |
+
self.active = True
|
47 |
+
self.lang_filter = lang_filter
|
48 |
+
self.logger = logging.getLogger(__name__)
|
49 |
+
|
50 |
+
def reset(self) -> None:
|
51 |
+
self._state = ProbingState.DETECTING
|
52 |
+
|
53 |
+
@property
|
54 |
+
def charset_name(self) -> Optional[str]:
|
55 |
+
return None
|
56 |
+
|
57 |
+
@property
|
58 |
+
def language(self) -> Optional[str]:
|
59 |
+
raise NotImplementedError
|
60 |
+
|
61 |
+
def feed(self, byte_str: Union[bytes, bytearray]) -> ProbingState:
|
62 |
+
raise NotImplementedError
|
63 |
+
|
64 |
+
@property
|
65 |
+
def state(self) -> ProbingState:
|
66 |
+
return self._state
|
67 |
+
|
68 |
+
def get_confidence(self) -> float:
|
69 |
+
return 0.0
|
70 |
+
|
71 |
+
@staticmethod
|
72 |
+
def filter_high_byte_only(buf: Union[bytes, bytearray]) -> bytes:
|
73 |
+
buf = re.sub(b"([\x00-\x7F])+", b" ", buf)
|
74 |
+
return buf
|
75 |
+
|
76 |
+
@staticmethod
|
77 |
+
def filter_international_words(buf: Union[bytes, bytearray]) -> bytearray:
|
78 |
+
"""
|
79 |
+
We define three types of bytes:
|
80 |
+
alphabet: english alphabets [a-zA-Z]
|
81 |
+
international: international characters [\x80-\xFF]
|
82 |
+
marker: everything else [^a-zA-Z\x80-\xFF]
|
83 |
+
The input buffer can be thought to contain a series of words delimited
|
84 |
+
by markers. This function works to filter all words that contain at
|
85 |
+
least one international character. All contiguous sequences of markers
|
86 |
+
are replaced by a single space ascii character.
|
87 |
+
This filter applies to all scripts which do not use English characters.
|
88 |
+
"""
|
89 |
+
filtered = bytearray()
|
90 |
+
|
91 |
+
# This regex expression filters out only words that have at-least one
|
92 |
+
# international character. The word may include one marker character at
|
93 |
+
# the end.
|
94 |
+
words = INTERNATIONAL_WORDS_PATTERN.findall(buf)
|
95 |
+
|
96 |
+
for word in words:
|
97 |
+
filtered.extend(word[:-1])
|
98 |
+
|
99 |
+
# If the last character in the word is a marker, replace it with a
|
100 |
+
# space as markers shouldn't affect our analysis (they are used
|
101 |
+
# similarly across all languages and may thus have similar
|
102 |
+
# frequencies).
|
103 |
+
last_char = word[-1:]
|
104 |
+
if not last_char.isalpha() and last_char < b"\x80":
|
105 |
+
last_char = b" "
|
106 |
+
filtered.extend(last_char)
|
107 |
+
|
108 |
+
return filtered
|
109 |
+
|
110 |
+
@staticmethod
|
111 |
+
def remove_xml_tags(buf: Union[bytes, bytearray]) -> bytes:
|
112 |
+
"""
|
113 |
+
Returns a copy of ``buf`` that retains only the sequences of English
|
114 |
+
alphabet and high byte characters that are not between <> characters.
|
115 |
+
This filter can be applied to all scripts which contain both English
|
116 |
+
characters and extended ASCII characters, but is currently only used by
|
117 |
+
``Latin1Prober``.
|
118 |
+
"""
|
119 |
+
filtered = bytearray()
|
120 |
+
in_tag = False
|
121 |
+
prev = 0
|
122 |
+
buf = memoryview(buf).cast("c")
|
123 |
+
|
124 |
+
for curr, buf_char in enumerate(buf):
|
125 |
+
# Check if we're coming out of or entering an XML tag
|
126 |
+
|
127 |
+
# https://github.com/python/typeshed/issues/8182
|
128 |
+
if buf_char == b">": # type: ignore[comparison-overlap]
|
129 |
+
prev = curr + 1
|
130 |
+
in_tag = False
|
131 |
+
# https://github.com/python/typeshed/issues/8182
|
132 |
+
elif buf_char == b"<": # type: ignore[comparison-overlap]
|
133 |
+
if curr > prev and not in_tag:
|
134 |
+
# Keep everything after last non-extended-ASCII,
|
135 |
+
# non-alphabetic character
|
136 |
+
filtered.extend(buf[prev:curr])
|
137 |
+
# Output a space to delimit stretch we kept
|
138 |
+
filtered.extend(b" ")
|
139 |
+
in_tag = True
|
140 |
+
|
141 |
+
# If we're not in a tag...
|
142 |
+
if not in_tag:
|
143 |
+
# Keep everything after last non-extended-ASCII, non-alphabetic
|
144 |
+
# character
|
145 |
+
filtered.extend(buf[prev:])
|
146 |
+
|
147 |
+
return filtered
|
venv/lib/python3.10/site-packages/chardet/cli/__init__.py
ADDED
File without changes
|
venv/lib/python3.10/site-packages/chardet/cli/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (179 Bytes). View file
|
|
venv/lib/python3.10/site-packages/chardet/cli/__pycache__/chardetect.cpython-310.pyc
ADDED
Binary file (3.02 kB). View file
|
|
venv/lib/python3.10/site-packages/chardet/cli/chardetect.py
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"""
|
2 |
+
Script which takes one or more file paths and reports on their detected
|
3 |
+
encodings
|
4 |
+
|
5 |
+
Example::
|
6 |
+
|
7 |
+
% chardetect somefile someotherfile
|
8 |
+
somefile: windows-1252 with confidence 0.5
|
9 |
+
someotherfile: ascii with confidence 1.0
|
10 |
+
|
11 |
+
If no paths are provided, it takes its input from stdin.
|
12 |
+
|
13 |
+
"""
|
14 |
+
|
15 |
+
|
16 |
+
import argparse
|
17 |
+
import sys
|
18 |
+
from typing import Iterable, List, Optional
|
19 |
+
|
20 |
+
from .. import __version__
|
21 |
+
from ..universaldetector import UniversalDetector
|
22 |
+
|
23 |
+
|
24 |
+
def description_of(
|
25 |
+
lines: Iterable[bytes],
|
26 |
+
name: str = "stdin",
|
27 |
+
minimal: bool = False,
|
28 |
+
should_rename_legacy: bool = False,
|
29 |
+
) -> Optional[str]:
|
30 |
+
"""
|
31 |
+
Return a string describing the probable encoding of a file or
|
32 |
+
list of strings.
|
33 |
+
|
34 |
+
:param lines: The lines to get the encoding of.
|
35 |
+
:type lines: Iterable of bytes
|
36 |
+
:param name: Name of file or collection of lines
|
37 |
+
:type name: str
|
38 |
+
:param should_rename_legacy: Should we rename legacy encodings to
|
39 |
+
their more modern equivalents?
|
40 |
+
:type should_rename_legacy: ``bool``
|
41 |
+
"""
|
42 |
+
u = UniversalDetector(should_rename_legacy=should_rename_legacy)
|
43 |
+
for line in lines:
|
44 |
+
line = bytearray(line)
|
45 |
+
u.feed(line)
|
46 |
+
# shortcut out of the loop to save reading further - particularly useful if we read a BOM.
|
47 |
+
if u.done:
|
48 |
+
break
|
49 |
+
u.close()
|
50 |
+
result = u.result
|
51 |
+
if minimal:
|
52 |
+
return result["encoding"]
|
53 |
+
if result["encoding"]:
|
54 |
+
return f'{name}: {result["encoding"]} with confidence {result["confidence"]}'
|
55 |
+
return f"{name}: no result"
|
56 |
+
|
57 |
+
|
58 |
+
def main(argv: Optional[List[str]] = None) -> None:
|
59 |
+
"""
|
60 |
+
Handles command line arguments and gets things started.
|
61 |
+
|
62 |
+
:param argv: List of arguments, as if specified on the command-line.
|
63 |
+
If None, ``sys.argv[1:]`` is used instead.
|
64 |
+
:type argv: list of str
|
65 |
+
"""
|
66 |
+
# Get command line arguments
|
67 |
+
parser = argparse.ArgumentParser(
|
68 |
+
description=(
|
69 |
+
"Takes one or more file paths and reports their detected encodings"
|
70 |
+
)
|
71 |
+
)
|
72 |
+
parser.add_argument(
|
73 |
+
"input",
|
74 |
+
help="File whose encoding we would like to determine. (default: stdin)",
|
75 |
+
type=argparse.FileType("rb"),
|
76 |
+
nargs="*",
|
77 |
+
default=[sys.stdin.buffer],
|
78 |
+
)
|
79 |
+
parser.add_argument(
|
80 |
+
"--minimal",
|
81 |
+
help="Print only the encoding to standard output",
|
82 |
+
action="store_true",
|
83 |
+
)
|
84 |
+
parser.add_argument(
|
85 |
+
"-l",
|
86 |
+
"--legacy",
|
87 |
+
help="Rename legacy encodings to more modern ones.",
|
88 |
+
action="store_true",
|
89 |
+
)
|
90 |
+
parser.add_argument(
|
91 |
+
"--version", action="version", version=f"%(prog)s {__version__}"
|
92 |
+
)
|
93 |
+
args = parser.parse_args(argv)
|
94 |
+
|
95 |
+
for f in args.input:
|
96 |
+
if f.isatty():
|
97 |
+
print(
|
98 |
+
"You are running chardetect interactively. Press "
|
99 |
+
"CTRL-D twice at the start of a blank line to signal the "
|
100 |
+
"end of your input. If you want help, run chardetect "
|
101 |
+
"--help\n",
|
102 |
+
file=sys.stderr,
|
103 |
+
)
|
104 |
+
print(
|
105 |
+
description_of(
|
106 |
+
f, f.name, minimal=args.minimal, should_rename_legacy=args.legacy
|
107 |
+
)
|
108 |
+
)
|
109 |
+
|
110 |
+
|
111 |
+
if __name__ == "__main__":
|
112 |
+
main()
|
venv/lib/python3.10/site-packages/chardet/cp949prober.py
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
######################## BEGIN LICENSE BLOCK ########################
|
2 |
+
# The Original Code is mozilla.org 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) 1998
|
7 |
+
# the Initial Developer. All Rights Reserved.
|
8 |
+
#
|
9 |
+
# Contributor(s):
|
10 |
+
# Mark Pilgrim - port to Python
|
11 |
+
#
|
12 |
+
# This library is free software; you can redistribute it and/or
|
13 |
+
# modify it under the terms of the GNU Lesser General Public
|
14 |
+
# License as published by the Free Software Foundation; either
|
15 |
+
# 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 of
|
19 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
+
# Lesser General Public License for more details.
|
21 |
+
#
|
22 |
+
# You should have received a copy of the GNU Lesser General Public
|
23 |
+
# License along with this library; if not, write to the Free Software
|
24 |
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
25 |
+
# 02110-1301 USA
|
26 |
+
######################### END LICENSE BLOCK #########################
|
27 |
+
|
28 |
+
from .chardistribution import EUCKRDistributionAnalysis
|
29 |
+
from .codingstatemachine import CodingStateMachine
|
30 |
+
from .mbcharsetprober import MultiByteCharSetProber
|
31 |
+
from .mbcssm import CP949_SM_MODEL
|
32 |
+
|
33 |
+
|
34 |
+
class CP949Prober(MultiByteCharSetProber):
|
35 |
+
def __init__(self) -> None:
|
36 |
+
super().__init__()
|
37 |
+
self.coding_sm = CodingStateMachine(CP949_SM_MODEL)
|
38 |
+
# NOTE: CP949 is a superset of EUC-KR, so the distribution should be
|
39 |
+
# not different.
|
40 |
+
self.distribution_analyzer = EUCKRDistributionAnalysis()
|
41 |
+
self.reset()
|
42 |
+
|
43 |
+
@property
|
44 |
+
def charset_name(self) -> str:
|
45 |
+
return "CP949"
|
46 |
+
|
47 |
+
@property
|
48 |
+
def language(self) -> str:
|
49 |
+
return "Korean"
|
venv/lib/python3.10/site-packages/chardet/euckrprober.py
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
######################## BEGIN LICENSE BLOCK ########################
|
2 |
+
# The Original Code is mozilla.org 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) 1998
|
7 |
+
# the Initial Developer. All Rights Reserved.
|
8 |
+
#
|
9 |
+
# Contributor(s):
|
10 |
+
# Mark Pilgrim - port to Python
|
11 |
+
#
|
12 |
+
# This library is free software; you can redistribute it and/or
|
13 |
+
# modify it under the terms of the GNU Lesser General Public
|
14 |
+
# License as published by the Free Software Foundation; either
|
15 |
+
# 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 of
|
19 |
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
20 |
+
# Lesser General Public License for more details.
|
21 |
+
#
|
22 |
+
# You should have received a copy of the GNU Lesser General Public
|
23 |
+
# License along with this library; if not, write to the Free Software
|
24 |
+
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
25 |
+
# 02110-1301 USA
|
26 |
+
######################### END LICENSE BLOCK #########################
|
27 |
+
|
28 |
+
from .chardistribution import EUCKRDistributionAnalysis
|
29 |
+
from .codingstatemachine import CodingStateMachine
|
30 |
+
from .mbcharsetprober import MultiByteCharSetProber
|
31 |
+
from .mbcssm import EUCKR_SM_MODEL
|
32 |
+
|
33 |
+
|
34 |
+
class EUCKRProber(MultiByteCharSetProber):
|
35 |
+
def __init__(self) -> None:
|
36 |
+
super().__init__()
|
37 |
+
self.coding_sm = CodingStateMachine(EUCKR_SM_MODEL)
|
38 |
+
self.distribution_analyzer = EUCKRDistributionAnalysis()
|
39 |
+
self.reset()
|
40 |
+
|
41 |
+
@property
|
42 |
+
def charset_name(self) -> str:
|
43 |
+
return "EUC-KR"
|
44 |
+
|
45 |
+
@property
|
46 |
+
def language(self) -> str:
|
47 |
+
return "Korean"
|