Skip to content

Commit a56faa8

Browse files
committed
Enchant: Spell checking library for Enchant WIP
<https://github.com/pyenchant/pyenchant> <http://pyenchant.github.io/pyenchant/api/index.html> - [ ] API-2 accepts Union[Text, bytes], see <python/typing#208> - [ ] API-3 provides new functions and is Pyhton-3-only
1 parent 27a45df commit a56faa8

File tree

10 files changed

+286
-0
lines changed

10 files changed

+286
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
from typing import Any, List, Tuple
2+
3+
from enchant.errors import *
4+
from enchant.pypwl import PyPWL as PyPWL
5+
from enchant.utils import (
6+
EnchantStr as EnchantStr,
7+
UTF16EnchantStr as UTF16EnchantStr,
8+
get_default_language as get_default_language,
9+
)
10+
11+
class warnings:
12+
def warn(self, *args: Any, **kwds: Any) -> None: ...
13+
14+
class ProviderDesc:
15+
name: str = ...
16+
desc: str = ...
17+
file: str = ...
18+
def __init__(self, name: str, desc: str, file: str) -> None: ...
19+
def __eq__(self, pd: Any) -> bool: ...
20+
def __hash__(self) -> int: ...
21+
22+
class _EnchantObject:
23+
def __init__(self) -> None: ...
24+
25+
class Broker(_EnchantObject):
26+
def __init__(self) -> None: ...
27+
def __del__(self) -> None: ...
28+
def request_dict(self, tag: str = ...) -> Dict: ...
29+
def request_pwl_dict(self, pwl: str) -> Dict: ...
30+
def dict_exists(self, tag: str) -> bool: ...
31+
def set_ordering(self, tag: str, ordering: str) -> None: ...
32+
def describe(self) -> List[ProviderDesc]: ...
33+
def list_dicts(self) -> List[Tuple[str, ProviderDesc]]: ...
34+
def list_languages(self) -> List[str]: ...
35+
def get_param(self, name: str) -> Any: ...
36+
def set_param(self, name: str, value: Any) -> None: ...
37+
38+
class Dict(_EnchantObject):
39+
provider: ProviderDesc = ...
40+
tag: str = ...
41+
def __init__(self, tag: str = ..., broker: Broker = ...) -> None: ...
42+
def __del__(self) -> None: ...
43+
def check(self, word: str) -> bool: ...
44+
def suggest(self, word: str) -> List[str]: ...
45+
def add(self, word: str) -> None: ...
46+
def remove(self, word: str) -> None: ...
47+
def add_to_pwl(self, word: str) -> None: ...
48+
def add_to_session(self, word: str) -> None: ...
49+
def remove_from_session(self, word: str) -> None: ...
50+
def is_added(self, word: str) -> bool: ...
51+
def is_removed(self, word: str) -> bool: ...
52+
def store_replacement(self, mis: str, cor: str) -> None: ...
53+
54+
class DictWithPWL(Dict):
55+
pwl: Dict = ...
56+
pel: Dict = ...
57+
def __init__(self, tag: str, pwl: str = ..., pel: str = ..., broker: Broker = ...) -> None: ...
58+
def check(self, word: str) -> bool: ...
59+
def suggest(self, word: str) -> List[str]: ...
60+
def add(self, word: str) -> None: ...
61+
def remove(self, word: str) -> None: ...
62+
def add_to_pwl(self, word: str) -> None: ...
63+
def is_added(self, word: str) -> bool: ...
64+
def is_removed(self, word: str) -> bool: ...
65+
66+
def request_dict(self, tag: str = ...) -> Dict: ...
67+
def request_pwl_dict(self, pwl: str) -> Dict: ...
68+
def dict_exists(tag: str) -> bool: ...
69+
def list_dicts() -> List[Tuple[str, ProviderDesc]]: ...
70+
def list_languages() -> List[str]: ...
71+
def get_param(name: str) -> Any: ...
72+
def set_param(name: str, value: Any) -> None: ...
73+
def get_enchant_version() -> str: ...
74+
def set_prefix_dir(path: str) -> None: ...
75+
def get_user_config_dir() -> str: ...
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from typing import Dict, Optional
2+
3+
from enchant.checker import SpellChecker
4+
5+
colors: Dict[str, str]
6+
7+
def color(string: str, color: str = ..., prefix: str = ...): ...
8+
def success(string: str): ...
9+
def error(string: str): ...
10+
def warning(string: str): ...
11+
def info(string: str): ...
12+
13+
class CmdLineChecker:
14+
def __init__(self) -> None: ...
15+
def set_checker(self, chkr: SpellChecker) -> None: ...
16+
def get_checker(self, chkr: SpellChecker) -> SpellChecker: ...
17+
# error: Any = ...
18+
def run(self) -> None: ...
19+
def print_error(self) -> None: ...
20+
def print_suggestions(self) -> None: ...
21+
def print_help(self) -> None: ...
22+
def read_command(self) -> bool: ...
23+
def run_on_file(self, infile: str, outfile: str = ..., enc: str = ...) -> None: ...
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from typing import Any
2+
3+
import gtk
4+
from enchant.checker import SpellChecker
5+
6+
COLUMN_SUGGESTION: int
7+
8+
# def create_list_view(col_label: Any): ...
9+
10+
class GtkSpellCheckerDialog(gtk.Window):
11+
# errors: Any = ...
12+
# error_text: Any = ...
13+
# replace_text: Any = ...
14+
# suggestion_list_view: Any = ...
15+
def __init__(self, *args: Any, **kwargs: Any) -> None: ...
16+
def setSpellChecker(self, checker: SpellChecker) -> None: ...
17+
def getSpellChecker(self, checker: SpellChecker): ...
18+
def updateUI(self) -> None: ...
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import Iterator, List, Optional, Type, Union
2+
3+
from enchant import Dict
4+
from enchant.errors import *
5+
from enchant.tokenize import Chunker, Filter, get_tokenizer as get_tokenizer, tokenize
6+
from enchant.utils import get_default_language as get_default_language
7+
8+
class SpellChecker:
9+
lang: str = ...
10+
dict: Dict = ...
11+
word: Optional[str] = ...
12+
wordpos: Optional[int] = ...
13+
def __init__(
14+
self,
15+
lang: Union[Dict, str] = ...,
16+
text: str = ...,
17+
tokenize: Union[Type[tokenize], Filter] = ...,
18+
chunkers: List[Chunker] = ...,
19+
filters: List[Filter] = ...,
20+
) -> None: ...
21+
def __iter__(self) -> Iterator[SpellChecker]: ...
22+
def set_text(self, text: str) -> None: ...
23+
def get_text(self) -> str: ...
24+
def wants_unicode(self) -> bool: ...
25+
def coerce_string(self, text: str, enc: str = ...) -> str: ...
26+
def __next__(self) -> SpellChecker: ...
27+
def next(self) -> SpellChecker: ...
28+
def replace(self, repl: str) -> None: ...
29+
def replace_always(self, word: str, repl: str = ...) -> None: ...
30+
def ignore_always(self, word: str = ...) -> None: ...
31+
def add_to_personal(self, word: str = ...) -> None: ...
32+
def add(self, word: str = ...) -> None: ...
33+
def suggest(self, word: str = ...) -> List[str]: ...
34+
def check(self, word: str) -> bool: ...
35+
def set_offset(self, off: int, whence: int = ...) -> None: ...
36+
def leading_context(self, chars: int) -> str: ...
37+
def trailing_context(self, chars: int) -> str: ...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any, Optional
2+
3+
import wx
4+
from enchant.checker import SpellChecker
5+
6+
class wxSpellCheckerDialog(wx.Dialog):
7+
# sz: Any = ...
8+
# error_text: Any = ...
9+
# replace_text: Any = ...
10+
# replace_list: Any = ...
11+
def __init__(self, parent: Optional[Any] = ..., id: int = ..., title: str = ...) -> None: ...
12+
# buttons: Any = ...
13+
def InitLayout(self) -> None: ...
14+
def Advance(self) -> bool: ...
15+
def EnableButtons(self, state: bool = ...) -> None: ...
16+
def GetRepl(self) -> str: ...
17+
def OnAdd(self, evt: Any) -> None: ...
18+
def OnDone(self, evt: Any) -> None: ...
19+
def OnIgnore(self, evt: Any) -> None: ...
20+
def OnIgnoreAll(self, evt: Any) -> None: ...
21+
def OnReplace(self, evt: Any) -> None: ...
22+
def OnReplaceAll(self, evt: Any) -> None: ...
23+
def OnReplSelect(self, evt: Any) -> None: ...
24+
def GetSpellChecker(self) -> SpellChecker: ...
25+
def SetSpellChecker(self, chkr: SpellChecker) -> bool: ...

