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

Function LeftWordAttributes

deps/tesseract/ccmain/paragraphs.cpp:394–434  ·  view source on GitHub ↗

Given the leftmost 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

392// starts_idea - this word is likely to start a sentence.
393// ends_idea - this word is likely to end a sentence.
394void LeftWordAttributes(const UNICHARSET *unicharset, const WERD_CHOICE *werd,
395 const STRING &utf8,
396 bool *is_list, bool *starts_idea, bool *ends_idea) {
397 *is_list = false;
398 *starts_idea = false;
399 *ends_idea = false;
400 if (utf8.size() == 0 || (werd != NULL && werd->length() == 0)) { // Empty
401 *ends_idea = true;
402 return;
403 }
404
405 if (unicharset && werd) { // We have a proper werd and unicharset so use it.
406 if (UniLikelyListItem(unicharset, werd)) {
407 *is_list = true;
408 *starts_idea = true;
409 *ends_idea = true;
410 }
411 if (unicharset->get_isupper(werd->unichar_id(0))) {
412 *starts_idea = true;
413 }
414 if (unicharset->get_ispunctuation(werd->unichar_id(0))) {
415 *starts_idea = true;
416 *ends_idea = true;
417 }
418 } else { // Assume utf8 is mostly ASCII
419 if (AsciiLikelyListItem(utf8)) {
420 *is_list = true;
421 *starts_idea = true;
422 }
423 int start_letter = utf8[0];
424 if (IsOpeningPunct(start_letter)) {
425 *starts_idea = true;
426 }
427 if (IsTerminalPunct(start_letter)) {
428 *ends_idea = true;
429 }
430 if (start_letter >= 'A' && start_letter <= 'Z') {
431 *starts_idea = true;
432 }
433 }
434}
435
436// Given the rightmost word of a line either as a Tesseract unicharset + werd
437// or a utf8 string, set the following attributes for it:

Callers 1

InitializeRowInfoFunction · 0.85

Calls 9

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

Tested by

no test coverage detected