MCPcopy Create free account
hub / github.com/davisking/dlib / segment_sequence

Method segment_sequence

dlib/svm/sequence_segmenter.h:363–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

361 }
362
363 void segment_sequence (
364 const sample_sequence_type& x,
365 segmented_sequence_type& y
366 ) const
367 {
368 y.clear();
369 std::vector<unsigned long> labels;
370 labeler.label_sequence(x, labels);
371
372 if (feature_extractor::use_BIO_model)
373 {
374 // Convert from BIO tagging to the explicit segments representation.
375 for (unsigned long i = 0; i < labels.size(); ++i)
376 {
377 if (labels[i] == impl_ss::BEGIN)
378 {
379 const unsigned long begin = i;
380 ++i;
381 while (i < labels.size() && labels[i] == impl_ss::INSIDE)
382 ++i;
383
384 y.push_back(std::make_pair(begin, i));
385 --i;
386 }
387 }
388 }
389 else
390 {
391 // Convert from BILOU tagging to the explicit segments representation.
392 for (unsigned long i = 0; i < labels.size(); ++i)
393 {
394 if (labels[i] == impl_ss::BEGIN)
395 {
396 const unsigned long begin = i;
397 ++i;
398 while (i < labels.size() && labels[i] == impl_ss::INSIDE)
399 ++i;
400
401 y.push_back(std::make_pair(begin, i+1));
402 }
403 else if (labels[i] == impl_ss::UNIT)
404 {
405 y.push_back(std::make_pair(i, i+1));
406 }
407 }
408 }
409 }
410
411 friend void serialize(const sequence_segmenter& item, std::ostream& out)
412 {

Callers 1

Calls 4

label_sequenceMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected