Skip to content

add universaldetector #3734

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions third_party/2and3/chardet/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from typing import Any
from .universaldetector import UniversalDetector as UniversalDetector

def __getattr__(name: str) -> Any: ... # incomplete
31 changes: 31 additions & 0 deletions third_party/2and3/chardet/universaldetector.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sys
from typing import Dict, Union, AnyStr, Pattern, Optional
from typing_extensions import TypedDict
from logging import Logger

class _FinalResultType(TypedDict):
encoding: str
confidence: float
language: str

class _IntermediateResultType(TypedDict):
encoding: Optional[str]
confidence: float
language: Optional[str]

class UniversalDetector(object):
MINIMUM_THRESHOLD: float
HIGH_BYTE_DETECTOR: Pattern[bytes]
ESC_DETECTOR: Pattern[bytes]
WIN_BYTE_DETECTOR: Pattern[bytes]
ISO_WIN_MAP: Dict[str, str]

result: _IntermediateResultType
done: bool
lang_filter: int
logger: Logger

def __init__(self, lang_filter: int) -> None: ...
def reset(self) -> None: ...
def feed(self, byte_str: bytes) -> None: ...
def close(self) -> _FinalResultType: ...