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.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.15-py3-none-any.whl (382.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: text_highlighter_hilton-0.0.15.tar.gz
  • Upload date:
  • Size: 473.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.6

File hashes

Hashes for text_highlighter_hilton-0.0.15.tar.gz
Algorithm Hash digest
SHA256 183d08bc92c7aae051b7dd0ebe637d80dfe6e4b8ba11bf868a8a7017e97eba7e
MD5 8efc4d37213e6b160452d96b50d4142a
BLAKE2b-256 329ee0a300f54bad4f5eb19f4d3b01c718c8c741e900a9a67134c046151cee13

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for text_highlighter_hilton-0.0.15-py3-none-any.whl
Algorithm Hash digest
SHA256 33afb0fff9065a7ce32adc469988600b3cb85f7429aa2d426c4ab91a84fb98d7
MD5 709f349f46e168d177d9aba1ddce40b7
BLAKE2b-256 a292f04bd448c7e216afe43fdb1d2784681695bd293040feb7447a370e906eae

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