Skip to content
Open
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
2 changes: 2 additions & 0 deletions stubs/flashtext/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "2.7.*"
upstream-repository = "https://github.com/vi3k6i5/flashtext"
1 change: 1 addition & 0 deletions stubs/flashtext/flashtext/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .keyword import KeywordProcessor as KeywordProcessor
36 changes: 36 additions & 0 deletions stubs/flashtext/flashtext/keyword.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator, Mapping
from typing import Literal, overload

class KeywordProcessor:
case_sensitive: bool
non_word_boundaries: set[str]
keyword_trie_dict: dict[str, Incomplete]

def __init__(self, case_sensitive: bool = False) -> None: ...
def __len__(self) -> int: ...
def __contains__(self, word: str) -> bool: ...
def __getitem__(self, word: str) -> str | None: ...
def __setitem__(self, keyword: str, clean_name: str | None = None) -> bool: ...
def __delitem__(self, keyword: str) -> bool: ...
def __iter__(self) -> Iterator[str]: ...
def set_non_word_boundaries(self, non_word_boundaries: Iterable[str]) -> None: ...
def add_non_word_boundary(self, character: str) -> None: ...
def add_keyword(self, keyword: str, clean_name: str | None = None) -> bool: ...
def remove_keyword(self, keyword: str) -> bool: ...
def get_keyword(self, word: str) -> str | None: ...
def add_keyword_from_file(self, keyword_file: str, encoding: str = "utf-8") -> None: ...
def add_keywords_from_dict(self, keyword_dict: Mapping[str, Iterable[str]]) -> None: ...
def remove_keywords_from_dict(self, keyword_dict: Mapping[str, Iterable[str]]) -> None: ...
def add_keywords_from_list(self, keyword_list: Iterable[str]) -> None: ...
def remove_keywords_from_list(self, keyword_list: Iterable[str]) -> None: ...
def get_all_keywords(self, term_so_far: str = "", current_dict: dict[str, Incomplete] | None = None) -> dict[str, str]: ...

@overload
def extract_keywords(self, sentence: str, span_info: Literal[False] = False, max_cost: int = 0) -> list[str]: ...
@overload
def extract_keywords(self, sentence: str, span_info: Literal[True], max_cost: int = 0) -> list[tuple[str, int, int]]: ...

def replace_keywords(self, sentence: str, max_cost: int = 0) -> str: ...
def get_next_word(self, sentence: str) -> str: ...
def levensthein(self, word: str, max_cost: int = 2, start_node: dict[str, Incomplete] | None = None) -> set[Incomplete]: ...
Loading