Streamlit component to annotate text span
Project description
st-span-annotation
Streamlit component to annotate text span
Usage instructions
from typing import TypedDict
import streamlit as st
from st_span_annotation import st_span_annotation
class Span(TypedDict):
start: int
end: int
label: str
text: str
text = """Alice and Bob are planning to visit New York next week.
They will be attending a conference on AI."""
labels = ["PERSON", "LOCATION", "DATE", "EVENT"]
initial_spans: list[Span] = [
{"start": 0, "end": 5, "label": "PERSON", "text": "Alice"},
{"start": 36, "end": 44, "label": "LOCATION", "text": "New York"},
{"start": 45, "end": 54, "label": "DATE", "text": "next week"},
{"start": 81, "end": 97, "label": "EVENT", "text": "conference on AI"},
]
color_palette: dict[str, str] = {
"PERSON": "lightblue",
"LOCATION": "lightgreen",
"DATE": "lightyellow",
"EVENT": "lightcoral",
}
result: list[Span] = st_span_annotation(
text=text,
labels=labels,
spans=initial_spans, # optional
color_palette=color_palette, # optional
is_editable=True, #optional
)
st.write(result)
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
st_span_annotation-0.0.8.tar.gz
(405.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file st_span_annotation-0.0.8.tar.gz.
File metadata
- Download URL: st_span_annotation-0.0.8.tar.gz
- Upload date:
- Size: 405.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17569d75bbab0e0397821c7fc2cbaf57ee3009bd87885c688c20d8d1d2bbb827
|
|
| MD5 |
5e0175074a772b1a3c631f6002e29247
|
|
| BLAKE2b-256 |
9abedcd967abd949086ba5af22cf81857f206f75d059baf7e7452542d07d751d
|
File details
Details for the file st_span_annotation-0.0.8-py3-none-any.whl.
File metadata
- Download URL: st_span_annotation-0.0.8-py3-none-any.whl
- Upload date:
- Size: 408.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30fa864aa8f5fdee32c4a5c871ce39b3ea5a449a029aae33f90a170cb438b85a
|
|
| MD5 |
4a15e76932c70c52ec2a2546ce480775
|
|
| BLAKE2b-256 |
6157def97920ddf8109d13fba2e6377ed0ab4be36c4885b34f00cec7fe313ff7
|