Skip to content

Commit

Permalink
Add nlp word senses to tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
pbong committed Oct 31, 2023
1 parent 0dc14bb commit 577267f
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions src/callbacks/home/plot/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ def display_word_in_the_source_plot_description(word, word_exists):
def display_word_tooltip_in_the_source_plot(source_n_clicks, sense_n_clicks, word):
if source_n_clicks > 0 or sense_n_clicks > 0:
df = get_word_db(API_URL, word)
nlp_word_df = get_nlp_word(API_URL, word)

sense_list = []
sense_num = 0

# netsci
if len(df) >= 1:
sense_list = []
for i in range(len(df)):
sample_sentence_list = df.iloc[i]['example_sentences']

Expand All @@ -70,15 +74,45 @@ def display_word_tooltip_in_the_source_plot(source_n_clicks, sense_n_clicks, wor
]
)

sense_num += 1

sense_list.append(
html.Li([
html.B(f'Sense {i+1}:'),
html.B(f'Sense {sense_num}:'),
html_sample_sentence,
html.Br()
]
)
)
# nlp
if len(nlp_word_df) >= 1:
for i in range(len(df)):
sample_sentence_list = df.iloc[i]['example_sentences']

html_sample_sentence = html.Ul()
if len(sample_sentence_list) >= 1:
html_sample_sentence = html.Ul(
children=[
html.Li([
html.Span('Sample sentence: '),
html.Span(
sample_sentence_list[0],
style={'color': 'gray'}
)
])
]
)

sense_num += 1

sense_list.append(
html.Li([
html.B(f'Sense {sense_num}:'),
html_sample_sentence,
html.Br()
]
)
)

modal = [
dbc.ModalHeader(
Expand Down

0 comments on commit 577267f

Please sign in to comment.