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
69aeae9c
Commit
69aeae9c
authored
4 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added transition set tagparserbt
parent
c269c0a0
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
Transition.py
+7
-1
7 additions, 1 deletion
Transition.py
main.py
+9
-1
9 additions, 1 deletion
main.py
with
16 additions
and
2 deletions
Transition.py
+
7
−
1
View file @
69aeae9c
...
@@ -14,7 +14,7 @@ class Transition :
...
@@ -14,7 +14,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
"
,
"
EOS
"
,
"
TAG
"
]
:
if
not
self
.
name
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
,
"
BACK
"
,
"
NOBACK
"
,
"
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
)
:
...
@@ -38,6 +38,8 @@ class Transition :
...
@@ -38,6 +38,8 @@ class Transition :
applyEOS
(
config
)
applyEOS
(
config
)
elif
self
.
name
==
"
TAG
"
:
elif
self
.
name
==
"
TAG
"
:
applyTag
(
config
,
self
.
colName
,
self
.
argument
)
applyTag
(
config
,
self
.
colName
,
self
.
argument
)
elif
self
.
name
==
"
NOBACK
"
:
data
=
None
elif
"
BACK
"
in
self
.
name
:
elif
"
BACK
"
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
]))
applyBack
(
config
,
strategy
,
self
.
size
)
applyBack
(
config
,
strategy
,
self
.
size
)
...
@@ -76,6 +78,8 @@ class Transition :
...
@@ -76,6 +78,8 @@ class Transition :
return
config
.
wordIndex
==
len
(
config
.
lines
)
-
1
return
config
.
wordIndex
==
len
(
config
.
lines
)
-
1
if
self
.
name
==
"
TAG
"
:
if
self
.
name
==
"
TAG
"
:
return
isEmpty
(
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
))
return
isEmpty
(
config
.
getAsFeature
(
config
.
wordIndex
,
self
.
colName
))
if
self
.
name
==
"
NOBACK
"
:
return
True
if
"
BACK
"
in
self
.
name
:
if
"
BACK
"
in
self
.
name
:
if
len
(
config
.
historyPop
)
<
self
.
size
:
if
len
(
config
.
historyPop
)
<
self
.
size
:
return
False
return
False
...
@@ -95,6 +99,8 @@ class Transition :
...
@@ -95,6 +99,8 @@ class Transition :
return
scoreOracleReduce
(
config
,
missingLinks
)
return
scoreOracleReduce
(
config
,
missingLinks
)
if
self
.
name
==
"
TAG
"
:
if
self
.
name
==
"
TAG
"
:
return
0
if
self
.
argument
==
config
.
getGold
(
config
.
wordIndex
,
self
.
colName
)
else
1
return
0
if
self
.
argument
==
config
.
getGold
(
config
.
wordIndex
,
self
.
colName
)
else
1
if
self
.
name
==
"
NOBACK
"
:
return
0
if
"
BACK
"
in
self
.
name
:
if
"
BACK
"
in
self
.
name
:
return
1
return
1
...
...
This diff is collapsed.
Click to expand it.
main.py
+
9
−
1
View file @
69aeae9c
...
@@ -52,7 +52,7 @@ if __name__ == "__main__" :
...
@@ -52,7 +52,7 @@ if __name__ == "__main__" :
parser
.
add_argument
(
"
--silent
"
,
"
-s
"
,
default
=
False
,
action
=
"
store_true
"
,
parser
.
add_argument
(
"
--silent
"
,
"
-s
"
,
default
=
False
,
action
=
"
store_true
"
,
help
=
"
Don
'
t print advancement infos.
"
)
help
=
"
Don
'
t print advancement infos.
"
)
parser
.
add_argument
(
"
--transitions
"
,
default
=
"
eager
"
,
parser
.
add_argument
(
"
--transitions
"
,
default
=
"
eager
"
,
help
=
"
Transition set to use (eager | swift | tagparser).
"
)
help
=
"
Transition set to use (eager | swift | tagparser
| tagparserbt
).
"
)
parser
.
add_argument
(
"
--ts
"
,
default
=
""
,
parser
.
add_argument
(
"
--ts
"
,
default
=
""
,
help
=
"
Comma separated list of supplementary transitions. Example
\"
BACK 1,BACK 2
\"
"
)
help
=
"
Comma separated list of supplementary transitions. Example
\"
BACK 1,BACK 2
\"
"
)
parser
.
add_argument
(
"
--network
"
,
default
=
"
base
"
,
parser
.
add_argument
(
"
--network
"
,
default
=
"
base
"
,
...
@@ -93,6 +93,14 @@ if __name__ == "__main__" :
...
@@ -93,6 +93,14 @@ if __name__ == "__main__" :
args
.
predictedStr
=
"
HEAD,UPOS
"
args
.
predictedStr
=
"
HEAD,UPOS
"
args
.
states
=
[
"
tagger
"
,
"
parser
"
]
args
.
states
=
[
"
tagger
"
,
"
parser
"
]
strategy
=
{
"
RIGHT
"
:
(
1
,
0
),
"
SHIFT
"
:
(
1
,
0
),
"
LEFT
"
:
(
0
,
1
),
"
REDUCE
"
:
(
0
,
1
),
"
TAG
"
:
(
0
,
1
)}
strategy
=
{
"
RIGHT
"
:
(
1
,
0
),
"
SHIFT
"
:
(
1
,
0
),
"
LEFT
"
:
(
0
,
1
),
"
REDUCE
"
:
(
0
,
1
),
"
TAG
"
:
(
0
,
1
)}
elif
args
.
transitions
==
"
tagparserbt
"
:
tmpDicts
=
Dicts
()
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
)]
transitionSets
=
[[
Transition
(
elem
)
for
elem
in
tagActions
if
len
(
elem
)
>
0
],
[
Transition
(
elem
)
for
elem
in
[
"
SHIFT
"
,
"
REDUCE
"
,
"
LEFT
"
,
"
RIGHT
"
]
if
len
(
elem
)
>
0
],
[
"
NOBACK
"
,
"
BACK 4
"
]]
args
.
predictedStr
=
"
HEAD,UPOS
"
args
.
states
=
[
"
tagger
"
,
"
parser
"
,
"
backer
"
]
strategy
=
{
"
RIGHT
"
:
(
1
,
2
),
"
SHIFT
"
:
(
1
,
2
),
"
LEFT
"
:
(
0
,
1
),
"
REDUCE
"
:
(
0
,
1
),
"
TAG
"
:
(
0
,
1
),
"
NOBACK
"
:
(
0
,
0
)}
elif
args
.
transitions
==
"
swift
"
:
elif
args
.
transitions
==
"
swift
"
:
transitionSets
=
[[
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
]]
transitionSets
=
[[
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
.
predictedStr
=
"
HEAD
"
args
.
predictedStr
=
"
HEAD
"
...
...
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