diff --git a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java index faa5418566..cf9fc89c35 100644 --- a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java +++ b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java @@ -2551,7 +2551,9 @@ public static SentenceFragment fromProto(CoreNLPProtos.SentenceFragment fragment * @return A Java Map corresponding to the serialized map. */ public static HashMap fromProto(CoreNLPProtos.MapStringString proto) { - HashMap map = new HashMap<>(); + // LinkedHashMap so that the pieces stay in the order we receive them + // (could also use a TreeMap instead to enforce sorted by key) + HashMap map = new LinkedHashMap<>(); for (int i = 0; i < proto.getKeyCount(); ++i) { map.put(proto.getKey(i), proto.getValue(i)); }