136 os << static_cast<BoWDocument>(d);
139 os <<
"## sentence breaks" << std::endl;
140 std::vector<BoWText::const_iterator>::const_iterator itSentBrk;
141 for (itSentBrk = d.m_sentenceBreaks.begin();
142 itSentBrk != d.m_sentenceBreaks.end(); itSentBrk ++) {
143 os << (**itSentBrk)->getOutputUTF8String() << std::endl;
147 os <<
"## topic shifts" << std::endl;
151 std::vector<BoWText::const_iterator>::const_iterator itTopSht;
152 for (itTopSht = d.m_topicShifts.begin();
153 itTopSht != d.m_topicShifts.end(); itTopSht ++) {
154 os << (**itTopSht)->getOutputUTF8String() << std::endl;
175 std::map<uint64_t, BoWText::const_iterator> indexToIterator;
176 uint64_t tokenCounter = 1;
177 for (BoWText::const_iterator itTok = this->begin();
178 itTok != this->end(); itTok ++) {
179 indexToIterator[tokenCounter] = itTok;
187 for (uint64_t sentBrkInd = 1; sentBrkInd <= sentBrkNb; sentBrkInd ++) {
189 std::map<uint64_t, BoWText::const_iterator>::const_iterator itMap =
190 indexToIterator.find(sentBrkIndex);
191 if (itMap != indexToIterator.end()) {
192 m_sentenceBreaks.push_back(itMap->second);
195 throw std::runtime_error(
"invalid sentence break reference\n");
203 for (uint64_t topShtInd = 1; topShtInd <= topShtNb; topShtInd ++) {
205 std::map<uint64_t, BoWText::const_iterator>::const_iterator itMap =
206 indexToIterator.find(topShtIndex);
207 if (itMap != indexToIterator.end()) {
208 m_topicShifts.push_back(itMap->second);
211 throw std::runtime_error(
"invalid topic shift reference\n");
233 std::vector<uint64_t> sentenceBreaks;
234 std::vector<uint64_t> topicShifts;
235 uint64_t tokenCounter = 1;
236 std::vector<BoWText::const_iterator>::const_iterator itSentBrk = m_sentenceBreaks.begin();
237 std::vector<BoWText::const_iterator>::const_iterator itTopSht = m_topicShifts.begin();
238 for (BoWText::const_iterator itTok = this->begin();
239 itTok != this->end(); itTok ++) {
240 if ((itSentBrk != m_sentenceBreaks.end()) && (*itTok == **itSentBrk)) {
241 sentenceBreaks.push_back(tokenCounter);
244 if ((itTopSht != m_topicShifts.end()) && (*itTok == **itTopSht)) {
247 topicShifts.push_back(tokenCounter);
252 if (itTopSht != m_topicShifts.end()) {
254 std::ostringstream oss;
256 oss << (**itTopSht)->getOutputUTF8String() <<
" "; itTopSht++;
257 }
while (itTopSht != m_topicShifts.end());
258 LERROR <<
"Write BoWDocumentST: missing topic shifts on tokens "
261 if (itSentBrk != m_sentenceBreaks.end()) {
263 std::ostringstream oss;
265 oss << (**itSentBrk)->getOutputUTF8String() <<
" "; itSentBrk++;
266 }
while (itSentBrk != m_sentenceBreaks.end());
267 LERROR <<
"Write BoWDocumentST: missing sentence breaks on tokens "
275 for (std::vector<uint64_t>::const_iterator itSent = sentenceBreaks.begin();
276 itSent != sentenceBreaks.end(); itSent ++) {
283 for (std::vector<uint64_t>::const_iterator itTop = topicShifts.begin();
284 itTop != topicShifts.end(); itTop ++) {
BoWText & operator=(const BoWText &)