Redmine #1487: added error messages to assert statements

This commit is contained in:
Cyprian Laskowski 2022-09-30 15:09:59 +02:00
parent 8d453eb20b
commit 2e2a523eed

View File

@ -85,9 +85,9 @@ class Runner:
else:
classla_columns = classla_line.split('\t')
tagged_columns = tagged_line.split('\t')
assert len(classla_columns) == len(tagged_columns) == 10 # conllu columns
assert classla_columns[0] == tagged_columns[0] # match index
assert classla_columns[1] == tagged_columns[1] # match token
assert len(classla_columns) == 10, 'Missing token in classla-generated conllu ({})'.format(len(tagged_line)
assert len(tagged_columns) == 10, 'Missing token in pre-tagged conllu ({})'.format(len(classla_line)
assert classla_columns[1] == tagged_columns[1], 'Pre-tagged token form ({}) does not match classla-generated token form ({}).'.format(classla_tokens[0], tagged_columns[0])
merged_columns = [classla_columns[i] if i in (3,5,9) else tagged_columns[i] for i in range(10)]
merged_line = '\t'.join(merged_columns)
merged_conllu_file.write(merged_line + '\n')