Skip to content

Commit 851efa5

Browse files
authored
add stubs for language models (#3848)
* add stubs for language models * fix syntax error in __init__.pyi * fix syntax error in universaldetector.pyi * remove erroneous imports * delete cli directory * make tuple types variable length
1 parent a1c6566 commit 851efa5

11 files changed

+126
-2
lines changed
+23-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,26 @@
1-
from typing import Any
1+
import sys
2+
from typing import Any, Tuple
3+
24
from .universaldetector import UniversalDetector as UniversalDetector
35

46
def __getattr__(name: str) -> Any: ... # incomplete
7+
8+
if sys.version_info >= (3, 8):
9+
from typing import TypedDict
10+
else:
11+
from typing_extensions import TypedDict
12+
13+
class _LangModelType(TypedDict):
14+
char_to_order_map: Tuple[int, ...]
15+
precedence_matrix: Tuple[int, ...]
16+
typical_positive_ratio: float
17+
keep_english_letter: bool
18+
charset_name: str
19+
language: str
20+
21+
class _SMModelType(TypedDict):
22+
class_table: Tuple[int, ...]
23+
class_factor: int
24+
state_table: Tuple[int, ...]
25+
char_len_table: Tuple[int, ...]
26+
name: str

third_party/2and3/chardet/enums.pyi

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
class InputState(object):
2+
PURE_ASCII: int
3+
ESC_ASCII: int
4+
HIGH_BYTE: int
5+
6+
class LanguageFilter(object):
7+
CHINESE_SIMPLIFIED: int
8+
CHINESE_TRADITIONAL: int
9+
JAPANESE: int
10+
KOREAN: int
11+
NON_CJK: int
12+
ALL: int
13+
CHINESE: int
14+
CJK: int
15+
16+
class ProbingState(object):
17+
DETECTING: int
18+
FOUND_IT: int
19+
NOT_ME: int
20+
21+
class MachineState(object):
22+
START: int
23+
ERROR: int
24+
ITS_ME: int
25+
26+
class SequenceLikelihood(object):
27+
NEGATIVE: int
28+
UNLIKELY: int
29+
LIKELY: int
30+
POSITIVE: int
31+
32+
@classmethod
33+
def get_num_categories(cls) -> int: ...
34+
35+
class CharacterCategory(object):
36+
UNDEFINED: int
37+
LINE_BREAK: int
38+
SYMBOL: int
39+
DIGIT: int
40+
CONTROL: int
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
Latin5_BulgarianCharToOrderMap: Tuple[int, ...]
5+
win1251BulgarianCharToOrderMap: Tuple[int, ...]
6+
BulgarianLangModel: Tuple[int, ...]
7+
Latin5BulgarianModel: _LangModelType
8+
Win1251BulgarianModel: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
KOI8R_char_to_order_map: Tuple[int, ...]
5+
win1251_char_to_order_map: Tuple[int, ...]
6+
latin5_char_to_order_map: Tuple[int, ...]
7+
macCyrillic_char_to_order_map: Tuple[int, ...]
8+
IBM855_char_to_order_map: Tuple[int, ...]
9+
IBM866_char_to_order_map: Tuple[int, ...]
10+
RussianLangModel: Tuple[int, ...]
11+
Koi8rModel: _LangModelType
12+
Win1251CyrillicModel: _LangModelType
13+
Latin5CyrillicModel: _LangModelType
14+
MacCyrillicModel: _LangModelType
15+
Ibm866Model: _LangModelType
16+
Ibm855Model: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
Latin7_char_to_order_map: Tuple[int, ...]
5+
win1253_char_to_order_map: Tuple[int, ...]
6+
GreekLangModel: Tuple[int, ...]
7+
Latin7GreekModel: _LangModelType
8+
Win1253GreekModel: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
WIN1255_CHAR_TO_ORDER_MAP: Tuple[int, ...]
5+
HEBREW_LANG_MODEL: Tuple[int, ...]
6+
Win1255HebrewModel: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
Latin2_HungarianCharToOrderMap: Tuple[int, ...]
5+
win1250HungarianCharToOrderMap: Tuple[int, ...]
6+
HungarianLangModel: Tuple[int, ...]
7+
Latin2HungarianModel: _LangModelType
8+
Win1250HungarianModel: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
TIS620CharToOrderMap: Tuple[int, ...]
5+
ThaiLangModel: Tuple[int, ...]
6+
TIS620ThaiModel: _LangModelType
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Tuple
2+
from . import _LangModelType
3+
4+
Latin5_TurkishCharToOrderMap: Tuple[int, ...]
5+
TurkishLangModel: Tuple[int, ...]
6+
Latin5TurkishModel: _LangModelType

third_party/2and3/chardet/universaldetector.pyi

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sys
2-
from typing import Dict, Union, AnyStr, Pattern, Optional
2+
from typing import Dict, Pattern, Optional
33
from typing_extensions import TypedDict
44
from logging import Logger
55

third_party/2and3/chardet/version.pyi

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from typing import List
2+
3+
__version__: str
4+
VERSION: List[str]

0 commit comments

Comments
 (0)