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

Uploaded Python 3

File details

Details for the file text_highlighter_hilton-0.0.16b0.tar.gz.

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.16b0.tar.gz
Algorithm Hash digest
SHA256 a41f4743a38e8d7d8c7c033d7318e7cbbc098e494654e469b0ecd2b9628f5ecd
MD5 5a57d89fecb051f7b64104fbfa0e2c1f
BLAKE2b-256 ef39baad50ffcd51d21db29bdad7027431c2db5b259833a2ab1eeb18536349e8

See more details on using hashes here.

File details

Details for the file text_highlighter_hilton-0.0.16b0-py3-none-any.whl.

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.16b0-py3-none-any.whl
Algorithm Hash digest
SHA256 135f4e39883b7c2a68b92cbf1ce2210e522c7484d930474e3169877d8eaf24aa
MD5 fc1d18b9875dbecb150f642f8836b47d
BLAKE2b-256 43097b8757be75f0a3184b9ac5363996b5264bee816bf6fceb32320ebbc3ea57

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