Comments (5)
Alright, cool, got it. Will investigate
from highlight-words.
Hey @karlhorky,
To make this clear, let's use an example.
const text = 'My dog is a very good boy and is always eating his lunch.';
const chunks = highlightWords({
text,
query: 'is',
clipBy: 3
});
By default, you'd get chunks like:
[
{
"text": "... My dog ",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": " a very ... boy and ",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": " always eating h",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": " lunch",
"match": false
}
]
And this will clip whole words. If you introduce a new option to clip by characters, then you'll get something like:
[
{
"text": "... My ",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": " a ve ...",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": "... g h",
"match": false
},
{
"text": "is",
"match": true
},
{
"text": " lu ...",
"match": false
}
]
Just want to be sure I got this right and I will investigate the implications.
from highlight-words.
Ah, not quite - it would count the 3 characters from the edge closest to the match, just like your algorithm counts the number of words from the matching edge.
I've added an example to the original description above, with 7 characters instead of 3.
from highlight-words.
@tricinel any news on this?
from highlight-words.
Nothing, no. I doubt this will make it in to be honest, as I see less use cases for having cut-up characters rather than words. Also from an accessibility stand point, I can imagine a screen reader just reciting letters and it pains me
from highlight-words.
Related Issues (10)
- ESM Support HOT 14
- Regular expresion in query param? HOT 11
- Invalid query type HOT 2
- This work with IE browser? HOT 1
- Query words with double spaces HOT 4
- Option to ignore diacritics HOT 1
- Declaration file not found with `Node16` module + moduleResolution HOT 12
- Option Proposal: `maxLength` HOT 9
- Investigate potential performance issues HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from highlight-words.