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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
RL-Parsing
Commits
0d5dffb6
Commit
0d5dffb6
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Corrected bug where predicted columns were not automaticaly set during decoding
parent
ead830cc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.py
+8
-6
8 additions, 6 deletions
main.py
with
8 additions
and
6 deletions
main.py
+
8
−
6
View file @
0d5dffb6
...
...
@@ -85,25 +85,27 @@ if __name__ == "__main__" :
tmpDicts
.
readConllu
(
args
.
corpus
,
[
"
UPOS
"
],
0
)
tagActions
=
[
"
TAG UPOS %s
"
%
p
for
p
in
tmpDicts
.
getElementsOf
(
"
UPOS
"
)
if
"
__
"
not
in
p
and
not
isEmpty
(
p
)]
transitionSet
=
[
Transition
(
elem
)
for
elem
in
([
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
+
tagActions
+
args
.
ts
.
split
(
'
,
'
))
if
len
(
elem
)
>
0
]
args
.
predicted
=
"
HEAD,UPOS
"
args
.
predicted
Str
=
"
HEAD,UPOS
"
elif
args
.
transitions
==
"
swift
"
:
transitionSet
=
[
Transition
(
elem
)
for
elem
in
([
"
SHIFT
"
]
+
[
"
LEFT
"
+
str
(
n
)
for
n
in
range
(
1
,
6
)]
+
[
"
RIGHT
"
+
str
(
n
)
for
n
in
range
(
1
,
6
)]
+
args
.
ts
.
split
(
'
,
'
))
if
len
(
elem
)
>
0
]
args
.
predicted
=
"
HEAD
"
args
.
predicted
Str
=
"
HEAD
"
else
:
raise
Exception
(
"
Unknown transition set
'
%s
'"
%
args
.
transitions
)
strategy
=
{
"
RIGHT
"
:
1
,
"
SHIFT
"
:
1
,
"
LEFT
"
:
0
,
"
REDUCE
"
:
0
,
"
TAG
"
:
0
}
args
.
predicted
=
set
({
colName
for
colName
in
args
.
predicted
.
split
(
'
,
'
)})
if
args
.
mode
==
"
train
"
:
json
.
dump
([
str
(
t
)
for
t
in
transitionSet
],
open
(
args
.
model
+
"
/transitions.json
"
,
"
w
"
))
args
.
predicted
=
set
({
colName
for
colName
in
args
.
predictedStr
.
split
(
'
,
'
)})
json
.
dump
([
args
.
predictedStr
,
[
str
(
t
)
for
t
in
transitionSet
]],
open
(
args
.
model
+
"
/transitions.json
"
,
"
w
"
))
json
.
dump
(
strategy
,
open
(
args
.
model
+
"
/strategy.json
"
,
"
w
"
))
printTS
(
transitionSet
,
sys
.
stderr
)
probas
=
[
list
(
map
(
float
,
args
.
probaRandom
.
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaOracle
.
split
(
'
,
'
)))]
Train
.
trainMode
(
args
.
debug
,
args
.
corpus
,
args
.
type
,
transitionSet
,
strategy
,
args
.
model
,
int
(
args
.
iter
),
int
(
args
.
batchSize
),
args
.
dev
,
args
.
bootstrap
,
args
.
incr
,
args
.
reward
,
float
(
args
.
lr
),
float
(
args
.
gamma
),
probas
,
int
(
args
.
countBreak
),
args
.
predicted
,
args
.
silent
)
elif
args
.
mode
==
"
decode
"
:
transNames
=
json
.
load
(
open
(
args
.
model
+
"
/transitions.json
"
,
"
r
"
))
transInfos
=
json
.
load
(
open
(
args
.
model
+
"
/transitions.json
"
,
"
r
"
))
transNames
=
json
.
load
(
open
(
args
.
model
+
"
/transitions.json
"
,
"
r
"
))[
1
]
args
.
predictedStr
=
transInfos
[
0
]
args
.
predicted
=
set
({
colName
for
colName
in
args
.
predictedStr
.
split
(
'
,
'
)})
transitionSet
=
[
Transition
(
elem
)
for
elem
in
transNames
]
strategy
=
json
.
load
(
open
(
args
.
model
+
"
/strategy.json
"
,
"
r
"
))
printTS
(
transitionSet
,
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