Skip to main content

Bloatectomy: a method for the identification and removal of duplicate text in the bloated notes of electronic health records and other documents.

Project description

Bloatectomy

Bloatectomy: a method for the identification and removal of duplicate text in the bloated notes of electronic health records and other documents. Takes in a list of notes or a single file (.docx, .txt, .rtf, etc) or single string to be marked for duplicates. Marked output and tokens are output.

Requirements

  • Python>=3.7.x (in order for the regular expressions to work correctly)
  • re
  • sys
  • pandas (optional, only necessary if using MIMIC III data)
  • docx (optional, only necessary if input or output is a word/docx file)

Installation

using anaconda or miniconda

conda install -c summerkrankin bloatectomy

using pip via PyPI
make sure to install it to python3 if your default is python2

python3 -m pip install bloatectomy

using pip via github

python3 -m pip install git+git://github.com/MIT-LCP/mimic-code TBA

manual install by cloning the repository

git clone git://github.com/MIT-LCP/mimic-code TBA
cd bloatectomy
python3 setup.py install

Examples

To run bloatectomy on a sample string with the following options:

  • highlighting duplicates
  • display raw results
  • output file as html
  • output file of numbered tokens:
from bloatectomy import bloatectomy

text = '''Assessment and Plan
61 yo male Hep C cirrhosis
Abd pain:
-other labs: PT / PTT / INR:16.6//    1.5, CK / CKMB /
ICU Care
-other labs: PT / PTT / INR:16.6//  1.5, CK / CKMB /
Assessment and Plan
'''

bloatectomy(text, style='highlight', display=True, filename='sample_txt_highlight_output', output='html', output_numbered_tokens=True)

To use with example text or load ipynb examples, download the repository or just the bloatectomy_examples folder

cd bloatectomy_examples
from bloatectomy import bloatectomy

bloatectomy('./input/sample_text.txt',
            style='highlight', display=False,
            filename='./output/sample_txt_highlight_output',
            output='html',
            output_numbered_tokens=True,
            output_original_tokens=True)

Documentation

The paper is located at TBA

class bloatectomy(input_text,
                  path = '',
                  filename='bloatectomized_file',
                  display=False,
                  style='highlight',
                  output='html',
                  output_numbered_tokens=False,
                  output_original_tokens=False,
                  regex1=r"(.+?\.[\s\n]+)",
                  regex2=r"(?=\n\s*[A-Z1-9#-]+.*)",
                  postgres_engine=None,
                  postgres_table=None)

Parameters

input_text: file, str, list
An input document (.txt, .rtf, .docx), a string of text, or list of hadm_ids for postgres mimiciii database or the raw text.

style: str, optional, default=highlight
Method for denoting a duplicate. The following are allowed: highlight, bold, remov.

filename: str, optional, default=bloatectomized_file A string to name output file of the bloat-ectomized document.

path: str, optional, default=' '
The directory for output files.

output_numbered_tokens: bool, optional, default=False
If set to True, a .txt file with each token enumerated and marked for duplication, is output as [filename]_token_numbers.txt. This is useful when diagnosing your own regular expression for tokenization or testing the remov option for style.

output_original_tokens: bool, optional, default=False
If set to True, a .txt file with each original (non-marked) token enumerated but not marked for duplication, is output as [filename]_original_token_numbers.txt.

display: bool, optional, default=False
If set to True, the bloatectomized text will display in the console on completion.

regex1: str, optional, default=r"(.+?\.[\s\n]+)"
The regular expression for the first tokenization. Split on a period (.) followed by one or more white space characters (space, tab, line breaks) or a line feed character (\n). This can be replaced with any valid regular expression to change the way tokens are created.

regex2: str, optional, default=r"(?=\n\s*[A-Z1-9#-]+.*)"
The regular expression for the second tokenization. Split on any newline character (\n) followed by an uppercase letter, a number, or a dash. This can be replaced with any valid regular expression to change how sub-tokens are created.

postgres_engine: str, optional The postgres connection. Only relevant for use with the MIMIC III dataset. When using this option, do not invoke a filename and it will name each file with the hadm_id. See the jupyter notebook mimic_bloatectomy_example for the example code.

postgres_table: str, optional The name of the postgres table containing the concatenated notes. Only relevant for use with the MIMIC III dataset. When using this option, do not invoke a filename and it will name each file with the hadm_id. See the jupyter notebook mimic_bloatectomy_example for the example code.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bloatectomy-0.0.11.tar.gz (16.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bloatectomy-0.0.11-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file bloatectomy-0.0.11.tar.gz.

File metadata

  • Download URL: bloatectomy-0.0.11.tar.gz
  • Upload date:
  • Size: 16.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for bloatectomy-0.0.11.tar.gz
Algorithm Hash digest
SHA256 d9df69119581a5266058b9270d8851350c394cc28248f3eb9e3347445d68abdb
MD5 65d618851c2584be59847a67dd468dbb
BLAKE2b-256 1309f91e59e3f5e7e800f5c204fe1c9442472ba1d667e527b859d6e46c631d4f

See more details on using hashes here.

File details

Details for the file bloatectomy-0.0.11-py3-none-any.whl.

File metadata

  • Download URL: bloatectomy-0.0.11-py3-none-any.whl
  • Upload date:
  • Size: 17.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6

File hashes

Hashes for bloatectomy-0.0.11-py3-none-any.whl
Algorithm Hash digest
SHA256 406c3e498426f1ad71e0fa135d2cb52a63b84e05e9fc27bf39d4f227aa5d7691
MD5 f94fc0047aed00242a612ef54e204010
BLAKE2b-256 993eab466e1b9c980782f686ccd8e8e1d21a6d34e0d94580b817e624f9ebaa69

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page