Skip to content

Commit d8d9d9f

Browse files
committed
Making this an IdentityHashSet hilariously makes the graph serialization stop working for sentences longer than N words. The problem is that the identity of an integer isn't cached beyond some predefined limit, 128 for a standard Integer
1 parent 117615c commit d8d9d9f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -832,7 +832,7 @@ public CoreNLPProtos.DependencyGraph toProto(SemanticGraph graph) {
832832
public CoreNLPProtos.DependencyGraph toProto(SemanticGraph graph, boolean storeTokens) {
833833
CoreNLPProtos.DependencyGraph.Builder builder = CoreNLPProtos.DependencyGraph.newBuilder();
834834
// Roots
835-
Set<Integer> rootSet = graph.getRoots().stream().map(IndexedWord::index).collect(Collectors.toCollection(IdentityHashSet::new));
835+
Set<Integer> rootSet = graph.getRoots().stream().map(IndexedWord::index).collect(Collectors.toCollection(HashSet::new));
836836
// Nodes
837837
for (IndexedWord node : graph.vertexSet()) {
838838
// Register node

0 commit comments

Comments
 (0)