diff --git a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java index 700a41ac84..eca5aaa23a 100644 --- a/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java +++ b/src/edu/stanford/nlp/pipeline/ProtobufAnnotationSerializer.java @@ -2390,7 +2390,6 @@ private static SemanticGraph fromProto(CoreNLPProtos.DependencyGraph proto, List max = in.getIndex() > max ? in.getIndex() : max; } // map from index, emptyIndex, copy -> IndexedWord - // TODO: still need to add the empty index to the proto, then use it here to build the graph ThreeDimensionalMap nodes = new ThreeDimensionalMap<>(); // map from index, emptyIndex -> CoreLabel TwoDimensionalMap originalLabels = TwoDimensionalMap.hashMap(); @@ -2416,8 +2415,7 @@ private static SemanticGraph fromProto(CoreNLPProtos.DependencyGraph proto, List if (document.isPresent()) { token = document.get().get(SentencesAnnotation.class).get(in.getSentenceIndex()).get(TokensAnnotation.class).get(in.getIndex() - 1); // token index starts at 1! } else { - // TODO: index based on emptyIndex as well - token = originalLabels.get(in.getIndex(), 0); + token = originalLabels.get(in.getIndex(), in.getEmptyIndex()); if (token == null) { throw new NullPointerException("Could not find the token for index " + in.getIndex()); } @@ -2449,12 +2447,11 @@ private static SemanticGraph fromProto(CoreNLPProtos.DependencyGraph proto, List // add all edges to the actual graph for(CoreNLPProtos.DependencyGraph.Edge ie: proto.getEdgeList()){ - // TODO: source and target should index on emptyIndex as well - IndexedWord source = nodes.get(ie.getSource(), 0, ie.getSourceCopy()); + IndexedWord source = nodes.get(ie.getSource(), ie.getSourceEmpty(), ie.getSourceCopy()); if (source == null) { throw new AssertionError("Source of a dependency was null! Edge: " + ie); } - IndexedWord target = nodes.get(ie.getTarget(), 0, ie.getTargetCopy()); + IndexedWord target = nodes.get(ie.getTarget(), ie.getTargetEmpty(), ie.getTargetCopy()); if (target == null) { throw new AssertionError("Target of a dependency was null! Edge: " + ie); }