"""OpenGlyph-OCR-IDS: read one line of printed scholarly Chinese that holds rare characters, glyphs without a code point and characters no catalogue has. (MLX, Apple silicon. Run from a local copy of the repository this package lies in.) python -m openglyph_ocr_ids LINE.png [LINE2.png ...] [--options] from openglyph_ocr_ids import load, read_line, atoms ocr = load() # the folder that holds this package; or load('/path/to/the/folder') out = read_line(ocr, 'line.png') print(out['text']) # 𤪷也庾參與⿰拍嵩了燒造磚瓦的工作 out = read_line(ocr, 'line.png', options=True) print(out['options']) # the second option of every place that has one What comes back (read_line): text Unicode text; a glyph without a code point that GlyphWiki has is written (its GlyphWiki name); a glyph that has neither is written IDS, an Ideographic Description Sequence the model composed ids every IDS the model wrote and what it spells: a coded character (a rare character read by its parts), a glyph with a token, or a new glyph options with options=True: beside the text, the other reading of every place that has one The picture: one horizontal line of print as cropped from a page (the lines measured are about 100 to 150 pixels high in the papers, 96 in the special test). A whole page can be read in one go with read_page(ocr, 'page.png') (or --page): it is then read as OpenGlyph-OCR-0 reads, without IDS; cutting the page into lines reads better. How a line is read. Four sets of weights work in one model built on Xiaomi-OCR-0: the reader (OpenGlyph-OCR-0, unchanged) writes the line; the opener says where a glyph needs an IDS; at such a place, and wherever the reader itself writes a rare character or a glyph token, the glyph is read two more ways -- unfolded (cut into its parts by a program, the parts read by the part reader) and spelt (by the speller, from the glyph as it stands); what stands is decided by both and by gates chosen on tuning lines (reading.json). The modules: build (the model, the interface), unfold (the reading of a line), spell (the speller), unfold_cut and unfold_search (the cuts), canon (canonical forms), decode (constrained decoding). The versions matter: this was measured with mlx 0.32.3, mlx-vlm 0.3.12, transformers 5.18.0, tokenizers 0.23.2 (requirements.txt); torch and torchvision are there for the pictures only (with torchvision, transformers prepares them as they were prepared when the model was measured).""" from .build import load,read_line,read_page,readable,atoms __all__=['load','read_line','read_page','readable','atoms']