third_party/2and3/enchant/errors.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Error(Exception): ...
2+
class DictNotFoundError(Error): ...
3+
class TokenizerNotFoundError(Error): ...
4+
class DefaultLanguageNotFoundError(Error): ...

third_party/2and3/enchant/pypwl.pyi

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from typing import Any, Iterable, Iterator, List, Optional
2+
3+
class Trie:
4+
def __init__(self, words: Iterable[str] = ...) -> None: ...
5+
def insert(self, word: str) -> None: ...
6+
def remove(self, word: str) -> None: ...
7+
def search(self, word: str, nerrs: int = ...) -> List[str]: ...
8+
def __getitem__(self, key: str) -> Trie: ...
9+
def __setitem__(self, key: str, val: Trie) -> None: ...
10+
def __iter__(self) -> Iterator[str]: ...
11+
12+
class PyPWL:
13+
provider: None = ...
14+
pwl: Optional[str] = ...
15+
tag: str = ...
16+
def __init__(self, pwl: str = ...) -> None: ...
17+
def check(self, word: str) -> bool: ...
18+
def suggest(self, word: str) -> List[str]: ...
19+
def add(self, word: str) -> None: ...
20+
def add_to_pwl(self, word: str) -> None: ...
21+
def remove(self, word: str) -> None: ...
22+
def add_to_session(self, word: str) -> None: ...
23+
def store_replacement(self, mis: str, cor: str) -> None: ...
24+
def is_added(self, word: str) -> bool: ...
25+
def is_removed(self, word: str) -> bool: ...
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# from enchant.errors import *
2+
from typing import Any, Callable, Iterable, Iterator, Optional, Tuple, Type, Union
3+
from typing_extensions import Protocol
4+
5+
Token = Tuple[str, int]
6+
7+
# Error = TokenizerNotFoundError
8+
9+
class tokenize(Protocol):
10+
def __init__(self, text: str) -> None: ...
11+
def __next__(self) -> Token: ...
12+
def next(self) -> Token: ...
13+
def __iter__(self) -> Iterator[Token]: ...
14+
def set_offset(self, offset: int, replaced: bool = ...) -> None: ...
15+
offset: int = ...
16+
17+
class empty_tokenize(tokenize):
18+
def __init__(self) -> None: ...
19+
20+
class unit_tokenize(tokenize):
21+
def __init__(self, text: str) -> None: ...
22+
23+
class basic_tokenize(tokenize):
24+
strip_from_start: str = ...
25+
strip_from_end: str = ...
26+
27+
class Chunker(tokenize): ...
28+
29+
_Filter = Union[Type[tokenize], Filter]
30+
31+
class Filter(tokenize):
32+
def __init__(self, tokenizer: _Filter) -> None: ...
33+
def __call__(self, *args: Any, **kwds: Any) -> tokenize: ...
34+
def _skip(self, word: str) -> bool: ...
35+
def _split(self, word: str) -> tokenize: ...
36+
class _TokenFilter(tokenize):
37+
def __init__(self, tokenizer: _Filter, skip: Callable[[str], bool], split: Callable[[str], tokenize]) -> None: ...
38+
39+
def wrap_tokenizer(tk1: _Filter, tk2: _Filter) -> Filter: ...
40+
41+
class URLFilter(Filter): ...
42+
class WikiWordFilter(Filter): ...
43+
class EmailFilter(Filter): ...
44+
class MentionFilter(Filter): ...
45+
class HashtagFilter(Filter): ...
46+
47+
class HTMLChunker(Chunker):
48+
def next(self) -> Token: ...
49+
50+
def get_tokenizer(tag: str = ..., chunkers: Iterable[Chunker] = ..., filters: Iterable[Filter] = ...) -> tokenize: ...
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from typing import Container
2+
3+
import enchant.tokenize
4+
5+
class tokenize(enchant.tokenize.tokenize):
6+
def __init__(self, text: str, valid_chars: Container[str] = ...) -> None: ...
7+
def next(self) -> enchant.tokenize.Token: ...

