Skip to content

Commit e20c132

Browse files
Fixes issue with corpus construction: if a single split was built on the first use of UDSCorpus, no other splits could be built based on incorrect logic in the first branch of UDSCorpus.__init__ (lines 76-81)
1 parent 79ada2f commit e20c132

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

decomp/semantics/uds.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,27 +73,27 @@ def __init__(self,
7373
errmsg = 'split must be "train", "dev", or "test"'
7474
raise ValueError(errmsg)
7575

76-
if graphs is None and self._corpus_paths:
77-
self._graphs = {}
76+
all_built = all(s in self._corpus_paths
77+
for s in ['train', 'dev', 'test'])
7878

79-
if split is not None:
80-
fpath = self._corpus_paths[split]
79+
self._graphs = {}
80+
81+
if graphs is None and split in self._corpus_paths:
82+
fpath = self._corpus_paths[split]
83+
corp_split = self.__class__.from_json(fpath)
84+
self._graphs.update(corp_split._graphs)
85+
86+
elif graphs is None and split is None and all_built:
87+
for fpath in self._corpus_paths.values():
8188
corp_split = self.__class__.from_json(fpath)
8289
self._graphs.update(corp_split._graphs)
8390

84-
else:
85-
for fpath in self._corpus_paths.values():
86-
corp_split = self.__class__.from_json(fpath)
87-
self._graphs.update(corp_split._graphs)
88-
8991
elif graphs is None:
9092
url = 'https://github.com/UniversalDependencies/' +\
9193
'UD_English-EWT/archive/r1.2.zip'
9294

9395
udewt = requests.get(url).content
9496

95-
self._graphs = {}
96-
9797
with ZipFile(BytesIO(udewt)) as zf:
9898
conll_names = [fname for fname in zf.namelist()
9999
if splitext(fname)[-1] == '.conllu']

0 commit comments

Comments
 (0)