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
1a127719
Commit
1a127719
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Corrected BACK action : 1) cannot create cycle 2) correct backward movement
parent
bf43cbf5
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
Config.py
+1
-1
1 addition, 1 deletion
Config.py
Decode.py
+1
-1
1 addition, 1 deletion
Decode.py
Transition.py
+9
-6
9 additions, 6 deletions
Transition.py
main.py
+1
-1
1 addition, 1 deletion
main.py
with
12 additions
and
9 deletions
Config.py
+
1
−
1
View file @
1a127719
...
...
@@ -82,7 +82,7 @@ class Config :
right
=
5
print
(
"
stack :
"
,[
self
.
getAsFeature
(
ind
,
"
ID
"
)
for
ind
in
self
.
stack
],
file
=
output
)
print
(
"
history :
"
,[
trans
.
name
for
trans
in
self
.
history
[
-
10
:]],
file
=
output
)
print
(
"
historyPop :
"
,[(
c
[
0
].
name
,
c
[
1
])
for
c
in
self
.
historyPop
[
-
10
:]],
file
=
output
)
print
(
"
historyPop :
"
,[(
c
[
0
].
name
,
c
[
1
]
,
c
[
2
]
)
for
c
in
self
.
historyPop
[
-
10
:]],
file
=
output
)
toPrint
=
[]
for
lineIndex
in
range
(
self
.
wordIndex
-
left
,
self
.
wordIndex
+
right
)
:
if
lineIndex
not
in
range
(
len
(
self
.
lines
))
:
...
...
This diff is collapsed.
Click to expand it.
Decode.py
+
1
−
1
View file @
1a127719
...
...
@@ -64,7 +64,7 @@ def decodeModel(ts, strat, config, network, dicts, debug) :
candidate
=
candidates
[
0
][
1
]
if
debug
:
config
.
printForDebug
(
sys
.
stderr
)
print
(
"
"
.
join
([
"
%s%.2f:%s
"
%
(
"
*
"
if
score
[
1
]
else
"
"
,
score
[
0
],
score
[
2
])
for
score
in
scores
])
+
"
\n
"
+
(
"
-
"
*
80
)
+
"
\n
"
,
file
=
sys
.
stderr
)
print
(
"
"
.
join
([
"
%s%.2f:%s
"
%
(
"
*
"
if
score
[
1
]
else
"
"
,
score
[
0
],
score
[
2
])
for
score
in
scores
])
+
"
\n
"
+
"
Chosen action : %s
"
%
candidate
+
"
\n
"
+
(
"
-
"
*
80
)
+
"
\n
"
,
file
=
sys
.
stderr
)
moved
=
applyTransition
(
ts
,
strat
,
config
,
candidate
)
EOS
.
apply
(
config
,
strat
)
...
...
This diff is collapsed.
Click to expand it.
Transition.py
+
9
−
6
View file @
1a127719
...
...
@@ -18,8 +18,7 @@ class Transition :
def
apply
(
self
,
config
,
strategy
)
:
data
=
None
if
"
BACK
"
not
in
self
.
name
:
config
.
historyHistory
.
add
(
str
([
t
[
0
].
name
for
t
in
config
.
historyPop
]))
config
.
historyHistory
.
add
(
str
([
t
[
0
].
name
for
t
in
config
.
historyPop
]))
if
self
.
name
==
"
RIGHT
"
:
applyRight
(
config
)
...
...
@@ -39,7 +38,7 @@ class Transition :
exit
(
1
)
config
.
history
.
append
(
self
)
if
"
BACK
"
not
in
self
.
name
:
config
.
historyPop
.
append
((
self
,
data
))
config
.
historyPop
.
append
((
self
,
data
,
None
))
def
appliable
(
self
,
config
)
:
if
self
.
name
==
"
RIGHT
"
:
...
...
@@ -146,8 +145,8 @@ def scoreOracleReduce(config, ml) :
################################################################################
def
applyBack
(
config
,
strategy
,
size
)
:
for
i
in
range
(
size
)
:
trans
,
data
=
config
.
historyPop
.
pop
()
config
.
moveWordIndex
(
-
strategy
[
trans
.
name
]
)
trans
,
data
,
movement
=
config
.
historyPop
.
pop
()
config
.
moveWordIndex
(
-
movement
)
if
trans
.
name
==
"
RIGHT
"
:
applyBackRight
(
config
)
elif
trans
.
name
==
"
LEFT
"
:
...
...
@@ -236,6 +235,10 @@ def applyTransition(ts, strat, config, name) :
transition
=
[
trans
for
trans
in
ts
if
trans
.
name
==
name
][
0
]
movement
=
strat
[
transition
.
name
]
if
transition
.
name
in
strat
else
0
transition
.
apply
(
config
,
strat
)
return
config
.
moveWordIndex
(
movement
)
moved
=
config
.
moveWordIndex
(
movement
)
movement
=
movement
if
moved
else
0
if
len
(
config
.
historyPop
)
>
0
and
"
BACK
"
not
in
name
:
config
.
historyPop
[
-
1
]
=
(
config
.
historyPop
[
-
1
][
0
],
config
.
historyPop
[
-
1
][
1
],
movement
)
return
moved
################################################################################
This diff is collapsed.
Click to expand it.
main.py
+
1
−
1
View file @
1a127719
...
...
@@ -41,7 +41,7 @@ if __name__ == "__main__" :
os
.
makedirs
(
args
.
model
,
exist_ok
=
True
)
Util
.
setDevice
(
torch
.
device
(
"
cuda
"
if
torch
.
cuda
.
is_available
()
else
"
cpu
"
))
print
(
"
Using device : %s
"
%
Util
.
getDevice
())
print
(
"
Using device : %s
"
%
Util
.
getDevice
()
,
file
=
sys
.
stderr
)
random
.
seed
(
args
.
seed
)
torch
.
manual_seed
(
args
.
seed
)
...
...
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