mirror of
https://git.pumpin.online/funkpower/catena.git
synced 2026-10-23 03:07:13 +00:00
bindings: the libraries in process, for Python
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""The catena libraries, in process.
|
||||
|
||||
Every function here is the same code the command-line tool runs, and hands
|
||||
back the same record shapes it writes to stdout — dictionaries rather than
|
||||
lines of JSON.
|
||||
|
||||
>>> import catena
|
||||
>>> chunks = catena.chunk_markdown(markdown, target=512)
|
||||
>>> chunks[0]["page"]
|
||||
41
|
||||
"""
|
||||
|
||||
from ._catena import (
|
||||
__version__,
|
||||
chunk_markdown,
|
||||
count_tokens,
|
||||
fuse_hits,
|
||||
identify,
|
||||
pack_cues,
|
||||
parse_subtitles,
|
||||
scrub,
|
||||
split_collection,
|
||||
)
|
||||
|
||||
__all__ = [
|
||||
"__version__",
|
||||
"chunk_markdown",
|
||||
"count_tokens",
|
||||
"fuse_hits",
|
||||
"identify",
|
||||
"pack_cues",
|
||||
"parse_subtitles",
|
||||
"scrub",
|
||||
"split_collection",
|
||||
]
|
||||
@@ -0,0 +1,32 @@
|
||||
from typing import Any, Iterable, Mapping, Sequence
|
||||
|
||||
__version__: str
|
||||
|
||||
def chunk_markdown(
|
||||
markdown: str,
|
||||
*,
|
||||
target: int | None = ...,
|
||||
overlap: int | None = ...,
|
||||
min_tokens: int | None = ...,
|
||||
hard_max: int | None = ...,
|
||||
) -> list[dict[str, Any]]: ...
|
||||
def scrub(markdown: str, *, pages: bool = ...) -> str: ...
|
||||
def count_tokens(text: str) -> int: ...
|
||||
def parse_subtitles(
|
||||
content: str, *, keep_repeats: bool = ...
|
||||
) -> list[dict[str, Any]]: ...
|
||||
def pack_cues(
|
||||
cues: Iterable[Mapping[str, Any]],
|
||||
*,
|
||||
seconds: float | None = ...,
|
||||
max_tokens: int | None = ...,
|
||||
) -> list[dict[str, Any]]: ...
|
||||
def split_collection(markdown: str) -> list[dict[str, Any]]: ...
|
||||
def fuse_hits(
|
||||
hits: Iterable[Mapping[str, Any]],
|
||||
*,
|
||||
k: float | None = ...,
|
||||
weights: Mapping[str, float] | None = ...,
|
||||
limit: int | None = ...,
|
||||
) -> list[dict[str, Any]]: ...
|
||||
def identify(name: str, data: bytes) -> dict[str, Any]: ...
|
||||
Reference in New Issue
Block a user