Skip to content

Commit 1506829

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 bc6da51 commit 1506829

10 files changed

Lines changed: 269 additions & 0 deletions

File tree

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