tvst / st-annotated-text

A simple component to display annotated text in Streamlit apps.
Apache License 2.0
523 stars 41 forks source link

Option to provide height of the iframe #3

Closed jithurjacob closed 3 years ago

jithurjacob commented 4 years ago

Please provide an option to set the height of the output iframe. https://docs.streamlit.io/en/stable/develop_streamlit_components.html#streamlit.components.v1.html

ChrisDelClea commented 4 years ago

I strongly support the upper idea. It seems to be very limited in space. About 4 rows.

mataney commented 4 years ago

This should do the trick https://github.com/tvst/st-annotated-text/pull/7

tvst commented 3 years ago

Merged.

srikar3120 commented 3 years ago

Hi @tvst , Im using below code to annotate sentence

def annotate_answer(answer, context): start_idx = context.find(answer) end_idx = start_idx + len(answer)

calculate dynamic height depending on context length

height = int(len(context) * 0.25) + 5
annotated_text(context[:start_idx], (answer, "Moderate", "#8ef"), context[end_idx:], height=height)

if (row["label"] == 1):

s is sentence here that i want to annotate

   annotate_answer(s, s) 

context Im passing is full sentence. And I want to annotate full sentence. Im seeing it getting annotated but there is gap between the sentences after annotation and sometimes not able to some of the text if the sentence is too big. Can you please let me know how to caluculate dynamically [height?] I tried to play with height parameter in the method but no luck... If I reduce height, lines are missing... If I increase height, space after the line is too big

image image