I would need to get SpaCy’s entity visualiser working for multiple text areas in Streamlit - yet it seems that SpaCy’s entity visualiser can’t be duplicated out of the box:
Currently, I’ve got the duplicateWidgetID error thrown on the 2nd text area - please see the screenshot below:
I’ve been trying various things on the spacy_streamlit visualizer.py file (which contains the visualize_ner function related to entity vizzes), yet every time either I get the duplicateWidgetID error, or other errors (which I would be happy to trace back here. :))
There must be something pretty easy to amend to enable it, yet I can’t seem to find what it is.
As always, any guidance would be uber appreciated!
To avoid duplicateWidgetID errors, you’ll have to play with the key parameter of Streamlit widgets.
Add a new key parameter in visualize that you’ll forward to every vizualize_*() function. And in every function, pass the key parameter to each streamlit widget that support it (which means all widgets you can interact with).
That done, you should be able to call visualize multiple times by passing a different key value each time:
It’s a strict duplication of visualize_ner with key=2 in lieu of key=1.
When trying the above, Streamlit is throwing the following AttributeError error:
AttributeError: module 'spacy_streamlit' has no attribute 'visualize_ner2'
Traceback:
File "c:\users\charly\desktop\streamlit spacy tests\venv\lib\site-packages\streamlit\ScriptRunner.py", line 319, in _run_script
exec(code, module.__dict__)
File "C:\Users\Charly\Desktop\Streamlit SpaCy tests\customMaster.py", line 43, in <module>
spacy_streamlit.visualize_ner2(
Am I understanding your explanation correctly? If so, is there anything else that I may need to tweak (possibly in ScriptRunner.py) in order to make this work?