Skip to content

Commit 9ea4f39

Browse files
committed
Keep features in the order they are in when we receive them in a proto
1 parent 901b0f0 commit 9ea4f39

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -2551,7 +2551,9 @@ public static SentenceFragment fromProto(CoreNLPProtos.SentenceFragment fragment
25512551
* @return A Java Map corresponding to the serialized map.
25522552
*/
25532553
public static HashMap<String, String> fromProto(CoreNLPProtos.MapStringString proto) {
2554-
HashMap<String, String> map = new HashMap<>();
2554+
// LinkedHashMap so that the pieces stay in the order we receive them
2555+
// (could also use a TreeMap instead to enforce sorted by key)
2556+
HashMap<String, String> map = new LinkedHashMap<>();
25552557
for (int i = 0; i < proto.getKeyCount(); ++i) {
25562558
map.put(proto.getKey(i), proto.getValue(i));
25572559
}

0 commit comments

Comments
 (0)