Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Gaëtan Caillaut
wsd
Commits
848a0cc9
Commit
848a0cc9
authored
Apr 15, 2021
by
Percedal
Browse files
method assoc sens <-> def
parent
1e5ca88d
Changes
1
Hide whitespace changes
Inline
Side-by-side
desambig.py
0 → 100644
View file @
848a0cc9
import
numpy
as
np
from
sklearn.metrics.pairwise
import
cosine_similarity
def
wsd
(
sens_vec
,
def_vec
):
'''
Parameters
----------
sens_vec: numpy.ndarray
Shape (n_sens, n_features)
def_vec: numpy.ndarray
Shape (n_def, n_features)
Returns
-------
numpy.ndarray
Shape (n_sens,)
Vecteur où pour chaque element 'n' à la position 's',
la 'n'-ième définition est la plus similaire au sens 's'
'''
sims
=
cosine_similarity
(
sens_vec
,
def_vec
)
#Shape (n_sens, n_def)
return
np
.
argmax
(
sims
,
axis
=
1
)
#Shape (n_sens,)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment