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
bc57dbba
Commit
bc57dbba
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added strucutre containing predicted dependents in Config
parent
436a97bc
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Config.py
+5
-3
5 additions, 3 deletions
Config.py
Transition.py
+6
-3
6 additions, 3 deletions
Transition.py
with
11 additions
and
6 deletions
Config.py
+
5
−
3
View file @
bc57dbba
...
...
@@ -5,7 +5,8 @@ import sys
class
Config
:
def
__init__
(
self
,
col2index
,
index2col
)
:
self
.
lines
=
[]
self
.
childs
=
[]
self
.
goldChilds
=
[]
self
.
predChilds
=
[]
self
.
col2index
=
col2index
self
.
index2col
=
index2col
self
.
predicted
=
set
({
"
HEAD
"
,
"
DEPREL
"
})
...
...
@@ -15,7 +16,8 @@ class Config :
def
addLine
(
self
,
cols
)
:
self
.
lines
.
append
([[
val
,
""
]
for
val
in
cols
])
self
.
childs
.
append
([])
self
.
goldChilds
.
append
([])
self
.
predChilds
.
append
([])
def
get
(
self
,
lineIndex
,
colname
,
predicted
)
:
if
lineIndex
not
in
range
(
len
(
self
.
lines
))
:
...
...
@@ -131,7 +133,7 @@ def readConllu(filename) :
if
head
==
"
0
"
:
continue
configs
[
-
1
].
set
(
index
,
"
HEAD
"
,
id2index
[
head
],
False
)
configs
[
-
1
].
c
hilds
[
int
(
id2index
[
head
])].
append
(
index
)
configs
[
-
1
].
goldC
hilds
[
int
(
id2index
[
head
])].
append
(
index
)
configs
[
-
1
].
comments
=
comments
...
...
This diff is collapsed.
Click to expand it.
Transition.py
+
6
−
3
View file @
bc57dbba
...
...
@@ -74,7 +74,7 @@ def getMissingLinks(config) :
# Number of missing links between wordIndex and the right of the sentence
def
nbLinksBufferRight
(
config
)
:
head
=
1
if
int
(
config
.
getGold
(
config
.
wordIndex
,
"
HEAD
"
))
>
config
.
wordIndex
else
0
return
head
+
len
([
c
for
c
in
config
.
c
hilds
[
config
.
wordIndex
]
if
c
>
config
.
wordIndex
])
return
head
+
len
([
c
for
c
in
config
.
goldC
hilds
[
config
.
wordIndex
]
if
c
>
config
.
wordIndex
])
################################################################################
################################################################################
...
...
@@ -89,7 +89,7 @@ def nbLinksStackRight(config) :
if
len
(
config
.
stack
)
==
0
:
return
0
head
=
1
if
int
(
config
.
getGold
(
config
.
stack
[
-
1
],
"
HEAD
"
))
>=
config
.
wordIndex
else
0
return
head
+
len
([
c
for
c
in
config
.
c
hilds
[
config
.
stack
[
-
1
]]
if
c
>=
config
.
wordIndex
])
return
head
+
len
([
c
for
c
in
config
.
goldC
hilds
[
config
.
stack
[
-
1
]]
if
c
>=
config
.
wordIndex
])
################################################################################
################################################################################
...
...
@@ -97,7 +97,7 @@ def nbLinksStackRight(config) :
def
nbLinksBufferStack
(
config
)
:
if
len
(
config
.
stack
)
==
0
:
return
0
return
len
([
s
for
s
in
config
.
stack
if
config
.
getGold
(
s
,
"
HEAD
"
)
==
config
.
wordIndex
or
config
.
wordIndex
in
config
.
c
hilds
[
s
]])
return
len
([
s
for
s
in
config
.
stack
if
config
.
getGold
(
s
,
"
HEAD
"
)
==
config
.
wordIndex
or
config
.
wordIndex
in
config
.
goldC
hilds
[
s
]])
################################################################################
################################################################################
...
...
@@ -133,12 +133,14 @@ def scoreOracleReduce(config, ml) :
################################################################################
def
applyRight
(
config
)
:
config
.
set
(
config
.
wordIndex
,
"
HEAD
"
,
config
.
stack
[
-
1
])
config
.
predChilds
[
config
.
stack
[
-
1
]].
append
(
config
.
wordIndex
)
config
.
addWordIndexToStack
()
################################################################################
################################################################################
def
applyLeft
(
config
)
:
config
.
set
(
config
.
stack
[
-
1
],
"
HEAD
"
,
config
.
wordIndex
)
config
.
predChilds
[
config
.
wordIndex
].
append
(
config
.
stack
[
-
1
])
config
.
popStack
()
################################################################################
...
...
@@ -171,6 +173,7 @@ def applyEOS(config) :
if
config
.
isMultiword
(
index
)
or
not
isEmpty
(
config
.
getAsFeature
(
index
,
"
HEAD
"
))
:
continue
config
.
set
(
index
,
"
HEAD
"
,
str
(
rootIndex
))
config
.
predChilds
[
rootIndex
].
append
(
index
)
################################################################################
################################################################################
...
...
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