MCPcopy Create free account
hub / github.com/KoljaB/RealtimeVoiceChat / __init__

Method __init__

code/text_context.py:15–31  ·  view source on GitHub ↗

Initializes the TextContext processor. Sets up the characters used to determine valid context boundaries. Args: split_tokens: An optional set of strings. Each string is treated as a potential end-of-context marker. If None, a default s

(self, split_tokens: Optional[Set[str]] = None)

Source from the content-addressed store, hash-verified

13 of alphanumeric characters.
14 """
15 def __init__(self, split_tokens: Optional[Set[str]] = None) -> None:
16 """
17 Initializes the TextContext processor.
18
19 Sets up the characters used to determine valid context boundaries.
20
21 Args:
22 split_tokens: An optional set of strings. Each string is treated as a
23 potential end-of-context marker. If None, a default set
24 of punctuation and whitespace characters is used.
25 """
26 if split_tokens is None:
27 # Using a more explicit variable name internally for clarity
28 default_splits: Set[str] = {".", "!", "?", ",", ";", ":", "\n", "-", "。", "、"}
29 self.split_tokens: Set[str] = default_splits
30 else:
31 self.split_tokens: Set[str] = set(split_tokens)
32
33 def get_context(self, txt: str, min_len: int = 6, max_len: int = 120, min_alnum_count: int = 10) -> Tuple[Optional[str], Optional[str]]:
34 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected