Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charfreq: use PCRE to operate on grapheme clusters instead of codepoints #375

Merged
merged 1 commit into from
Mar 2, 2024

Conversation

bertsky
Copy link
Collaborator

@bertsky bertsky commented Mar 2, 2024

No description provided.

@bertsky bertsky requested a review from stweil March 2, 2024 10:11
@zdenop zdenop merged commit b2a5a29 into tesseract-ocr:main Mar 2, 2024
2 checks passed
@stweil
Copy link
Collaborator

stweil commented Mar 2, 2024

This pull request was merged too fast, because the new code does not work at all on macOS:

% LC_ALL=C.UTF-8 grep -P -o /tmp/test2        
grep: invalid option -- P
usage: grep [-abcdDEFGHhIiJLlMmnOopqRSsUVvwXxZz] [-A num] [-B num] [-C[num]]
        [-e pattern] [-f file] [--binary-files=value] [--color=when]
        [--context[=num]] [--directories=action] [--label] [--line-buffered]
        [--null] [pattern] [file ...]
% grep --version
grep (BSD grep, GNU compatible) 2.6.0-FreeBSD

I'll fix that by using Python code which is more portable.

@bertsky
Copy link
Collaborator Author

bertsky commented Mar 2, 2024

@stweil then please just make a conditional on OS (as with dos2unix), and have Mac just use plain regexes on codepoints instead of grapheme clusters.

(Of course, this is doable in Python, but the point of that target is to be as simple and fast as possible, without dependencies.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants