Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RL-Parsing
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
RL-Parsing
Commits
4a7dabd5
Commit
4a7dabd5
authored
May 20, 2022
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Fixed embeddings generation
parent
76da121d
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Networks.py
+5
-1
5 additions, 1 deletion
Networks.py
embeddings/lefffEmbeddings/generateLefffEmbeddings.py
+3
-3
3 additions, 3 deletions
embeddings/lefffEmbeddings/generateLefffEmbeddings.py
with
8 additions
and
4 deletions
Networks.py
+
5
−
1
View file @
4a7dabd5
...
...
@@ -3,6 +3,7 @@ import torch.nn as nn
import
torch.nn.functional
as
F
import
Features
import
Transition
from
Util
import
prettyInt
################################################################################
def
readPretrainedSize
(
w2vFile
)
:
...
...
@@ -13,16 +14,19 @@ def readPretrainedSize(w2vFile) :
################################################################################
def
loadW2v
(
w2vFile
,
weights
,
dicts
,
colname
)
:
size
=
None
nbLoaded
=
0
for
line
in
open
(
w2vFile
,
"
r
"
)
:
line
=
line
.
strip
()
if
size
is
None
:
size
=
int
(
line
.
split
()[
1
])
continue
splited
=
line
.
split
()
word
=
"
"
.
join
(
splited
[
0
:
len
(
splited
)
-
size
])
word
=
"
"
.
join
(
splited
[
0
:
len
(
splited
)
-
size
])
.
replace
(
"
◌
"
,
"
"
)
emb
=
torch
.
tensor
(
list
(
map
(
float
,
splited
[
len
(
splited
)
-
size
:])))
weights
[
dicts
.
get
(
colname
,
word
)]
=
emb
nbLoaded
+=
1
print
(
"
Loaded %s pretrained embeddings for
'
%s
'
from
'
%s
'"
%
(
prettyInt
(
nbLoaded
,
3
),
colname
,
w2vFile
))
################################################################################
################################################################################
...
...
This diff is collapsed.
Click to expand it.
embeddings/lefffEmbeddings/generateLefffEmbeddings.py
+
3
−
3
View file @
4a7dabd5
...
...
@@ -35,14 +35,14 @@ for conllu in [("--conllu %s"%conlluFiles, "conllu")] :
nbDone
=
0
for
name
,
command
in
commands
:
print
(
"
\r
%s
\r
%5.2f%% Generating %s
"
%
(
"
"
*
80
,
100
*
nbDone
/
len
(
commands
),
name
),
end
=
""
)
print
(
"
\r
%s
\r
%5.2f%% Generating %s
"
%
(
"
"
*
80
,
100
*
nbDone
/
len
(
commands
),
name
),
end
=
""
,
file
=
sys
.
stderr
)
sys
.
stdout
.
flush
()
err
=
subprocess
.
Popen
(
command
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
).
stderr
.
read
().
decode
()
if
len
(
err
)
>
0
:
print
(
err
,
sys
.
stderr
)
print
(
"
\r
%s
\r
When generating %s
\n
%s
"
%
(
"
"
*
80
,
name
,
err
)
,
file
=
sys
.
stderr
)
nbDone
+=
1
print
()
print
(
file
=
sys
.
stderr
)
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