Skip to main content

Finds and highlights text in documents

Project description

txtmarker: Highlight text in documents

Version GitHub Release Date GitHub issues GitHub last commit Build Status Coverage Status

demo

txtmarker highlights text in documents. txtmarker takes a list of (name, text) pairs, scan an input document and creates a modified version with highlights embedded.

Current file formats supported:

  • pdf

Installation

The easiest way to install is via pip and PyPI

pip install txtmarker

You can also install txtmarker directly from GitHub. Using a Python Virtual Environment is recommended.

pip install git+https://github.com/neuml/txtmarker

Python 3.6+ is supported

Examples

The examples directory has a series of examples and notebooks giving an overview of txtmarker. See the list of notebooks below.

Notebooks

Notebook Description
Introducing txtmarker Overview of the functionality provided by txtmarker Open In Colab
Highlighting with Transformers AI-driven highlighting with Transformers Open In Colab

Configuration

The following section gives an overview of highlighters and available methods/configuration. See the notebooks above for detailed examples.

Create a new highlighter

from txtmarker.factory import Factory
highlighter = Factory.create("pdf")

extension

extension: string

Type of highlighter to create (i.e. pdf)

Optional constructor arguments:

formatter

formatter: callable

Formats queries and input text using this method. Helps with cleanup of files with lots of symbols and other content.

chunks

chunks: int

Splits queries into multiple chunks. This is designed for very long text matches.

Highlight text

highlighter.highlight("input.pdf", "output.pdf", [("name", "text to highlight")])

infile

infile: string

Full path to input file

outfile

outfile: string

Full path to output file, i.e. the highlighted file

highlights

highlights: list of (string, string|regex)

List of highlight elements. Each pair has a name (can be None) and text value. The text can either be a string or a regular expression.

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

txtmarker-1.0.0.tar.gz (6.6 kB view hashes)

Uploaded Source

Built Distribution

txtmarker-1.0.0-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

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