3 ms·
Wow, oddly relevant - I've been working on a RegExp implementation in JavaScript using similar techniques (minus vectorization of course, RIP SIMD.js). There is
by bterlson 9y ago
Wow, oddly relevant - I've been working on a RegExp implementation in JavaScript using similar techniques (minus vectorization of course, RIP SIMD.js). There is no efficient way in JavaScript to replace many patterns (e.g. a list of sentence fragments with optional whitespace, capitalization, pluralization, etc.) against a large document where the replacement requires metadata about the subpattern that was matched (e.g. to replace a term with a link to the term's definition).
I wonder if I should switch gears and try to write a native Node module for this instead. This looks really great.
- glangdale 9y agoThanks for the kind words. You'll have to roll your own 'replace', and the all-matches semantics of Hyperscan may give you some headaches - you'll need a careful reading of our Start of Match semantics and to craft patterns that yield "less surprising results". If you can share your workload, or want assistance in figuring out whether to do this and/or how to do it, please contact us on the mailing list or on the email link for Hyperscan on 01.org. We're always interested in sample patterns, especially ones that fall outside our normal wheelhouse of 'network security and then some more network security'.
- time4tea 9y agoWell depends on how big and how fast. This worked for me https://github.com/time4tea/glossary/blob/master/README.md https://github.com/time4tea/glossary/blob/master/README.md Its a very simple Aho-Corasick text search with replacement. A similar thing in Java using Ropes rather than Strings was also ok, for some value of ok.