Feat/options api pattern refactor - #5
Merged
Conversation
BREAKING CHANGE: findAll/contains take an options object instead of a
positional boolean. `findAll(text, true)` -> `findAll(text, { relaxed: true })`
- src/lib/patterns.ts: patterns are now declared as data (id/label/strict/
source/samples) instead of being baked into one giant regex literal, and
each pattern's samples auto-generate coverage in test/patterns.test.ts
- src/lib/regex.ts: builds regexStrict/regexRelaxed from the patterns list;
strict patterns are always ordered before relaxed-only ones so greedy
matches (e.g. "(?:爆笑){2,}") aren't shadowed by shorter relaxed-only
alternatives
- fixed a latent bug where the "(笑)" branch after a stem required a
trailing space, causing findAll to drop the stem from the match
(e.g. findAll("うお(笑)") returned ["(笑)"] instead of ["うお(笑)"])
- added new strict patterns (うわ/さむ/いた/きも, 🙄/😏/🤡, 笑2回以上) and
new relaxed-only patterns (😑/🙃/💀/🫠)
- README/CONTRIBUTING updated for the new API and the patterns.ts workflow
…ne endings - src/lib/patterns.ts: drop the unused `label` field from PatternDefinition (id/strict/source/samples only); merge the "新規追加候補" stems into the regular strict stem section - add ❗/❓/⁉️ as strict emoji patterns (alongside the existing‼️ ) - add phrase-based patterns sourced from https://note.com/kido_meigen/n/nc0fb2d47f6f6 and https://w.atwiki.jp/reisyou/pages/10.html: strict: かっこよ/えぐ/ど、どした/冗談ですやん/必死やん/そういうノリ relaxed-only (common enough alone that strict felt too aggressive): ちょ/ったく/おもろいな(あ)/すごいな(あ) skipped as too narrow or too likely to false-positive: よせやい/ あたぼうよ/あらよっと/てやんでい (obscure, single-copypasta-specific), the "教養🤣" meme (one specific tweet, not a general construction) - extend STEM_SUFFIX to optionally allow "!/?" before the w/笑 marker so phrases like "えぐー!笑" and "ど、どした?笑" match as one token - test/patterns.test.ts: drop label from describe() titles - .prettierrc.json / .gitattributes: adopt oto-lab/npm-eslint-prettier-ts's settings, in particular `* text=auto eol=lf` so Windows checkouts stop drifting from the LF committed in the repo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.