Skip to main content

Text Highlighter

A Streamlit component for annotating text using text highlighting. Useful for NLP tasks.

Installation

You can install the Text Highlighter package using the following command:

pip install --upgrade text-highlighter

Usage

The package can be used as follows:

from text_highlighter import text_highlighter
import streamlit as st

# Basic usage
result = text_highlighter(
    text="John Doe is the founder of MyComp Inc. and lives in New York with his wife Jane Doe.",
    labels=[("PERSON", "red"), ("ORG", "#0000FF")],
    # Optionally you can specify pre-existing annotations:
    annotations=[
        {"start": 0, "end": 8, "tag": "PERSON"},
        {"start": 27, "end": 38, "tag": "ORG"},
        {"start": 75, "end": 83, "tag": "PERSON"},
    ],
)

# Show the results (in XML format)
st.code(result.to_xml())

# Show the results (as a list)
st.write(result)

In the example.py script you can find the above example. You can run the example as follows:

streamlit run example.py

The output will look like this:

Example

Deployment

Run the following to build the front-end:

cd text_highlighter/frontend
npm run build

After that, you can build the package using the following command from the root directory:

python -m build

And then you can deploy it to PyPI using the following command:

twine upload dist/*

Contribute

Feel free to add a pull request or open an issue if you have any questions or suggestions.

Metadata

Release files for text-highlighter-hilton 0.0.16.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for text-highlighter-hilton 0.0.16.2
File Size Uploaded
text_highlighter_hilton-0.0.16.2.tar.gz 1.0 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for text-highlighter-hilton 0.0.16.2
File Interpreter ABI Platform
text_highlighter_hilton-0.0.16.2-py3-none-any.whl Python 3 none any Details

Total release size: 1.9 MB

Release files / text_highlighter_hilton-0.0.16.2.tar.gz

Download URL text_highlighter_hilton-0.0.16.2.tar.gz
Size 1.0 MB
Tags Source
SHA-256 checksum
How to use checksums
88ab376db0c443360936245da8d2a2e67060782d09d846eef22cb6c816c857cf
BLAKE2b-256 checksum
How to use checksums
022e8e62c84b7f63f8e028ab307bc2c2d39dc9d3a9a1b2b6e5095f66eaf2dc45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.6

Release files / text_highlighter_hilton-0.0.16.2-py3-none-any.whl

Download URL text_highlighter_hilton-0.0.16.2-py3-none-any.whl
Size 929.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
eb7b4fe0bfb1c02809e0c0818d3db8da3ad470dc03b0cf5cc2d1e2e1e3940896
BLAKE2b-256 checksum
How to use checksums
ea7b91e273732091775e31a0120a7c9c0bd3a69bf02bc8d2aa260f5a793712a4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.6

Release history Release notifications | RSS feed

This release

0.0.16.2 This release

2 release files

0.0.15

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page