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

Punctuation in the word segmenter #137

Open
my2iu opened this issue Apr 20, 2021 · 0 comments
Open

Punctuation in the word segmenter #137

my2iu opened this issue Apr 20, 2021 · 0 comments

Comments

@my2iu
Copy link

my2iu commented Apr 20, 2021

I’m trying to build a line breaking algorithm on top of the word segmenter, so that I can lay out some text in paragraphs in svg. The current Intl.Segmenter seems to put words and punctuation into different segments, so that “Who? Why?” becomes 5 segments: “who,” “?,” “ ,” “why,” and “?”

When laying out text in paragraphs, I usually want the punctuation to stay glued to the nearest word, but there isn’t enough information coming back from the segmenter to do this. It might be nice if the segmenter had an option to include punctuation with words during segmentation, or if the segment iterator returned additional information beyond “isWordLike.” Perhaps “isWhitespace” and/or “isPunctuation” would be enough, but I’m not sure.

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

No branches or pull requests

1 participant