#1508·CoreNLP

CoNLLUDocumentWriter overwrites refined enhanced relations with the basic relation

Author: AngledLuffaCreated Sep 21, 2026Updated Sep 21, 2026

CoNLLUDocumentWriter overwrites refined enhanced relations with the basic relation

Summary

When CoNLLUDocumentWriter.printSemanticGraph is given a null enhanced graph, it rebuilds the DEPS column from each word's CoNLLUSecondaryDepsAnnotation and then adds the basic arc. The basic arc is added with put, so wherever an enhanced arc shares its governor with the basic arc, the enhanced relation is replaced by the basic one: obl:in becomes obl, conj:and becomes conj, nmod:of becomes nmod.

Where

CoNLLUDocumentWriter.printSemanticGraph, in the branch taken when enhancedSg == null:

java
HashMap<String, String> secondaryDeps = token.get(CoreAnnotations.CoNLLUSecondaryDepsAnnotation.class);
if (secondaryDeps != null) {
  enhancedDependencies.putAll(token.get(CoreAnnotations.CoNLLUSecondaryDepsAnnotation.class));
  //add basic dependency
  if (gov != null) {
    enhancedDependencies.put(govIdx, reln.toString());
  }
}

Cause

CoNLLUSecondaryDepsAnnotation is documented as a "list of secondary dependencies" — the arcs beyond the basic one. The writer is consistent with that: it takes the secondary arcs and adds the basic arc back.

CoNLLUDocumentReader does not follow that contract. It parses the entire DEPS column into the annotation, and the DEPS column already contains the basic arc, usually in a refined form. Adding the basic arc back then collides with the refined version of the same arc, and put keeps the basic one.

The map is keyed by governor index, so only enhanced arcs whose governor matches the basic governor are affected.

Reproduction

Input, read with CoNLLUDocumentReader and written with a null enhanced graph:

4	Paris	Paris	PROPN	NNP	_	2	obl	2:obl:in	_
6	London	London	PROPN	NNP	_	4	conj	2:obl:in|4:conj:and	SpaceAfter=No

Output:

4	Paris	Paris	PROPN	NNP	Number=Sing	2	obl	2:obl	_
6	London	London	PROPN	NNP	Number=Sing	4	conj	2:obl:in|4:conj	SpaceAfter=No

Paris loses :in because its enhanced governor (2) is its basic governor. On London, obl:in survives because its governor (2) is not London's basic governor (4), while conj:and loses :and because its governor is.

Who is affected

Anything that passes a null enhanced graph while the words carry CoNLLUSecondaryDepsAnnotation:

  • UniversalDependenciesFeatureAnnotator, which always writes with a null enhanced graph, so every relation it writes that shares a governor with its basic arc has been losing its specific.
  • UniversalDependenciesConverter -outputRepresentation basic on an input that has a DEPS column, when reading with CoNLLUDocumentReader.
  • Annotations deserialized by ProtobufAnnotationSerializer, which also sets CoNLLUSecondaryDepsAnnotation. This keeps the path reachable even once CoNLLUDocumentReader is no longer used.

pipeline.CoNLLUReader never sets the annotation, so the tools which have moved to it no longer reach this branch through the reader.

Proposed fix

java
enhancedDependencies.putIfAbsent(govIdx, reln.toString());

This is correct under either reading of the annotation. If it holds only the secondary arcs, the basic governor is absent and the basic arc is added, as now. If it holds the whole DEPS column, the refined arc is already present and is kept.

Test

UniversalDependenciesFeatureAnnotatorTest.testSharedGovernorLosesTheSpecific pins the current behaviour. With the fix it should change to 2:obl:in for Paris and 2:obl:in|4:conj:and for London.