|
Download README.md from Toolster/ebook-format-samples: direct link, hf CLI and curl.
- Browser
- Download file 6.87 kB
-
https://huggingface.co/datasets/Toolster/ebook-format-samples/resolve/main/README.md
- Command line
-
hf download hf://datasets/Toolster/ebook-format-samples/README.md
-
curl -L -o README.md https://huggingface.co/datasets/Toolster/ebook-format-samples/resolve/main/README.md
6.87 kB
| license: cc0-1.0 | |
| pretty_name: E-book Format Samples | |
| language: | |
| - en | |
| - es | |
| - ru | |
| size_categories: | |
| - n<1K | |
| tags: | |
| - ebook | |
| - file-format | |
| - format-detection | |
| - test-fixtures | |
| - epub | |
| - mobi | |
| - fb2 | |
| - lit | |
| - lrf | |
| - pdb | |
| - text-extraction | |
| configs: | |
| - config_name: default | |
| data_files: metadata.csv | |
| # E-book Format Samples | |
| Four public-domain books, each converted into up to 23 e-book and document formats: 88 files in total. | |
| For every book there is also the XHTML source it was converted from and a plain-text ground truth, | |
| so you always know what a file is supposed to contain. | |
| ## Why this dataset | |
| Legal sample files of old e-book formats are hard to find. Search for a LIT, LRF or TCR file and you mostly get | |
| pirated books or files of unknown origin, with no idea what text is inside. Here the same known text exists in | |
| every format, which makes the set useful for: | |
| - **Testing format recognition.** File type detectors, MIME sniffing, ML classifiers of file types. Every row of | |
| `metadata.csv` gives the extension, MIME type, first 16 bytes and, for Palm database based files, the type/creator code. | |
| Several formats share a container (EPUB, KEPUB, DOCX, HTMLZ, TXTZ and PMLZ are all ZIP; MOBI, AZW3 and three PDB | |
| flavours are all Palm databases), which is exactly where detectors get confused. | |
| - **Developing converters and readers for rare formats.** LIT, LRF, TCR, SNB, RB, PMLZ, eReader, PalmDOC and zTXT | |
| files with a text you can check against. Good for writing a new parser, fixing an old one or adding a format to an | |
| existing reader. | |
| - **Measuring text extraction.** Compare what your parser gets out of a file with `ground_truth/<book>.txt`. | |
| Useful before feeding e-books into a search index or an LLM pipeline, where silent text loss is hard to notice. | |
| - **Regression tests for reading apps.** Illustrations, a footnote, block quotes, scene breaks, a table of contents, | |
| Cyrillic text, accented Spanish and a book made of several separate works. | |
| ## Books | |
| | id | Language | Text | Features | | |
| |---|---|---|---| | |
| | `alice_en` | English | Lewis Carroll, *Alice's Adventures in Wonderland*, chapters I-II (1865) | 2 illustrations by John Tenniel, italics, scene breaks | | |
| | `art_of_war_en` | English | Sun Tzu, *The Art of War*, chapter I, translated by Lionel Giles (1910) | footnote, commentary as block quotes, numbered paragraphs | | |
| | `quijote_es` | Spanish | Miguel de Cervantes, *Don Quijote de la Mancha*, chapters I-II (1605) | accented letters, ¡¿ punctuation, long chapter titles | | |
| | `chekhov_ru` | Russian | Anton Chekhov, three short stories (1883-1884) | Cyrillic, dialogue dashes, non-breaking spaces, three works in one book | | |
| ## Formats | |
| | variant | Format | Extension | | |
| |---|---|---| | |
| | `epub2`, `epub3` | EPUB 2 and EPUB 3 | .epub | | |
| | `kepub` | Kobo EPUB | .kepub | | |
| | `azw3` | Kindle KF8 | .azw3 | | |
| | `mobi7` | Mobipocket 6 (old MOBI) | .mobi | | |
| | `mobi_joint` | MOBI + KF8 in one file | .mobi | | |
| | `fb2` | FictionBook 2 | .fb2 | | |
| | `lit` | Microsoft Reader | .lit | | |
| | `lrf` | Sony BroadBand eBook | .lrf | | |
| | `pdb_ereader`, `pdb_palmdoc`, `pdb_ztxt` | Palm database: eReader, PalmDOC, zTXT | .pdb | | |
| | `rb` | RocketBook | .rb | | |
| | `tcr` | Psion TCR | .tcr | | |
| | `snb` | Shanda Bambook | .snb | | |
| | `pmlz` | eReader PML in ZIP | .pmlz | | |
| | `htmlz` | HTML in ZIP (Calibre) | .htmlz | | |
| | `txtz` | text in ZIP (Calibre) | .txtz | | |
| | `html_zip` | HTML in plain ZIP | .zip | | |
| | `txt` | plain text, UTF-8 | .txt | | |
| | `rtf` | Rich Text Format | .rtf | | |
| | `docx` | Word | .docx | | |
| | `pdf` | PDF | .pdf | | |
| Missing on purpose: `rb` for the Spanish and Russian books, and `pdb_ereader` and `pmlz` for the Russian book (see below). | |
| ## Layout | |
| ``` | |
| metadata.csv one row per file | |
| files/<book>/<book>.<variant>.<ext> the samples | |
| ground_truth/<book>.txt expected text of each book | |
| source/<book>/<book>.html XHTML source (+ images) all formats were made from | |
| ``` | |
| `metadata.csv` columns: `file_name`, `book_id`, `language`, `format`, `variant`, `extension`, `mime`, | |
| `text_encoding` (for 8-bit and text formats), `size_bytes`, `sha256`, `magic_hex` (first 16 bytes), | |
| `pdb_type_creator` (bytes 60-67 of Palm database files, such as `BOOKMOBI`, `TEXtREAd`, `PNRdPPrs`), | |
| `ground_truth`, `converter`, `options`, `roundtrip_word_recall`. | |
| MIME types follow common practice. Formats without any widely used MIME type (TCR, SNB, PMLZ, HTMLZ, TXTZ) | |
| are listed as `application/octet-stream`. | |
| ## How the files were made | |
| All files were produced from the XHTML sources with Calibre 9.17.0 (`ebook-convert`), chapters split on `<h2>`, | |
| title, author, language and year set as metadata. The exact extra options for each file are in the `options` column. | |
| - **8-bit formats.** PalmDOC and zTXT are written in cp1252 for the English and Spanish books and in cp1251 | |
| for the Russian one (see `text_encoding`). Read them with that code page. | |
| - **Gaps.** Calibre's PML writer, which is also used for eReader PDB, keeps only cp1252 and writes `?` for every | |
| Cyrillic letter, so those two files are not included for the Russian book. Calibre also writes RocketBook files | |
| for the Spanish and Russian texts that it cannot read back itself, so those were left out too. | |
| - **Round-trip check.** Every file was converted back to text with the same Calibre and compared with the ground truth. | |
| `roundtrip_word_recall` is the share of ground-truth words found in that text (lowest value in the set: 0.994). | |
| It is a sanity check that the file really contains the book, not a benchmark of other tools. | |
| Keep in mind that all samples come from one converter. Files made by the original vendor tools (Microsoft Reader, | |
| Sony, Mobipocket Creator, Kindle) can use features and quirks that Calibre does not produce. | |
| ## Ground truth | |
| UTF-8 plain text: title, author, then each chapter title and its paragraphs, separated by blank lines. | |
| The footnote reference is written as `[1]` and the note itself follows its chapter. Illustrations and scene | |
| breaks carry no text. Non-breaking spaces are replaced with ordinary spaces. | |
| ## Usage | |
| ```python | |
| from datasets import load_dataset | |
| from huggingface_hub import hf_hub_download | |
| meta = load_dataset("Toolster/ebook-format-samples", split="train") | |
| row = meta.filter(lambda r: r["variant"] == "lit")[0] | |
| path = hf_hub_download("Toolster/ebook-format-samples", row["file_name"], repo_type="dataset") | |
| truth = hf_hub_download("Toolster/ebook-format-samples", row["ground_truth"], repo_type="dataset") | |
| ``` | |
| ## Sources and license | |
| - Texts: Project Gutenberg eBooks #11, #132 and #2000 (only the chapters themselves were taken, without the Gutenberg | |
| header and license), and Russian Wikisource (Chekhov, Complete Works edition texts). | |
| All are in the public domain. | |
| - Illustrations: John Tenniel (1865), from Wikimedia Commons, public domain. | |
| - The converted files, ground truth and metadata are released under CC0 1.0. | |