this.impl.addSentence(sent.serialize());
for (CoreMap sentence : doc.get(SentencesAnnotation.class)) { builder.addSentence(toProto(sentence)); } keysToSerialize.remove(SentencesAnnotation.class); } else if (doc.containsKey(TokensAnnotation.class)) {
this.impl.addSentence(sent.serialize());
for (CoreMap sentence : doc.get(SentencesAnnotation.class)) { builder.addSentence(toProto(sentence)); } keysToSerialize.remove(SentencesAnnotation.class); } else if (doc.containsKey(TokensAnnotation.class)) {
/** * <p> * Bypass the tokenizer and sentence splitter -- axiomatically set the sentences for this document. * This is a VERY dangerous method to call if you don't know what you're doing. * The primary use case is for forcing single-sentence documents, where most of the fields in the document * do not matter. * </p> * * @param sentences The sentences to force for the sentence list of this document. */ void forceSentences(List<Sentence> sentences) { this.sentences = sentences; synchronized (impl) { this.impl.clearSentence(); for (Sentence sent : sentences) { this.impl.addSentence(sent.serialize()); } } }
/** * Serialize this Document as a Protocol Buffer. * This can be deserialized with the constructor {@link Document#Document(edu.stanford.nlp.pipeline.CoreNLPProtos.Document)}. * * @return The document as represented by a Protocol Buffer. */ public CoreNLPProtos.Document serialize() { synchronized (impl) { // Ensure we have sentences List<Sentence> sentences = sentences(); // Ensure we're saving the newest sentences // IMPORTANT NOTE: the clear below must come after we call #sentences() this.impl.clearSentence(); for (Sentence s : sentences) { this.impl.addSentence(s.serialize()); } // Serialize document return impl.build(); } }
/** * Serialize this Document as a Protocol Buffer. * This can be deserialized with the constructor {@link Document#Document(edu.stanford.nlp.pipeline.CoreNLPProtos.Document)}. * * @return The document as represented by a Protocol Buffer. */ public CoreNLPProtos.Document serialize() { synchronized (impl) { // Ensure we have sentences List<Sentence> sentences = sentences(); // Ensure we're saving the newest sentences // IMPORTANT NOTE: the clear below must come after we call #sentences() this.impl.clearSentence(); for (Sentence s : sentences) { this.impl.addSentence(s.serialize()); } // Serialize document return impl.build(); } }
/** * <p> * Bypass the tokenizer and sentence splitter -- axiomatically set the sentences for this document. * This is a VERY dangerous method to call if you don't know what you're doing. * The primary use case is for forcing single-sentence documents, where most of the fields in the document * do not matter. * </p> * * @param sentences The sentences to force for the sentence list of this document. */ void forceSentences(List<Sentence> sentences) { this.sentences = sentences; synchronized (impl) { this.impl.clearSentence(); for (Sentence sent : sentences) { this.impl.addSentence(sent.serialize()); } } }