Skip to content

Commit

Permalink
Keep features in the order they are in when we receive them in a proto
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Mar 11, 2023
1 parent 901b0f0 commit 9ea4f39
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2551,7 +2551,9 @@ public static SentenceFragment fromProto(CoreNLPProtos.SentenceFragment fragment
* @return A Java Map corresponding to the serialized map.
*/
public static HashMap<String, String> fromProto(CoreNLPProtos.MapStringString proto) {
HashMap<String, String> 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<String, String> map = new LinkedHashMap<>();
for (int i = 0; i < proto.getKeyCount(); ++i) {
map.put(proto.getKey(i), proto.getValue(i));
}
Expand Down

0 comments on commit 9ea4f39

Please sign in to comment.