| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "gusev_d_sentence_count/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | #include <string> | ||
| 5 | |||
| 6 | #include "gusev_d_sentence_count/common/include/common.hpp" | ||
| 7 | |||
| 8 | namespace gusev_d_sentence_count { | ||
| 9 | |||
| 10 | namespace { | ||
| 11 | |||
| 12 | bool IsTerminator(char c) { | ||
| 13 | return (c == '.' || c == '!' || c == '?'); | ||
| 14 | } | ||
| 15 | |||
| 16 | } // namespace | ||
| 17 | |||
| 18 |
1/2✓ Branch 1 taken 128 times.
✗ Branch 2 not taken.
|
128 | GusevDSentenceCountSEQ::GusevDSentenceCountSEQ(const InType &in) { |
| 19 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 20 | GetInput() = in; | ||
| 21 | 128 | GetOutput() = 0; | |
| 22 | 128 | } | |
| 23 | |||
| 24 | 128 | bool GusevDSentenceCountSEQ::ValidationImpl() { | |
| 25 | 128 | return true; | |
| 26 | } | ||
| 27 | |||
| 28 | 128 | bool GusevDSentenceCountSEQ::PreProcessingImpl() { | |
| 29 | 128 | return true; | |
| 30 | } | ||
| 31 | |||
| 32 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
|
128 | bool GusevDSentenceCountSEQ::RunImpl() { |
| 33 | const std::string &data = GetInput(); | ||
| 34 | |||
| 35 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 120 times.
|
128 | if (data.empty()) { |
| 36 | 8 | GetOutput() = 0; | |
| 37 | 8 | return true; | |
| 38 | } | ||
| 39 | |||
| 40 | size_t sentences = 0; | ||
| 41 | size_t len = data.length(); | ||
| 42 | |||
| 43 |
2/2✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 120 times.
|
2232 | for (size_t i = 0; i < len; ++i) { |
| 44 |
2/2✓ Branch 0 taken 304 times.
✓ Branch 1 taken 1808 times.
|
2112 | if (IsTerminator(data[i])) { |
| 45 |
4/4✓ Branch 0 taken 208 times.
✓ Branch 1 taken 96 times.
✓ Branch 2 taken 112 times.
✓ Branch 3 taken 96 times.
|
304 | bool is_next_not_term = (i + 1 == len) || !IsTerminator(data[i + 1]); |
| 46 | if (is_next_not_term) { | ||
| 47 | 208 | sentences++; | |
| 48 | } | ||
| 49 | } | ||
| 50 | } | ||
| 51 | |||
| 52 | 120 | GetOutput() = sentences; | |
| 53 | 120 | return true; | |
| 54 | } | ||
| 55 | |||
| 56 | 128 | bool GusevDSentenceCountSEQ::PostProcessingImpl() { | |
| 57 | 128 | return true; | |
| 58 | } | ||
| 59 | |||
| 60 | } // namespace gusev_d_sentence_count | ||
| 61 |