Skip to content

Commit f9c01d4

Browse files
author
pupiera
committed
ARCHI: Changed the multiple constructors of GoldConfiguration to a single one with optional arguments.
1 parent 517446e commit f9c01d4

1 file changed

Lines changed: 16 additions & 21 deletions

File tree

  • parsebrain/processing/dependency_parsing/transition_based/configuration

parsebrain/processing/dependency_parsing/transition_based/configuration/configuration.py

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,25 @@ class GoldConfiguration:
2424
It only uses the position of the word in the sentence to identify them.
2525
This remove the ambiguity if there is multiple occurrence of the same word.
2626
'''
27-
28-
def __init__(self):
27+
def __init__(self, gov=None, label=None):
2928
self.heads = {} # the head of a given word
3029
self.deps = defaultdict(lambda: []) # the list of dependent of a given word (can be empty)
30+
if gov is not None:
31+
for i, g in enumerate(gov):
32+
self.heads[i + 1] = g
33+
deps = []
34+
for i, _ in enumerate(gov):
35+
tmp = []
36+
for y, gg in enumerate(gov):
37+
if i+1 == gg:
38+
tmp.append(y+1)
39+
for i, d in enumerate(deps):
40+
self.deps[i + 1] = d
41+
if label is not None:
42+
self.label = {} # the label between words i and the head.
43+
for i, l in enumerate(label):
44+
self.label[i + 1] = l
3145

32-
def __init__(self, gov):
33-
self.heads = {} # the head of a given word
34-
self.deps = defaultdict(lambda: []) # the list of dependent of a given word (can be empty)
35-
for i, g in enumerate(gov):
36-
self.heads[i + 1] = g
37-
deps = []
38-
for i, _ in enumerate(gov):
39-
tmp = []
40-
for y, gg in enumerate(gov):
41-
if i+1 == gg:
42-
tmp.append(y+1)
43-
for i, d in enumerate(deps):
44-
self.deps[i + 1] = d
45-
46-
def __init__(self, gov, label):
47-
self.__init__(gov)
48-
self.label = {} # the label between words i and the head.
49-
for i, l in enumerate(label):
50-
self.label[i + 1] = l
5146

5247
class Word:
5348
'''

0 commit comments

Comments
 (0)