third_party/2and3/enchant/utils.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from typing import IO, Any, Callable, Iterable, List, Optional, Text, Tuple
2+
3+
from enchant.errors import *
4+
5+
def raw_unicode(raw: bytes) -> Text: ...
6+
def raw_bytes(raw: Any) -> bytes: ...
7+
8+
class EnchantStr(str):
9+
def __new__(cls, value: Any): ...
10+
def encode(self) -> bytes: ... # type: ignore
11+
def decode(self, value: Any) -> Text: ... # type: ignore
12+
13+
class UTF16EnchantStr(EnchantStr):
14+
REPLACEMENT_CHAR: str = ...
15+
def encode(self) -> bytes: ... # type: ignore
16+
17+
def printf(values: Iterable[Any], sep: str = ..., end: str = ..., file: IO[str] = ...) -> None: ...
18+
def levenshtein(s1: str, s2: str) -> int: ...
19+
def trim_suggestions(word: str, suggs: Iterable[str], maxlen: int, calcdist: Callable[[str, str], int] = ...) -> List[str]: ...
20+
def get_default_language(default: str = ...) -> str: ...
21+
def get_resource_filename(resname: str) -> str: ...
22+
def win32_data_files() -> List[Tuple[str, List[str]]]: ...

0 commit comments

Comments
 (0)