| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "smetanin_d_sent_num/seq/include/ops_seq.hpp" | ||
| 2 | |||
| 3 | #include <cstddef> | ||
| 4 | |||
| 5 | #include "smetanin_d_sent_num/common/include/common.hpp" | ||
| 6 | |||
| 7 | namespace smetanin_d_sent_num { | ||
| 8 | |||
| 9 |
1/2✓ Branch 1 taken 40 times.
✗ Branch 2 not taken.
|
40 | SmetaninDSentNumSEQ::SmetaninDSentNumSEQ(const InType &in) { |
| 10 | SetTypeOfTask(GetStaticTypeOfTask()); | ||
| 11 | GetInput() = in; | ||
| 12 | 40 | GetOutput() = 0; | |
| 13 | 40 | } | |
| 14 | |||
| 15 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | bool SmetaninDSentNumSEQ::ValidationImpl() { |
| 16 | const InType &source_data = GetInput(); | ||
| 17 | const OutType ¤t_output = GetOutput(); | ||
| 18 |
2/4✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 40 times.
|
40 | return !source_data.empty() && current_output == 0; |
| 19 | } | ||
| 20 | |||
| 21 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | bool SmetaninDSentNumSEQ::PreProcessingImpl() { |
| 22 | InType &source_text = GetInput(); | ||
| 23 |
1/2✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
|
40 | if (!source_text.empty()) { |
| 24 |
2/2✓ Branch 0 taken 8 times.
✓ Branch 1 taken 32 times.
|
40 | if (GetInput()[0] == '.' || GetInput()[0] == '!' || GetInput()[0] == '?') { |
| 25 | 8 | GetInput()[0] = ' '; | |
| 26 | } | ||
| 27 | } | ||
| 28 | 40 | return true; | |
| 29 | } | ||
| 30 | |||
| 31 | 40 | bool SmetaninDSentNumSEQ::RunImpl() { | |
| 32 | const InType &text_data = GetInput(); | ||
| 33 | std::size_t text_length = text_data.length(); | ||
| 34 | std::size_t sentence_count = 0; | ||
| 35 | |||
| 36 |
2/2✓ Branch 0 taken 41960 times.
✓ Branch 1 taken 40 times.
|
42000 | for (std::size_t current_position = 0; current_position < text_length; ++current_position) { |
| 37 | 41960 | char current_char = text_data[current_position]; | |
| 38 | |||
| 39 |
4/4✓ Branch 0 taken 40472 times.
✓ Branch 1 taken 1488 times.
✓ Branch 2 taken 39920 times.
✓ Branch 3 taken 552 times.
|
41960 | if (current_char != '.' && current_char != '!' && current_char != '?') { |
| 40 | 39920 | continue; | |
| 41 | } | ||
| 42 | |||
| 43 |
1/2✓ Branch 0 taken 2040 times.
✗ Branch 1 not taken.
|
2040 | if (current_position > 0) { |
| 44 |
2/2✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 848 times.
|
2040 | char previous_char = text_data[current_position - 1]; |
| 45 |
2/2✓ Branch 0 taken 1192 times.
✓ Branch 1 taken 848 times.
|
2040 | if (previous_char == '.' || previous_char == '!' || previous_char == '?') { |
| 46 | 1192 | continue; | |
| 47 | } | ||
| 48 | } | ||
| 49 | |||
| 50 | 848 | sentence_count++; | |
| 51 | } | ||
| 52 | |||
| 53 |
2/2✓ Branch 0 taken 32 times.
✓ Branch 1 taken 8 times.
|
40 | if (sentence_count > 0) { |
| 54 | 32 | GetOutput() = static_cast<OutType>(sentence_count); | |
| 55 | } else { | ||
| 56 | 8 | GetOutput() = 0; | |
| 57 | } | ||
| 58 | |||
| 59 | 40 | return true; | |
| 60 | } | ||
| 61 | |||
| 62 | 40 | bool SmetaninDSentNumSEQ::PostProcessingImpl() { | |
| 63 | 40 | return true; | |
| 64 | } | ||
| 65 | |||
| 66 | } // namespace smetanin_d_sent_num | ||
| 67 |