{"record":{"id":"159ba71814201716","repo":"hankcs/HanLP","slug":"the-main-dependency-conflicts-with-2nd-dependency","errorCode":null,"errorMessage":"The main dependency conflicts with 2nd dependency at ID={i}, which means joint mode might not be suitable. The sample is\n{sample_str}","messagePattern":"The main dependency conflicts with 2nd dependency at ID=(.+?), which means joint mode might not be suitable\\. The sample is\n(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"hanlp/datasets/parsing/semeval15.py","lineNumber":56,"sourceCode":"    return sample\n\n\ndef append_bos_to_form_pos(sample, pos_key='CPOS'):\n    sample['token'] = [ROOT] + sample['FORM']\n    if pos_key in sample:\n        sample['pos'] = [ROOT] + sample[pos_key]\n    return sample\n\n\ndef merge_head_deprel_with_2nd(sample: dict):\n    if 'arc' in sample:\n        arc_2nd = sample['arc_2nd']\n        rel_2nd = sample['rel_2nd']\n        for i, (arc, rel) in enumerate(zip(sample['arc'], sample['rel'])):\n            if i:\n                if arc_2nd[i][arc] and rel_2nd[i][arc] != rel:\n                    sample_str = CoNLLSentence.from_dict(sample, conllu=True).to_markdown()\n                    warnings.warn(f'The main dependency conflicts with 2nd dependency at ID={i}, ' \\\n                                  'which means joint mode might not be suitable. ' \\\n                                  f'The sample is\\n{sample_str}')\n                arc_2nd[i][arc] = True\n                rel_2nd[i][arc] = rel\n    return sample\n","sourceCodeStart":38,"sourceCodeEnd":62,"githubUrl":"https://github.com/hankcs/HanLP/blob/ddb1299bddff079e447af52ec12549c50636bfa8/hanlp/datasets/parsing/semeval15.py#L38-L62","documentation":"When merging main and second-order dependencies for SemEval-15 joint parsing, if the 2nd-best graph already has a different label for the head chosen by the main parser, the labels conflict and joint mode may be inconsistent; the full CoNLL sample is printed in the warning.","triggerScenarios":"Calling merge_head_deprel_with_2nd on a SemEval-15 sample where arc_2nd[i][arc] is True but rel_2nd[i][arc] != rel — i.e. both graphs pick the same head with different deprel labels.","commonSituations":"Preparing SemEval-15 data for joint dependency parsing; mismatched main/2nd annotations in the corpus or preprocessed files.","solutions":["Check the printed sample at the flagged ID to see which deprel is intended","If labels disagree, prefer non-joint (separate) decoding for that data or fix the source annotation","Ignore if occasional disagreement is acceptable for your training setup"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"for i, (arc, rel) in enumerate(zip(sample['arc'], sample['rel'])):\n    if i and sample['arc_2nd'][i][arc] and sample['rel_2nd'][i][arc] != rel:\n        conflicts.append(i)  # inspect before joint mode","typeGuard":null,"tryCatchPattern":"with warnings.catch_warnings():\n    warnings.filterwarnings('ignore', message='.*joint mode might not be suitable.*')\n    merged = merge_head_deprel_with_2nd(sample)","preventionTips":["Audit SemEval-15 samples for head/label conflicts before joint training","Fall back to non-joint parsing when conflicts are frequent"],"tags":["parsing","semeval","dataset"],"backgroundTag":"annotation-conflict-warning","analyzedSha":"ddb1299bddff079e447af52ec12549c50636bfa8","analyzedAt":"2026-08-27T03:36:54.287Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}