Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
word2vec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lexworkers
word2vec
Commits
0d6ab195
Commit
0d6ab195
authored
Oct 31, 2023
by
Damian Raczkowski
Browse files
Options
Downloads
Patches
Plain Diff
Satisfy pep8
parent
8ac6f7c2
No related branches found
No related tags found
1 merge request
!5
Develop
Pipeline
#14501
passed
Oct 31, 2023
Stage: check_style
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/word2vec_worker.py
+16
-8
16 additions, 8 deletions
src/word2vec_worker.py
with
16 additions
and
8 deletions
src/word2vec_worker.py
+
16
−
8
View file @
0d6ab195
...
...
@@ -93,8 +93,8 @@ class W2vWorker(lex_ws.LexWorker):
def
_evaluate_operation
(
self
,
operation_type
,
input_to_evaluate
):
"""
Evaluates operation passed by task.
:param operation_type: task which is supposed to be done.
Can be one of either:
vector, similarity, kbest.
:param operation_type: task which is supposed to be done.
Can be one of either:
vector, similarity, kbest.
:type operation_type: str
:raise Exception: If provided operation is not supported.
:param input_to_evaluate: Data to be evaluated by the worker.
...
...
@@ -106,8 +106,10 @@ class W2vWorker(lex_ws.LexWorker):
if
operation_type
==
"
notmatch
"
:
return
model
.
most_not_match
(
input_to_evaluate
[
"
options
"
][
"
words
"
])
if
operation_type
==
"
kbestposneg
"
:
return
model
.
most_similar_full
(
input_to_evaluate
[
"
options
"
][
"
positive
"
],
input_to_evaluate
[
"
options
"
][
"
negative
"
])
return
model
.
most_similar_full
(
input_to_evaluate
[
"
options
"
][
"
positive
"
],
input_to_evaluate
[
"
options
"
][
"
negative
"
]
)
if
operation_type
==
"
kbest
"
:
return
model
.
most_similar
(
input_to_evaluate
[
"
lexeme
"
])
elif
operation_type
==
"
similarity
"
:
...
...
@@ -121,12 +123,18 @@ class W2vWorker(lex_ws.LexWorker):
input_to_evaluate
[
"
lexeme2
"
]
)
elif
operation_type
==
"
doc2vec
"
:
return
model
.
doc2vec
(
input_to_evaluate
[
"
lexeme1
"
],
input_to_evaluate
[
"
counts1
"
])
return
model
.
doc2vec
(
input_to_evaluate
[
"
lexeme1
"
],
input_to_evaluate
[
"
counts1
"
]
)
elif
operation_type
==
"
vector
"
:
return
model
.
vector_representations
(
input_to_evaluate
[
"
lexeme
"
])
elif
operation_type
==
"
all
"
or
not
operation_type
:
return
{
"
vector
"
:
model
.
vector_representations
(
input_to_evaluate
[
"
lexeme
"
]),
"
kbest
"
:
model
.
most_similar
(
input_to_evaluate
[
"
lexeme
"
])}
return
{
"
vector
"
:
model
.
vector_representations
(
input_to_evaluate
[
"
lexeme
"
]),
"
kbest
"
:
model
.
most_similar
(
input_to_evaluate
[
"
lexeme
"
])
}
else
:
raise
Exception
(
...
...
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