diff --git a/libcorpus2/io/cclreader.cpp b/libcorpus2/io/cclreader.cpp index 49fcc03bec0127e915bf06026fe815474153443c..f796eb21018b94e432a301d1238ff73c2a008a54 100644 --- a/libcorpus2/io/cclreader.cpp +++ b/libcorpus2/io/cclreader.cpp @@ -140,9 +140,18 @@ void CclReaderImpl::start_chunk(const AttributeList& attributes) -void CclReaderImpl::start_sentence(const AttributeList& /*attributes*/) +void CclReaderImpl::start_sentence(const AttributeList &attributes) { - ann_sent_ = boost::make_shared<AnnotatedSentence>(); + // find sentence id + std::string id = ""; + foreach (const Attribute& a, attributes) { + if (a.name == "id") { + id = a.value; + break; + } + } + + ann_sent_ = boost::make_shared<AnnotatedSentence>(id); sent_ = ann_sent_; state_ = STATE_SENTENCE; } diff --git a/libcorpus2/io/cclwriter.cpp b/libcorpus2/io/cclwriter.cpp index 221d6a337a232f335f6e74a7754ad0f7af770cff..4909291996ac478a6a1ada2b654ac37241d19da2 100644 --- a/libcorpus2/io/cclwriter.cpp +++ b/libcorpus2/io/cclwriter.cpp @@ -33,7 +33,15 @@ void CclWriter::write_sentence(const Sentence& s) void CclWriter::write_sentence_int(const Sentence &s) { const AnnotatedSentence* ann = dynamic_cast<const AnnotatedSentence*>(&s); - osi() << "<sentence>\n"; + + std::string id = s.id(); + if (id == "") { + osi() << "<sentence>\n"; + } + else { + osi() << "<sentence id=\"" << id << "\">\n"; + } + if (use_indent_) indent_more(); for (size_t idx = 0; idx < s.size(); ++idx) { const Token* t = s.tokens()[idx];