MCPcopy Create free account
hub / github.com/creatale/node-dv / RightWordAttributes

Function RightWordAttributes

deps/tesseract/ccmain/paragraphs.cpp:441–471  ·  view source on GitHub ↗

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.

Source from the content-addressed store, hash-verified

439// starts_idea - this word is likely to start a sentence.
440// ends_idea - this word is likely to end a sentence.
441void 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 */

Callers 1

InitializeRowInfoFunction · 0.85

Calls 8

UniLikelyListItemFunction · 0.85
AsciiLikelyListItemFunction · 0.85
IsOpeningPunctFunction · 0.85
IsTerminalPunctFunction · 0.85
unichar_idMethod · 0.80
get_ispunctuationMethod · 0.80
sizeMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected