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.15.1.tar.gz (473.9 kB 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.15.1-py3-none-any.whl (382.6 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.15.1.tar.gz
Algorithm Hash digest
SHA256 b58cdcbd8f3f1e747b49f7e78f9578518c0884a072273167ca20f8dbafd42195
MD5 ddf6ce4bf515debca3cca06cc66f4ae2
BLAKE2b-256 672f9fddc95a8c0f52ec8a5ca781a69da97e8068f936f3a30157e6aa5dd3d2ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.15.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4345e8e15ff409207a0ada18dd86a65748ab0d4a004f77636d7f5d6b69780211
MD5 e3747cfe3918e0cbf638c7ef77e7877c
BLAKE2b-256 96545a6462847688a57633431cf8c7ab9e6a35b4f7baf863d40d29af0b7b52e4

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