Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
msx-tool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FoodInformatics
msx-tool
Commits
531b5907
Commit
531b5907
authored
4 years ago
by
Jim Hoekstra
Browse files
Options
Downloads
Patches
Plain Diff
merge
parent
82674525
No related branches found
No related tags found
1 merge request
!17
Develop
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
dash_app/callbacks.py
+2
-0
2 additions, 0 deletions
dash_app/callbacks.py
dash_app/index.py
+0
-1
0 additions, 1 deletion
dash_app/index.py
dash_app/words.py
+5
-5
5 additions, 5 deletions
dash_app/words.py
with
7 additions
and
6 deletions
dash_app/callbacks.py
+
2
−
0
View file @
531b5907
...
@@ -41,6 +41,7 @@ def update_base_word(submit_word_button, base_word_input):
...
@@ -41,6 +41,7 @@ def update_base_word(submit_word_button, base_word_input):
State
(
component_id
=
'
graph-elements-div
'
,
component_property
=
'
children
'
),
State
(
component_id
=
'
graph-elements-div
'
,
component_property
=
'
children
'
),
State
(
component_id
=
'
msx-graph
'
,
component_property
=
'
tapNodeData
'
),
State
(
component_id
=
'
msx-graph
'
,
component_property
=
'
tapNodeData
'
),
State
(
component_id
=
'
base-word-div
'
,
component_property
=
'
children
'
),
State
(
component_id
=
'
base-word-div
'
,
component_property
=
'
children
'
),
# State(component_id='msx-graph', component_property='zoom'),
prevent_initial_call
=
True
prevent_initial_call
=
True
)
)
def
update_graph_elements
(
submit_word_button
,
add_word_button
,
extend_graph_button
,
remove_word_button
,
base_word_input
,
def
update_graph_elements
(
submit_word_button
,
add_word_button
,
extend_graph_button
,
remove_word_button
,
base_word_input
,
...
@@ -50,6 +51,7 @@ def update_graph_elements(submit_word_button, add_word_button, extend_graph_butt
...
@@ -50,6 +51,7 @@ def update_graph_elements(submit_word_button, add_word_button, extend_graph_butt
button_id
=
callback_context
.
triggered
[
0
][
'
prop_id
'
].
split
(
'
.
'
)[
0
]
button_id
=
callback_context
.
triggered
[
0
][
'
prop_id
'
].
split
(
'
.
'
)[
0
]
graph
=
Graph
()
graph
=
Graph
()
# print('graph zoom level: ', graph_zoom_level)
if
button_id
==
'
submit-word-button
'
:
if
button_id
==
'
submit-word-button
'
:
graph
.
fill_with_associations
(
word2vec_model
,
base_word_input
)
graph
.
fill_with_associations
(
word2vec_model
,
base_word_input
)
...
...
This diff is collapsed.
Click to expand it.
dash_app/index.py
+
0
−
1
View file @
531b5907
import
os
import
os
from
dash_app.app
import
app
from
dash_app.app
import
app
from
dash_app.layout
import
layout
from
dash_app.layout
import
layout
import
dash_app.callbacks
app
.
layout
=
layout
app
.
layout
=
layout
...
...
This diff is collapsed.
Click to expand it.
dash_app/words.py
+
5
−
5
View file @
531b5907
...
@@ -5,13 +5,13 @@ import stringdist as sdi
...
@@ -5,13 +5,13 @@ import stringdist as sdi
class
AssociatedWords
:
class
AssociatedWords
:
def
__init__
(
self
):
def
__init__
(
self
):
print
(
"
\n
Word2Vec model is loading.This can take a couple of minutes.
"
)
print
(
"
\n
Word2Vec model is loading.
This can take a couple of minutes.
"
)
self
.
model
=
api
.
load
(
'
glove-twitter-200
'
)
#
self.model = api.load('glove-twitter-200')
print
(
"
Word2Vec model is ready. Enjoy!!!
\n
"
)
#
print(" Word2Vec model is ready. Enjoy!!!\n")
def
get_associated_words
(
self
,
word
,
top_n
=
10
):
def
get_associated_words
(
self
,
word
,
top_n
=
10
):
gensim_result
=
self
.
model
.
most_similar
(
word
,
topn
=
top_n
)
#
gensim_result = self.model.most_similar(word, topn=top_n)
#
gensim_result = [('apple', 1.0), ('banana', 1.0), ('strawberry', 1.0)]
gensim_result
=
[(
'
apple
'
,
1.0
),
(
'
banana
'
,
1.0
),
(
'
strawberry
'
,
1.0
)]
words
=
self
.
filter_results
(
gensim_result
,
word
)
words
=
self
.
filter_results
(
gensim_result
,
word
)
return
words
return
words
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment