| 202 | typename sequence_type |
| 203 | > |
| 204 | bool is_sequence_segmentation_problem ( |
| 205 | const std::vector<sequence_type>& samples, |
| 206 | const std::vector<std::vector<std::pair<unsigned long,unsigned long> > >& segments |
| 207 | ) |
| 208 | { |
| 209 | if (is_learning_problem(samples, segments)) |
| 210 | { |
| 211 | for (unsigned long i = 0; i < samples.size(); ++i) |
| 212 | { |
| 213 | // Make sure the segments are inside samples[i] and don't overlap with each |
| 214 | // other. |
| 215 | std::vector<bool> hits(samples[i].size(), false); |
| 216 | for (unsigned long j = 0; j < segments[i].size(); ++j) |
| 217 | { |
| 218 | const unsigned long begin = segments[i][j].first; |
| 219 | const unsigned long end = segments[i][j].second; |
| 220 | // if the segment is outside the sequence |
| 221 | if (end > samples[i].size()) |
| 222 | return false; |
| 223 | |
| 224 | if (begin >= end) |
| 225 | return false; |
| 226 | |
| 227 | // check for overlap |
| 228 | for (unsigned long k = begin; k < end; ++k) |
| 229 | { |
| 230 | if (hits[k]) |
| 231 | return false; |
| 232 | hits[k] = true; |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | return true; |
| 237 | } |
| 238 | |
| 239 | return false; |
| 240 | } |
| 241 | |
| 242 | // ---------------------------------------------------------------------------------------- |
| 243 | |