Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
17ef7c7e
Commit
17ef7c7e
authored
Aug 23, 2017
by
Toby Boyd
Browse files
Merge branch 'master' of github.com:tensorflow/models
parents
8008e72f
a380b4b3
Changes
21
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
swivel/wordsim.py
swivel/wordsim.py
+10
-7
No files found.
swivel/wordsim.py
View file @
17ef7c7e
...
...
@@ -34,6 +34,7 @@ the scored human judgement.
"""
from
__future__
import
print_function
import
scipy.stats
import
sys
from
getopt
import
GetoptError
,
getopt
...
...
@@ -42,8 +43,8 @@ from vecs import Vecs
try
:
opts
,
args
=
getopt
(
sys
.
argv
[
1
:],
''
,
[
'embeddings='
,
'vocab='
])
except
GetoptError
,
e
:
print
>>
sys
.
stderr
,
e
except
GetoptError
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
opt_embeddings
=
None
...
...
@@ -56,19 +57,20 @@ for o, a in opts:
opt_vocab
=
a
if
not
opt_vocab
:
print
>>
sys
.
stderr
,
'please specify a vocabulary file with "--vocab"'
print
(
'please specify a vocabulary file with "--vocab"'
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
if
not
opt_embeddings
:
print
>>
sys
.
stderr
,
'please specify the embeddings with "--embeddings"'
print
(
'please specify the embeddings with "--embeddings"'
,
file
=
sys
.
stderr
)
sys
.
exit
(
2
)
try
:
vecs
=
Vecs
(
opt_vocab
,
opt_embeddings
)
except
IOError
,
e
:
print
>>
sys
.
stderr
,
e
except
IOError
as
e
:
print
(
e
,
file
=
sys
.
stderr
)
sys
.
exit
(
1
)
def
evaluate
(
lines
):
acts
,
preds
=
[],
[]
...
...
@@ -85,6 +87,7 @@ def evaluate(lines):
rho
,
_
=
scipy
.
stats
.
spearmanr
(
acts
,
preds
)
return
rho
for
filename
in
args
:
with
open
(
filename
,
'r'
)
as
lines
:
print
'%0.3f %s'
%
(
evaluate
(
lines
),
filename
)
print
(
'%0.3f %s'
%
(
evaluate
(
lines
),
filename
)
)
Prev
1
2
Next
Write
Preview
Markdown
is supported
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