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:
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for text_highlighter-0.0.14-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8f308e1cb46995db20e1d32fa5756446586272d91d0829112f2b322ced6c2dd |
|
MD5 | 1600e36183be3e0211e224be6a0a9ab6 |
|
BLAKE2b-256 | 6d4ccdb5c1e4bc3c8fe2840762ccc7b67ec37bc2561d7df873001203b1765010 |