Given the rightmost word of a line either as a Tesseract unicharset + werd or a utf8 string, set the following attributes for it: is_list - this word might be a list number or bullet. starts_idea - this word is likely to start a sentence. ends_idea - this word is likely to end a sentence.
| 439 | // starts_idea - this word is likely to start a sentence. |
| 440 | // ends_idea - this word is likely to end a sentence. |
| 441 | void RightWordAttributes(const UNICHARSET *unicharset, const WERD_CHOICE *werd, |
| 442 | const STRING &utf8, |
| 443 | bool *is_list, bool *starts_idea, bool *ends_idea) { |
| 444 | *is_list = false; |
| 445 | *starts_idea = false; |
| 446 | *ends_idea = false; |
| 447 | if (utf8.size() == 0 || (werd != NULL && werd->length() == 0)) { // Empty |
| 448 | *ends_idea = true; |
| 449 | return; |
| 450 | } |
| 451 | |
| 452 | if (unicharset && werd) { // We have a proper werd and unicharset so use it. |
| 453 | if (UniLikelyListItem(unicharset, werd)) { |
| 454 | *is_list = true; |
| 455 | *starts_idea = true; |
| 456 | } |
| 457 | UNICHAR_ID last_letter = werd->unichar_id(werd->length() - 1); |
| 458 | if (unicharset->get_ispunctuation(last_letter)) { |
| 459 | *ends_idea = true; |
| 460 | } |
| 461 | } else { // Assume utf8 is mostly ASCII |
| 462 | if (AsciiLikelyListItem(utf8)) { |
| 463 | *is_list = true; |
| 464 | *starts_idea = true; |
| 465 | } |
| 466 | int last_letter = utf8[utf8.size() - 1]; |
| 467 | if (IsOpeningPunct(last_letter) || IsTerminalPunct(last_letter)) { |
| 468 | *ends_idea = true; |
| 469 | } |
| 470 | } |
| 471 | } |
| 472 | |
| 473 | // =============== Implementation of RowScratchRegisters ===================== |
| 474 | /* static */ |
no test coverage detected