Dynamically calculated max num components

This commit is contained in:
Ozbolt Menegatti 2019-06-10 14:05:40 +02:00
parent c0a22a4ef3
commit d30f8c1980

View File

@ -20,7 +20,7 @@ except ImportError:
tqdm = lambda x: x
MAX_NUM_COMPONENTS = 5
MAX_NUM_COMPONENTS = -1
CODES = {
"Noun": "N",
@ -782,12 +782,17 @@ def load_structures(filename):
return build_structures(et), get_lemma_features(et)
def build_structures(et):
global MAX_NUM_COMPONENTS
structures = []
for structure in et.iter('syntactic_structure'):
to_append = SyntacticStructure.from_xml(structure)
if to_append is None:
continue
structures.append(to_append)
MAX_NUM_COMPONENTS = max(MAX_NUM_COMPONENTS, len(to_append.components))
return structures
def get_lemma_features(et):