ketab-ocr 1.0.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ketab_ocr/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """Ketab OCR: Persian OCR for printed text lines."""
2
+ from .ocr import KetabOCR
3
+
4
+ __all__ = ["KetabOCR"]
5
+ __version__ = "1.0.0"
ketab_ocr/bidi.py ADDED
@@ -0,0 +1,213 @@
1
+ """Reading order for mixed right-to-left / left-to-right text.
2
+
3
+ The model reads a line left to right, so its output is in visual order. `logical_from_visual`
4
+ turns that back into the order the text is read and stored in (Unicode bidi, UAX #9).
5
+ `visual_label` does the opposite and is used to check candidates.
6
+ """
7
+ from __future__ import annotations
8
+
9
+ import unicodedata
10
+
11
+ MIRROR = {"(": ")", ")": "(", "[": "]", "]": "[", "{": "}", "}": "{", "<": ">", ">": "<",
12
+ "«": "»", "»": "«", "‹": "›", "›": "‹"}
13
+ BRACKETS = {"(": ")", "[": "]", "{": "}"}
14
+
15
+
16
+ def logical_from_visual(visual: str) -> str:
17
+ """Visual (left-to-right) string -> logical reading order."""
18
+ if not _has_rtl(visual):
19
+ return visual
20
+ candidates = [_islands(visual, digits_join=True), _reverse_runs(visual), _islands(visual, digits_join=False)]
21
+ for base in (1, 0): # right-to-left paragraph first, then left-to-right
22
+ for candidate in candidates:
23
+ if visual_label(candidate, base) == visual:
24
+ return candidate
25
+ return candidates[0]
26
+
27
+
28
+ def visual_label(text: str, base: int = 1) -> str:
29
+ """Logical text -> the left-to-right order it is displayed in (base 1 = right-to-left paragraph)."""
30
+ levels = bidi_levels(text, base)
31
+ return "".join(MIRROR.get(text[i], text[i]) if levels[i] % 2 else text[i] for i in visual_order(levels))
32
+
33
+
34
+ def bidi_levels(text: str, base: int = 1) -> list[int]:
35
+ """Embedding level per character, following the UAX #9 rules named in the comments."""
36
+ n = len(text)
37
+ types = [unicodedata.bidirectional(c) or "ON" for c in text]
38
+ real = [i for i in range(n) if types[i] != "BN"] # X9: boundary neutrals (e.g. ZWNJ) are skipped
39
+ t = [types[i] for i in real]
40
+ sos = "R" if base % 2 else "L"
41
+ embedding = sos
42
+
43
+ for k, x in enumerate(t): # W1
44
+ if x == "NSM":
45
+ t[k] = t[k - 1] if k else sos
46
+ last = sos
47
+ for k, x in enumerate(t): # W2
48
+ if x in ("R", "L", "AL"):
49
+ last = x
50
+ elif x == "EN" and last == "AL":
51
+ t[k] = "AN"
52
+ t = ["R" if x == "AL" else x for x in t] # W3
53
+ for k in range(1, len(t) - 1): # W4
54
+ if t[k] == "ES" and t[k - 1] == "EN" and t[k + 1] == "EN":
55
+ t[k] = "EN"
56
+ elif t[k] == "CS" and t[k - 1] == t[k + 1] and t[k - 1] in ("EN", "AN"):
57
+ t[k] = t[k - 1]
58
+ for start, end in _runs(t, lambda x: x == "ET"): # W5
59
+ if (start > 0 and t[start - 1] == "EN") or (end < len(t) and t[end] == "EN"):
60
+ t[start:end] = ["EN"] * (end - start)
61
+ t = ["ON" if x in ("ES", "ET", "CS") else x for x in t] # W6
62
+ last = sos
63
+ for k, x in enumerate(t): # W7
64
+ if x in ("R", "L"):
65
+ last = x
66
+ elif x == "EN" and last == "L":
67
+ t[k] = "L"
68
+
69
+ # N0: a bracket pair takes the direction of the text inside it
70
+ chars = [text[i] for i in real]
71
+ for open_, close in sorted(_bracket_pairs(chars, t)):
72
+ inside = {_strong(x) for x in t[open_ + 1 : close]} - {None}
73
+ if not inside:
74
+ continue
75
+ if embedding in inside:
76
+ direction = embedding
77
+ else:
78
+ before = next((_strong(t[q]) for q in range(open_ - 1, -1, -1) if _strong(t[q])), sos)
79
+ direction = before
80
+ t[open_] = t[close] = direction
81
+
82
+ neutral = ("B", "S", "WS", "ON") # N1, N2
83
+ for start, end in _runs(t, lambda x: x in neutral):
84
+ before = _as_strong(t[start - 1]) if start > 0 else sos
85
+ after = _as_strong(t[end]) if end < len(t) else sos
86
+ t[start:end] = [before if before == after else embedding] * (end - start)
87
+
88
+ resolved = []
89
+ for x in t: # I1, I2
90
+ if base % 2 == 0:
91
+ resolved.append(base + (1 if x == "R" else 2 if x in ("AN", "EN") else 0))
92
+ else:
93
+ resolved.append(base + (1 if x in ("L", "EN", "AN") else 0))
94
+ levels = [base] * n
95
+ for i, level in zip(real, resolved):
96
+ levels[i] = level
97
+ for i in range(n): # boundary neutrals take their neighbour's level
98
+ if types[i] == "BN":
99
+ levels[i] = levels[i - 1] if i else (levels[i + 1] if i + 1 < n else base)
100
+ i = n - 1
101
+ while i >= 0 and types[i] in ("WS", "BN"): # L1: trailing white space goes to the base level
102
+ levels[i] = base
103
+ i -= 1
104
+ return levels
105
+
106
+
107
+ def visual_order(levels: list[int]) -> list[int]:
108
+ """L2: character indices in left-to-right display order."""
109
+ order = list(range(len(levels)))
110
+ odd = [level for level in levels if level % 2]
111
+ if not odd:
112
+ return order
113
+ for level in range(max(levels), min(odd) - 1, -1):
114
+ for start, end in _runs(order, lambda i: levels[i] >= level):
115
+ order[start:end] = order[start:end][::-1]
116
+ return order
117
+
118
+
119
+ def _strong(x: str) -> str | None:
120
+ return "R" if x in ("R", "EN", "AN") else "L" if x == "L" else None
121
+
122
+
123
+ def _as_strong(x: str) -> str:
124
+ """N1: numbers count as right-to-left."""
125
+ return "R" if x in ("R", "EN", "AN") else x
126
+
127
+
128
+ def _runs(items: list, test) -> list[tuple[int, int]]:
129
+ """(start, end) of each maximal stretch of items passing `test`."""
130
+ runs, start = [], None
131
+ for k, item in enumerate(items):
132
+ if test(item):
133
+ start = k if start is None else start
134
+ elif start is not None:
135
+ runs.append((start, k))
136
+ start = None
137
+ if start is not None:
138
+ runs.append((start, len(items)))
139
+ return runs
140
+
141
+
142
+ def _bracket_pairs(chars: list[str], types: list[str]) -> list[tuple[int, int]]:
143
+ stack, pairs = [], []
144
+ for k, ch in enumerate(chars):
145
+ if types[k] != "ON":
146
+ continue
147
+ if ch in BRACKETS:
148
+ if len(stack) < 63:
149
+ stack.append((BRACKETS[ch], k))
150
+ elif ch in BRACKETS.values():
151
+ for depth in range(len(stack) - 1, -1, -1):
152
+ if stack[depth][0] == ch:
153
+ pairs.append((stack[depth][1], k))
154
+ del stack[depth:]
155
+ break
156
+ return pairs
157
+
158
+
159
+ def _has_rtl(s: str) -> bool:
160
+ return any(unicodedata.bidirectional(c) in ("R", "AL") for c in s)
161
+
162
+
163
+ def _reverse_runs(visual: str) -> str:
164
+ """Candidate: reverse the whole line, then restore the order of its left-to-right runs."""
165
+ reversed_ = [MIRROR.get(c, c) for c in visual[::-1]]
166
+ levels = bidi_levels("".join(reversed_), 1)
167
+ out, i = [], 0
168
+ while i < len(reversed_):
169
+ if levels[i] % 2 == 0:
170
+ j = i
171
+ while j < len(reversed_) and levels[j] % 2 == 0:
172
+ j += 1
173
+ out += [MIRROR.get(c, c) for c in reversed_[i:j][::-1]]
174
+ i = j
175
+ else:
176
+ out.append(reversed_[i])
177
+ i += 1
178
+ return "".join(out)
179
+
180
+
181
+ def _islands(visual: str, digits_join: bool = True) -> str:
182
+ """Candidate: reverse the line but keep each left-to-right stretch (Latin words, numbers and
183
+ the punctuation between them) together and in its own order."""
184
+ def kind(c: str) -> str:
185
+ b = unicodedata.bidirectional(c)
186
+ if b == "L" or (digits_join and b in ("EN", "AN")):
187
+ return "ltr"
188
+ if b in ("R", "AL"):
189
+ return "rtl"
190
+ return "digit" if b in ("EN", "AN") else "neutral"
191
+
192
+ kinds = [kind(c) for c in visual]
193
+ tokens, i = [], 0
194
+ while i < len(visual):
195
+ if kinds[i] in ("ltr", "digit"):
196
+ k, j, last = kinds[i], i, i
197
+ while j < len(visual) and kinds[j] != "rtl" and not (kinds[j] in ("ltr", "digit") and kinds[j] != k):
198
+ if kinds[j] == k:
199
+ last = j
200
+ j += 1
201
+ # a stretch that opens a bracket also takes its closing bracket
202
+ while last + 1 < len(visual) and visual[last + 1] in ")]}" and _open_brackets(visual[i : last + 1]) > 0:
203
+ last += 1
204
+ tokens.append(visual[i : last + 1])
205
+ i = last + 1
206
+ else:
207
+ tokens.append(MIRROR.get(visual[i], visual[i]))
208
+ i += 1
209
+ return "".join(reversed(tokens))
210
+
211
+
212
+ def _open_brackets(s: str) -> int:
213
+ return sum(s.count(o) - s.count(c) for o, c in ("()", "[]", "{}"))
ketab_ocr/cli.py ADDED
@@ -0,0 +1,24 @@
1
+ """Command line: ketab-ocr line1.png line2.png"""
2
+ import argparse
3
+
4
+ from . import __version__
5
+ from .ocr import DEFAULT_VERSION, KetabOCR
6
+
7
+
8
+ def main(argv=None):
9
+ parser = argparse.ArgumentParser(prog="ketab-ocr", description="Read printed Persian text line images.")
10
+ parser.add_argument("images", nargs="+", help="images of single text lines")
11
+ parser.add_argument("--version", default=DEFAULT_VERSION, help=f"model version (default: {DEFAULT_VERSION})")
12
+ parser.add_argument("--model", help="path to a local .onnx model instead of downloading one")
13
+ parser.add_argument("--no-crop", action="store_true", help="do not cut oversized blank margins")
14
+ parser.add_argument("-V", action="version", version=f"ketab-ocr {__version__}")
15
+ args = parser.parse_args(argv)
16
+
17
+ ocr = KetabOCR(args.model) if args.model else KetabOCR.from_hub(args.version)
18
+ texts = ocr.read_many(args.images, crop=not args.no_crop)
19
+ for path, text in zip(args.images, texts):
20
+ print(text if len(args.images) == 1 else f"{path}\t{text}")
21
+
22
+
23
+ if __name__ == "__main__":
24
+ main()
ketab_ocr/ocr.py ADDED
@@ -0,0 +1,132 @@
1
+ """Line recognizer: image of one printed text line in, Persian text out."""
2
+ from __future__ import annotations
3
+
4
+ import json
5
+ import os
6
+ from pathlib import Path
7
+ from typing import Iterable, Union
8
+
9
+ import cv2
10
+ import numpy as np
11
+ import onnxruntime as ort
12
+ from PIL import Image
13
+
14
+ from .bidi import logical_from_visual
15
+
16
+ HUB_REPO = "iw4p/ketab-ocr"
17
+ DEFAULT_VERSION = "v3"
18
+ LINE_HEIGHT = 48 # used when a model does not say which line height it reads
19
+ MAX_WIDTH = 1600 # longer lines are squeezed to this width
20
+ BATCH_PIXELS = 64 * 1024
21
+ PAD_RIGHT = 16 # blank columns after each line, as the model saw in training
22
+
23
+ ImageLike = Union[str, Path, Image.Image, np.ndarray]
24
+
25
+
26
+ class KetabOCR:
27
+ """Persian OCR for printed text lines.
28
+
29
+ >>> ocr = KetabOCR.from_hub() # downloads the default model once, then uses the cache
30
+ >>> ocr.read("line.png")
31
+ """
32
+
33
+ def __init__(self, model_path: str | Path, threads: int | None = None):
34
+ options = ort.SessionOptions()
35
+ if threads:
36
+ options.intra_op_num_threads = threads
37
+ self.session = ort.InferenceSession(str(model_path), options, providers=["CPUExecutionProvider"])
38
+ meta = self.session.get_modelmeta().custom_metadata_map
39
+ self.alphabet = json.loads(meta["alphabet"])
40
+ self.version = meta.get("version", "unknown")
41
+ self.line_height = int(meta.get("line_height", LINE_HEIGHT))
42
+
43
+ @classmethod
44
+ def from_hub(cls, version: str = DEFAULT_VERSION, repo_id: str = HUB_REPO, **kwargs) -> "KetabOCR":
45
+ """Load a model version (e.g. "v3", "v4") from the Hugging Face Hub."""
46
+ from huggingface_hub import hf_hub_download
47
+
48
+ return cls(hf_hub_download(repo_id, f"models/{version}.onnx"), **kwargs)
49
+
50
+ def read(self, image: ImageLike, crop: bool = True) -> str:
51
+ """Read one text line. `image` is a path, a PIL image or a numpy array."""
52
+ return self.read_many([image], crop=crop)[0]
53
+
54
+ def read_many(self, images: Iterable[ImageLike], crop: bool = True) -> list[str]:
55
+ """Read many text lines; lines of similar width are batched together."""
56
+ inputs = [preprocess(image, crop, self.line_height) for image in images]
57
+ results = [""] * len(inputs)
58
+ for batch in _batches(inputs):
59
+ width = _round_up(max(inputs[i].shape[1] for i in batch) + PAD_RIGHT, 4)
60
+ x = np.zeros((len(batch), 1, self.line_height, width), np.float32)
61
+ for row, i in enumerate(batch):
62
+ x[row, 0, :, : inputs[i].shape[1]] = inputs[i]
63
+ widths = np.array([inputs[i].shape[1] for i in batch], np.int64)
64
+ logprobs, lengths = self.session.run(None, {"image": x, "widths": widths})
65
+ for row, i in enumerate(batch):
66
+ visual = self._decode(logprobs[row, : lengths[row]])
67
+ results[i] = logical_from_visual(visual).strip()
68
+ return results
69
+
70
+ def _decode(self, logprobs: np.ndarray) -> str:
71
+ """Greedy CTC decoding (class 0 is the blank). The result is in left-to-right visual order."""
72
+ chars, previous = [], 0
73
+ for k in logprobs.argmax(-1):
74
+ if k != previous and k != 0:
75
+ chars.append(self.alphabet[k - 1])
76
+ previous = k
77
+ return "".join(chars)
78
+
79
+
80
+ def preprocess(image: ImageLike, crop: bool = True, line_height: int = LINE_HEIGHT) -> np.ndarray:
81
+ """Grayscale, cut oversized margins, scale to `line_height`; ink is 1, paper is 0."""
82
+ gray = to_gray(image)
83
+ if crop:
84
+ gray = trim_margins(gray)
85
+ h, w = gray.shape
86
+ new_width = max(8, min(MAX_WIDTH, round(w * line_height / h)))
87
+ resized = cv2.resize(gray, (new_width, line_height), interpolation=cv2.INTER_AREA)
88
+ return 1.0 - resized.astype(np.float32) / 255.0
89
+
90
+
91
+ def to_gray(image: ImageLike) -> np.ndarray:
92
+ if isinstance(image, (str, os.PathLike)):
93
+ image = Image.open(image)
94
+ if isinstance(image, np.ndarray):
95
+ if image.ndim == 2:
96
+ return image.astype(np.uint8)
97
+ image = Image.fromarray(image[..., :3].astype(np.uint8))
98
+ return np.asarray(image.convert("L"))
99
+
100
+
101
+ def trim_margins(gray: np.ndarray, vertical: float = 0.6, horizontal: float = 1.5) -> np.ndarray:
102
+ """Cut blank margins larger than `vertical` / `horizontal` times the text height.
103
+
104
+ The model was trained on lines cropped close to the text; very wide margins hurt it,
105
+ normal ones do not, so normal margins are left as they are.
106
+ """
107
+ lo, hi = int(gray.min()), int(gray.max())
108
+ if hi - lo < 40: # blank or no contrast
109
+ return gray
110
+ ink = gray < (lo + hi) / 2
111
+ rows, cols = np.flatnonzero(ink.any(axis=1)), np.flatnonzero(ink.any(axis=0))
112
+ top, bottom, left, right = rows[0], rows[-1] + 1, cols[0], cols[-1] + 1
113
+ text_height = bottom - top
114
+ pad_v = max(2, int(round(vertical * text_height)))
115
+ pad_h = max(2, int(round(horizontal * text_height)))
116
+ return gray[max(0, top - pad_v) : bottom + pad_v, max(0, left - pad_h) : right + pad_h]
117
+
118
+
119
+ def _batches(inputs: list[np.ndarray]) -> Iterable[list[int]]:
120
+ """Indices grouped by similar width, each group at most BATCH_PIXELS wide in total."""
121
+ order = sorted(range(len(inputs)), key=lambda i: inputs[i].shape[1])
122
+ start = 0
123
+ while start < len(order):
124
+ end = start + 1
125
+ while end < len(order) and (end - start + 1) * inputs[order[end]].shape[1] <= BATCH_PIXELS:
126
+ end += 1
127
+ yield order[start:end]
128
+ start = end
129
+
130
+
131
+ def _round_up(n: int, multiple: int) -> int:
132
+ return -(-n // multiple) * multiple
@@ -0,0 +1,134 @@
1
+ Metadata-Version: 2.5
2
+ Name: ketab-ocr
3
+ Version: 1.0.0
4
+ Summary: Fast, accurate OCR for printed Persian text lines (ONNX, CPU)
5
+ Project-URL: Homepage, https://github.com/iw4p/ketab-ocr
6
+ Project-URL: Models, https://huggingface.co/iw4p/ketab-ocr
7
+ Author: iw4p
8
+ License-Expression: Apache-2.0
9
+ License-File: LICENSE
10
+ Keywords: farsi,ocr,onnx,persian,text-recognition
11
+ Classifier: Natural Language :: Persian
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
15
+ Requires-Python: >=3.10
16
+ Requires-Dist: huggingface-hub
17
+ Requires-Dist: numpy
18
+ Requires-Dist: onnxruntime
19
+ Requires-Dist: opencv-python-headless
20
+ Requires-Dist: pillow
21
+ Provides-Extra: test
22
+ Requires-Dist: pytest; extra == 'test'
23
+ Description-Content-Type: text/markdown
24
+
25
+ # Ketab OCR – Persian OCR
26
+
27
+ Fast, accurate OCR for printed Persian text lines. Small (5.6 M parameters), runs on CPU with ONNX Runtime,
28
+ about 50 lines per second on a laptop.
29
+
30
+ ```bash
31
+ pip install ketab-ocr
32
+ ```
33
+
34
+ ```python
35
+ from ketab_ocr import KetabOCR
36
+
37
+ ocr = KetabOCR.from_hub() # downloads the model once (v3, default)
38
+ print(ocr.read("line.png")) # a path, a PIL image or a numpy array
39
+ print(ocr.read_many(["line1.png", "line2.png"]))
40
+ ```
41
+
42
+ Or from the command line:
43
+
44
+ ```bash
45
+ ketab-ocr line.png
46
+ ```
47
+
48
+ **Input:** an image of one text line, dark text on a light background. Oversized blank margins are cut off
49
+ automatically (`crop=False` turns that off). Full pages must be split into lines first; page layout is not
50
+ included yet.
51
+
52
+ ## Examples
53
+
54
+ Each image below is read with the default model (`v3`):
55
+
56
+ ![Example 1](https://raw.githubusercontent.com/iw4p/ketab-ocr/main/assets/example_1.png)
57
+
58
+ ```text
59
+ کتاب خواندن بهترین راه برای یادگیری است.
60
+ ```
61
+
62
+ ![Example 2](https://raw.githubusercontent.com/iw4p/ketab-ocr/main/assets/example_2.png)
63
+
64
+ ```text
65
+ این کتاب در سال ۱۴۰۲ با قیمت ۲۵۰٬۰۰۰ تومان چاپ شد.
66
+ ```
67
+
68
+ ![Example 3](https://raw.githubusercontent.com/iw4p/ketab-ocr/main/assets/example_3.png)
69
+
70
+ ```text
71
+ نسخهٔ جدید Python 3.13 را نصب کنید (رایگان است).
72
+ ```
73
+
74
+ Mixed Persian and English text, numbers and brackets come out in reading order.
75
+
76
+ ## Models
77
+
78
+ Models live on Hugging Face: [iw4p/ketab-ocr](https://huggingface.co/iw4p/ketab-ocr). Every version stays
79
+ available, so you can pin one. A new version can be used as soon as it is on Hugging Face, without
80
+ updating the library:
81
+
82
+ ```python
83
+ ocr = KetabOCR.from_hub("v4")
84
+ ocr = KetabOCR("path/to/v3.onnx") # or a local file
85
+ ```
86
+
87
+ | version | note |
88
+ |---|---|
89
+ | `v3` | default; best on modern print and numbers |
90
+ | `v4` | best on mixed fonts and old books; a zero drawn as a small circle can be read as ۵ |
91
+
92
+ ## Train on your own data
93
+
94
+ Fine-tune a released model on your own line images (a laptop is enough for a few thousand lines):
95
+
96
+ ```bash
97
+ git clone https://github.com/iw4p/ketab-ocr && cd ketab-ocr
98
+ pip install -r train/requirements.txt
99
+ python train/finetune.py --data my_lines --out my-model.onnx
100
+ ```
101
+
102
+ `my_lines/labels.tsv` lists one image per line: `<file name><TAB><text>`. The script starts from `v3`
103
+ (`--base v4` or a `.safetensors` file from an earlier run also work), keeps the best epoch and writes
104
+ `my-model.onnx` for the library plus `my-model.safetensors` to fine-tune further.
105
+
106
+ ```python
107
+ ocr = KetabOCR("my-model.onnx")
108
+ ```
109
+
110
+ You can share it on Hugging Face as `models/v1.onnx` in your own repo, and others load it with
111
+ `KetabOCR.from_hub("v1", repo_id="you/your-repo")`.
112
+
113
+ ## Benchmarks
114
+
115
+ Character error rate on public test sets (lower is better). Details and the full table are on the
116
+ [model page](https://huggingface.co/iw4p/ketab-ocr#benchmarks).
117
+
118
+ ![Benchmarks](https://raw.githubusercontent.com/iw4p/ketab-ocr/main/assets/benchmarks.png)
119
+
120
+ ## Limits
121
+
122
+ - Printed text only, one line at a time (no handwriting, no page layout yet).
123
+ - A long run of the same digit (۰۰۰) can now and then lose one digit.
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ pip install -e ".[test]"
129
+ pytest
130
+ ```
131
+
132
+ ## License
133
+
134
+ Apache-2.0, code and models.
@@ -0,0 +1,9 @@
1
+ ketab_ocr/__init__.py,sha256=rtZFuslV16d5kSMDyc57sF-B0cXvjIUa1XuU9IJrCYo,125
2
+ ketab_ocr/bidi.py,sha256=g2ORwRlJj4N34Qe2Ox4CEI8Dg2zXnBRckE7glIxlxnM,8103
3
+ ketab_ocr/cli.py,sha256=uX_ovrVBruhWk4Upmly187DHjsYE_Y8g_ng2_GEEAT8,1081
4
+ ketab_ocr/ocr.py,sha256=hfU6K6faXmoMlimKS1hkXDUDHX_UwrUH6aqC21l-3Nw,5555
5
+ ketab_ocr-1.0.0.dist-info/METADATA,sha256=EPUQwzIwA_L4wMzBs8x0Wfjw0RJU-fVAA-3Qw3XPe3c,4117
6
+ ketab_ocr-1.0.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
7
+ ketab_ocr-1.0.0.dist-info/entry_points.txt,sha256=bQof-Q_xBWOFDTTtFnlZgJJ0-CwOALXM0vC4govtBOc,49
8
+ ketab_ocr-1.0.0.dist-info/licenses/LICENSE,sha256=0vPp8V2vhag7WH5Jy48qxRFtqeNnrsge80u4BhBRBqE,11335
9
+ ketab_ocr-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ketab-ocr = ketab_ocr.cli:main
@@ -0,0 +1,202 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 iw4p
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
202
+