mirror of
https://github.com/lovell/sharp.git
synced 2025-07-09 02:30:12 +02:00
Docs: keyword search improvements
This commit is contained in:
parent
53dd313e97
commit
fabe720b9b
File diff suppressed because one or more lines are too long
@ -1,65 +1,6 @@
|
||||
'use strict';
|
||||
|
||||
const stopWords = [
|
||||
'a',
|
||||
'about',
|
||||
'all',
|
||||
'already',
|
||||
'always',
|
||||
'an',
|
||||
'and',
|
||||
'any',
|
||||
'are',
|
||||
'as',
|
||||
'at',
|
||||
'be',
|
||||
'been',
|
||||
'by',
|
||||
'can',
|
||||
'do',
|
||||
'does',
|
||||
'each',
|
||||
'either',
|
||||
'etc',
|
||||
'for',
|
||||
'from',
|
||||
'get',
|
||||
'gets',
|
||||
'has',
|
||||
'have',
|
||||
'how',
|
||||
'if',
|
||||
'in',
|
||||
'is',
|
||||
'it',
|
||||
'its',
|
||||
'may',
|
||||
'more',
|
||||
'much',
|
||||
'no',
|
||||
'not',
|
||||
'of',
|
||||
'on',
|
||||
'or',
|
||||
'over',
|
||||
'set',
|
||||
'sets',
|
||||
'should',
|
||||
'that',
|
||||
'the',
|
||||
'their',
|
||||
'there',
|
||||
'therefore',
|
||||
'these',
|
||||
'this',
|
||||
'to',
|
||||
'use',
|
||||
'using',
|
||||
'when',
|
||||
'which',
|
||||
'will',
|
||||
'with'
|
||||
];
|
||||
const stopWords = require('./stop-words');
|
||||
|
||||
const extractDescription = (str) =>
|
||||
str
|
||||
@ -71,10 +12,13 @@ const extractDescription = (str) =>
|
||||
.trim();
|
||||
|
||||
const extractKeywords = (str) =>
|
||||
str
|
||||
.split(/[ -/]/)
|
||||
.map((word) => word.toLowerCase().replace(/[^a-z]/g, ''))
|
||||
.filter((word) => word.length > 2 && !stopWords.includes(word))
|
||||
.join(' ');
|
||||
[
|
||||
...new Set(
|
||||
str
|
||||
.split(/[ -/]/)
|
||||
.map((word) => word.toLowerCase().replace(/[^a-z]/g, ''))
|
||||
.filter((word) => word.length > 2 && !stopWords.includes(word))
|
||||
)
|
||||
].join(' ');
|
||||
|
||||
module.exports = { extractDescription, extractKeywords };
|
||||
|
71
docs/search-index/stop-words.js
Normal file
71
docs/search-index/stop-words.js
Normal file
@ -0,0 +1,71 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = [
|
||||
'about',
|
||||
'after',
|
||||
'all',
|
||||
'already',
|
||||
'alternative',
|
||||
'always',
|
||||
'and',
|
||||
'any',
|
||||
'are',
|
||||
'been',
|
||||
'before',
|
||||
'can',
|
||||
'containing',
|
||||
'default',
|
||||
'does',
|
||||
'each',
|
||||
'either',
|
||||
'etc',
|
||||
'for',
|
||||
'from',
|
||||
'get',
|
||||
'gets',
|
||||
'given',
|
||||
'has',
|
||||
'have',
|
||||
'how',
|
||||
'image',
|
||||
'its',
|
||||
'may',
|
||||
'more',
|
||||
'most',
|
||||
'much',
|
||||
'must',
|
||||
'non',
|
||||
'not',
|
||||
'occur',
|
||||
'occurs',
|
||||
'over',
|
||||
'perform',
|
||||
'performs',
|
||||
'provide',
|
||||
'provided',
|
||||
'set',
|
||||
'sets',
|
||||
'should',
|
||||
'spelling',
|
||||
'support',
|
||||
'supported',
|
||||
'take',
|
||||
'that',
|
||||
'the',
|
||||
'their',
|
||||
'there',
|
||||
'therefore',
|
||||
'these',
|
||||
'this',
|
||||
'use',
|
||||
'used',
|
||||
'using',
|
||||
'value',
|
||||
'values',
|
||||
'when',
|
||||
'which',
|
||||
'while',
|
||||
'will',
|
||||
'with',
|
||||
'without'
|
||||
];
|
Loading…
x
Reference in New Issue
Block a user