<jupyter_start><jupyter_text>Jupyter Demo : Parsr API Access This demo provides a demo showing how one can process a document (pdf or image) using the Parsr pipeline's API interface to generate various outputs.  Module Import<jupyter_code>import parsr_api<jupyter_output><empty_output><jupyter_text>Send document for processing<jupyter_code>p = parsr_api.ParserApi('localhost:3001')
job = p.sendDocument('./sampleFile.pdf', './sampleConfig.json')
jobId = job['server_response']
job<jupyter_output><empty_output><jupyter_text>Query the queue for status<jupyter_code>p.getStatus(jobId)<jupyter_output><empty_output><jupyter_text>Get the Raw Text output<jupyter_code>txt_output = p.getText(jobId)['server_response']<jupyter_output><empty_output><jupyter_text>Get the Markdown output<jupyter_code>md_output = p.getMarkdown(jobId)['server_response']<jupyter_output><empty_output><jupyter_text>Get the full JSON output<jupyter_code>json_output = p.getJson(jobId)['server_response']<jupyter_output><empty_output><jupyter_text>Interpret the JSON output<jupyter_code>import parsr_output_interpreter as p
pa = p.ParsrOutputInterpreter(json_output)<jupyter_output><empty_output><jupyter_text>Get all the text on Page 1<jupyter_code>pa.getTexts(page_number=1)<jupyter_output><empty_output><jupyter_text>Get tables on the first page as pandas dataframes - TODO<jupyter_code># pa.getTables(page_number=1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10352112676056338, 'fraction_numerical': 0.004929577464788733, 'mean_word_length': 11.6875, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '9', 'dir': 'jupyter-structured-clean-dedup', 'id': '183253', 'license': 'Apache-2.0', 'n_tokens_mistral': 507, 'n_tokens_neox': 499, 'n_words': 85, 'path': 'demo/jupyter-notebook/Jupyter - API Access Demo.ipynb', 'repo_name': 'CheikhSambaM/Parsr', 'size': '1420'}