Docs: keyword search improvements

This commit is contained in:
Lovell Fuller 2020-11-16 15:10:28 +00:00
parent 53dd313e97
commit fabe720b9b
3 changed files with 81 additions and 66 deletions

File diff suppressed because one or more lines are too long

View File

@ -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) =>
[
...new Set(
str
.split(/[ -/]/)
.map((word) => word.toLowerCase().replace(/[^a-z]/g, ''))
.filter((word) => word.length > 2 && !stopWords.includes(word))
.join(' ');
)
].join(' ');
module.exports = { extractDescription, extractKeywords };

View 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'
];