From d30f8c1980e6353d5c31019c55e4a9b8aeb0064f Mon Sep 17 00:00:00 2001 From: Ozbolt Menegatti Date: Mon, 10 Jun 2019 14:05:40 +0200 Subject: [PATCH] Dynamically calculated max num components --- wani.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wani.py b/wani.py index b4fb3fb..76def42 100644 --- a/wani.py +++ b/wani.py @@ -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):