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
e46f5930
Commit
e46f5930
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Corrected bug where NOBACK was impossible after a BACK
parent
9d39440a
Branches
erased
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
Transition.py
+3
-1
3 additions, 1 deletion
Transition.py
main.py
+2
-2
2 additions, 2 deletions
main.py
with
5 additions
and
3 deletions
Transition.py
+
3
−
1
View file @
e46f5930
...
@@ -15,7 +15,7 @@ class Transition :
...
@@ -15,7 +15,7 @@ class Transition :
if
len
(
splited
)
==
3
:
if
len
(
splited
)
==
3
:
self
.
colName
=
splited
[
1
]
self
.
colName
=
splited
[
1
]
self
.
argument
=
splited
[
2
]
self
.
argument
=
splited
[
2
]
if
not
self
.
name
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
,
"
BACK
"
,
"
NOBACK
"
,
"
NOBACKAB
"
,
"
EOS
"
,
"
TAG
"
]
:
if
not
self
.
name
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
,
"
BACK
"
,
"
NOBACK
"
,
"
NOBACKAB
"
,
"
NOBACKBB
"
,
"
EOS
"
,
"
TAG
"
]
:
raise
(
Exception
(
"'
%s
'
is not a valid transition type.
"
%
name
))
raise
(
Exception
(
"'
%s
'
is not a valid transition type.
"
%
name
))
def
__str__
(
self
)
:
def
__str__
(
self
)
:
...
@@ -81,6 +81,8 @@ class Transition :
...
@@ -81,6 +81,8 @@ class Transition :
if
self
.
name
==
"
TAG
"
:
if
self
.
name
==
"
TAG
"
:
return
isEmpty
(
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
))
or
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
)
==
Dicts
.
Dicts
.
erased
return
isEmpty
(
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
))
or
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
)
==
Dicts
.
Dicts
.
erased
if
self
.
name
==
"
NOBACK
"
:
if
self
.
name
==
"
NOBACK
"
:
return
True
if
self
.
name
==
"
NOBACKBB
"
:
return
config
.
nbUndone
==
0
return
config
.
nbUndone
==
0
if
self
.
name
==
"
NOBACKAB
"
:
if
self
.
name
==
"
NOBACKAB
"
:
return
config
.
nbUndone
!=
0
return
config
.
nbUndone
!=
0
...
...
This diff is collapsed.
Click to expand it.
main.py
+
2
−
2
View file @
e46f5930
...
@@ -134,10 +134,10 @@ if __name__ == "__main__" :
...
@@ -134,10 +134,10 @@ if __name__ == "__main__" :
tmpDicts
=
Dicts
()
tmpDicts
=
Dicts
()
tmpDicts
.
readConllu
(
args
.
corpus
,
[
"
UPOS
"
],
0
)
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
)]
tagActions
=
[
"
TAG UPOS %s
"
%
p
for
p
in
tmpDicts
.
getElementsOf
(
"
UPOS
"
)
if
"
__
"
not
in
p
and
not
isEmpty
(
p
)]
transitionSets
=
[[
Transition
(
elem
)
for
elem
in
tagActions
if
len
(
elem
)
>
0
],
[
Transition
(
elem
)
for
elem
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
if
len
(
elem
)
>
0
],
[
Transition
(
"
NOBACK
"
),
Transition
(
"
NOBACKAB
"
),
Transition
(
"
BACK 2
"
)],
[
Transition
(
elem
)
for
elem
in
tagActions
if
len
(
elem
)
>
0
],
[
Transition
(
elem
)
for
elem
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
if
len
(
elem
)
>
0
]]
transitionSets
=
[[
Transition
(
elem
)
for
elem
in
tagActions
if
len
(
elem
)
>
0
],
[
Transition
(
elem
)
for
elem
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
if
len
(
elem
)
>
0
],
[
Transition
(
"
NOBACK
BB
"
),
Transition
(
"
NOBACKAB
"
),
Transition
(
"
BACK 2
"
)],
[
Transition
(
elem
)
for
elem
in
tagActions
if
len
(
elem
)
>
0
],
[
Transition
(
elem
)
for
elem
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
if
len
(
elem
)
>
0
]]
args
.
predictedStr
=
"
HEAD,UPOS
"
args
.
predictedStr
=
"
HEAD,UPOS
"
args
.
states
=
[
"
tagger
"
,
"
parser
"
,
"
backer
"
,
"
taggerReco
"
,
"
parserReco
"
]
args
.
states
=
[
"
tagger
"
,
"
parser
"
,
"
backer
"
,
"
taggerReco
"
,
"
parserReco
"
]
strategy
=
[{
"
TAG
"
:
(
0
,
1
)},
{
"
RIGHT
"
:
(
1
,
2
),
"
SHIFT
"
:
(
1
,
2
),
"
LEFT
"
:
(
0
,
1
),
"
REDUCE
"
:
(
0
,
1
)},
{
"
NOBACK
"
:
(
0
,
0
),
"
NOBACKAB
"
:
(
0
,
3
)},
{
"
TAG
"
:
(
0
,
4
)},
{
"
RIGHT
"
:
(
1
,
2
),
"
SHIFT
"
:
(
1
,
2
),
"
LEFT
"
:
(
0
,
4
),
"
REDUCE
"
:
(
0
,
4
)}]
strategy
=
[{
"
TAG
"
:
(
0
,
1
)},
{
"
RIGHT
"
:
(
1
,
2
),
"
SHIFT
"
:
(
1
,
2
),
"
LEFT
"
:
(
0
,
1
),
"
REDUCE
"
:
(
0
,
1
)},
{
"
NOBACK
BB
"
:
(
0
,
0
),
"
NOBACKAB
"
:
(
0
,
3
)},
{
"
TAG
"
:
(
0
,
4
)},
{
"
RIGHT
"
:
(
1
,
2
),
"
SHIFT
"
:
(
1
,
2
),
"
LEFT
"
:
(
0
,
4
),
"
REDUCE
"
:
(
0
,
4
)}]
probas
=
[[
list
(
map
(
float
,
args
.
probaRandom
.
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaOracle
.
split
(
'
,
'
)))],
probas
=
[[
list
(
map
(
float
,
args
.
probaRandom
.
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaOracle
.
split
(
'
,
'
)))],
[
list
(
map
(
float
,
args
.
probaRandom
.
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaOracle
.
split
(
'
,
'
)))],
[
list
(
map
(
float
,
args
.
probaRandom
.
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaOracle
.
split
(
'
,
'
)))],
[
list
(
map
(
float
,
args
.
probaStateBack
.
split
(
'
-
'
)[
0
].
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaStateBack
.
split
(
'
-
'
)[
1
].
split
(
'
,
'
)))],
[
list
(
map
(
float
,
args
.
probaStateBack
.
split
(
'
-
'
)[
0
].
split
(
'
,
'
))),
list
(
map
(
float
,
args
.
probaStateBack
.
split
(
'
-
'
)[
1
].
split
(
'
,
'
)))],
...
...
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