Skip to content

Commit

Permalink
Display tooltip for PCA
Browse files Browse the repository at this point in the history
  • Loading branch information
memgonzales committed Nov 8, 2023
1 parent 0a21146 commit 785a9f3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/callbacks/home/embeddings/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,16 @@ def display_embeddings(word, word_exists):
# TODO: add exception handling
raise PreventUpdate
raise PreventUpdate

@app.callback(
Output('input-word-embeddings', 'children'),
Input('submitted-word', 'data'),
Input('word-exists', 'data')
)
def search_word(word, word_exists):
if word and word_exists:
df = get_word_db(API_URL, word)
if len(df) >= 1:
return word

raise PreventUpdate
5 changes: 3 additions & 2 deletions src/callbacks/home/plot/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ def display_word_in_the_source_plot_description(word, word_exists):
Input('word-plot-source', 'n_clicks'),
Input('word-plot-sense', 'n_clicks'),
Input('word-plot-network', 'n_clicks'),
Input('word-plot-embeddings', 'n_clicks'),
State('submitted-word', 'data')
)
def display_word_tooltip_in_the_source_plot(source_n_clicks, sense_n_clicks, network_n_clicks, word):
if source_n_clicks > 0 or sense_n_clicks > 0 or network_n_clicks > 0:
def display_word_tooltip_in_the_source_plot(source_n_clicks, sense_n_clicks, network_n_clicks, embeddings_n_clicks, word):
if source_n_clicks > 0 or sense_n_clicks > 0 or network_n_clicks > 0 or embeddings_n_clicks > 0:
df = get_word_db(API_URL, word)
nlp_word_df = get_nlp_word(API_URL, word)

Expand Down
16 changes: 14 additions & 2 deletions src/pages/home.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,20 @@
html.Br(),
html.Br(),
html.Div([
html.Div(
'Three-dimensional projection of word sense embeddings obtained via principal component analysis (PCA)'),
html.Div([
'Three-dimensional projection of the word sense embeddings of ',
html.Span(
children=[
html.Span(' ', id='input-word-embeddings'),
html.Span(' '),
html.I(
className='bi bi-info-circle',
),
f' '
],
id='word-plot-embeddings', n_clicks=0, style={'white-space': 'pre'}, className='fw-bold'),
', obtained via principal component analysis (PCA)'
]),
html.Div(
'Data processing is ongoing for senses marked with an asterisk (*)',
className='small mt-3', style={'color': 'gray'}
Expand Down

0 comments on commit 785a9f3

Please sign in to comment.