Open BillCM opened 7 months ago
Look at the example https://github.com/rmarquet21/streamlit-annotation-tools/blob/master/examples/example.py
You have here the format of parameter labels
def labeler_page():
st.title("Text Labeling Tool")
text = "Yesterday, at 3 PM, Emily Johnson and Michael Smith met at the Central Park in New York to discuss the merger between TechCorp and Global Solutions. The deal, worth approximately 500 million dollars, is expected to significantly impact the tech industry. Later, at 6 PM, they joined a conference call with the CEO of TechCorp, David Brown, who was in London for a technology summit. During the call, they discussed the market trends in Asia and Europe and planned for the next quarterly meeting, which is scheduled for January 15th, 2024, in Paris."
labels = {
"Personal names": [
{"start": 20, "end": 33, "label": "Emily Johnson"},
{"start": 38, "end": 51, "label": "Michael Smith"},
{"start": 327, "end": 338, "label": "David Brown"},
],
"Organizations": [
{"start": 118, "end": 126, "label": "TechCorp"},
{"start": 131, "end": 147, "label": "Global Solutions"},
],
"Locations": [
{"start": 63, "end": 75, "label": "Central Park"},
{"start": 79, "end": 87, "label": "New York"},
{"start": 351, "end": 357, "label": "London"},
{"start": 436, "end": 440, "label": "Asia"},
{"start": 445, "end": 451, "label": "Europe"},
{"start": 542, "end": 547, "label": "Paris"},
],
"Time": [
{"start": 0, "end": 9, "label": "Yesterday"},
{"start": 14, "end": 18, "label": "3 PM"},
{"start": 265, "end": 269, "label": "6 PM"},
{"start": 519, "end": 531, "label": "January 15th"},
{"start": 533, "end": 537, "label": "2024"},
],
"Money": [{"start": 179, "end": 198, "label": "500 million dollars"}],
}
labels = text_labeler(text, labels)
OK. Perhaps there is an opportunity to clarify the code doc here.
The labels
input isn't a list
as defined in the code. It's actually a Dict.
def text_labeler(text: str, labels=[], in_snake_case=False):
"""Create a new instance of "text_labeler".
Parameters
----------
text : str
The text to be labeled
labels : list
You're right, I'll take care of it.
I've started receiving this error whenever I try to pass a label list as input to the text_labeler().
Dependencies: python 3.11.4 streamlit==1.31.0 streamlit-annotation-tools==1.0.1
ERROR: text_labeler component is not presented. However, the annotations object is presented as expected
Chrome Inspector shows the following error, but JS is enabled. Same on Brave and Safari.
<noscript>You need to enable JavaScript to run this app.</noscript>
Removing the labels allows the text_labeler to render.
annotations = text_labeler(doc_text)