Skip to main content

Streamlit component for text highlighting

Project description

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.

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

text_highlighter_hilton-0.0.16.2.tar.gz (1.0 MB view details)

Uploaded Source

Built Distribution

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

text_highlighter_hilton-0.0.16.2-py3-none-any.whl (929.7 kB view details)

Uploaded Python 3

File details

Details for the file text_highlighter_hilton-0.0.16.2.tar.gz.

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.16.2.tar.gz
Algorithm Hash digest
SHA256 88ab376db0c443360936245da8d2a2e67060782d09d846eef22cb6c816c857cf
MD5 338f26de19ad41bec2ee00ab463c0176
BLAKE2b-256 022e8e62c84b7f63f8e028ab307bc2c2d39dc9d3a9a1b2b6e5095f66eaf2dc45

See more details on using hashes here.

File details

Details for the file text_highlighter_hilton-0.0.16.2-py3-none-any.whl.

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.16.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eb7b4fe0bfb1c02809e0c0818d3db8da3ad470dc03b0cf5cc2d1e2e1e3940896
MD5 ab54be08b7099bdf1663e5c16dde1a55
BLAKE2b-256 ea7b91e273732091775e31a0120a7c9c0bd3a69bf02bc8d2aa260f5a793712a4

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