--- dataset_info: features: - name: genre dtype: string - name: book_title dtype: string - name: fpath dtype: string - name: book_json dtype: string - name: author.first_name dtype: string - name: author.last_name dtype: string - name: author.middle_name dtype: string - name: langs.lang dtype: string - name: doc_info.nickname dtype: string - name: doc_info.email dtype: string - name: doc_info.date dtype: string - name: doc_info.doc_id dtype: string - name: doc_info.version dtype: string - name: doc_info.program_used dtype: string - name: langs.src_lang dtype: string - name: doc_info.src_url dtype: string - name: pub_info.book_name dtype: string - name: pub_info.publisher dtype: string - name: pub_info.city dtype: string - name: pub_info.year dtype: string - name: title_info.annotation dtype: string - name: pub_info.isbn dtype: string - name: pub_info.sequence dtype: string - name: title_info.keywords dtype: string splits: - name: train num_bytes: 351264228651 num_examples: 493378 download_size: 175655957118 dataset_size: 351264228651 configs: - config_name: default data_files: - split: train path: data/train-* --- # Librusec Books mostly in Russian from Librusec library. With original metadata. ``` DatasetDict({ train: Dataset({ features: ['genre', 'book_title', 'fpath', 'book_json', 'author.first_name', 'author.last_name', 'author.middle_name', 'langs.lang', 'doc_info.nickname', 'doc_info.email', 'doc_info.date', 'doc_info.doc_id', 'doc_info.version', 'doc_info.program_used', 'langs.src_lang', 'doc_info.src_url', 'pub_info.book_name', 'pub_info.publisher', 'pub_info.city', 'pub_info.year', 'title_info.annotation', 'pub_info.isbn', 'pub_info.sequence', 'title_info.keywords'], num_rows: 493378 }) }) ``` ## JSON Books are in JSON format: ``` [ { "body_title": [ "Жюльетта Бенцони", "Манчжурская принцесса" ], "epigraph": { "author": "Лао Цзы", "text": [ "«Нельзя идтии любоваться звездами, когда в твоем ботинке камень»." ] }, "sections": [ { "data": { "pars": [ "Июль 1918", "Вокзал в Шалон-сюр-Марн...", "Вдоль платформы длинной лентой вытянулись двадцать три вагона санитарного поезда, который вот-вот должен был тронуться. Занимавшиеся погрузкой раненых санитары оказывали им последние услуги, прежде чем передать на попечение медицинского персонала поезда, где позаботятся о них до Лиона.", "Весь день стояла жара, все вокруг было налито тяжестью. К пяти часам вечера разразившаяся гроза принесла долгожданную прохладу, с облегчением воспринятую всеми. ``` ## Format JSON as you need Example: ```python def format_book(doc): res = "" for body in doc: if 'body_title' in body: title = '\n\n'.join(body['body_title']) res += title res += '\n\n' if 'sections' in body: for section in body['sections']: if 'title' in section: sec_title = '\n\n'.join(section['title']) res += sec_title res += '\n\n' if 'data' in section and 'pars' in section['data']: for par in section['data']['pars']: res += f'{par}\n' else: # print('no pars', section) pass return res ```