Skip to content

Commit

Permalink
Merge pull request #317 from fergiemcdowall/316-enable-tree-shaking
Browse files Browse the repository at this point in the history
316 enable tree shaking
  • Loading branch information
fergiemcdowall authored Jan 2, 2024
2 parents 4af4f54 + e6bf200 commit 0375972
Show file tree
Hide file tree
Showing 12 changed files with 2,789 additions and 429 deletions.
7 changes: 7 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"arrowParens": "avoid",
"bracketSpacing": true,
"semi": false,
"singleQuote": true,
"trailingComma": "none"
}
14 changes: 5 additions & 9 deletions dist/stopword.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5148,7 +5148,7 @@ const hun = [
'alóluk',
'alólunk',
'amely',
'amelybol',
'amelyből',
'amelyek',
'amelyekben',
'amelyeket',
Expand Down Expand Up @@ -14273,16 +14273,12 @@ const zul = [
'ngelinye'
];

const defaultStopwords = eng;

const removeStopwords = function (tokens, stopwords) {
stopwords = stopwords || defaultStopwords;
if (typeof tokens !== 'object' || typeof stopwords !== 'object') {
// default to english stopword list
const removeStopwords = (tokens, stopwords = eng) => {
if (!Array.isArray(tokens) || !Array.isArray(stopwords)) {
throw new Error('expected Arrays try: removeStopwords(Array[, Array])')
}
return tokens.filter(function (value) {
return stopwords.indexOf(value.toLowerCase()) === -1
})
return tokens.filter(x => !stopwords.includes(x.toLowerCase()))
};

exports._123 = _123;
Expand Down
2 changes: 1 addition & 1 deletion dist/stopword.cjs.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/stopword.esm.min.mjs

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions dist/stopword.esm.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5144,7 +5144,7 @@ const hun = [
'alóluk',
'alólunk',
'amely',
'amelybol',
'amelyből',
'amelyek',
'amelyekben',
'amelyeket',
Expand Down Expand Up @@ -14269,16 +14269,12 @@ const zul = [
'ngelinye'
];

const defaultStopwords = eng;

const removeStopwords = function (tokens, stopwords) {
stopwords = stopwords || defaultStopwords;
if (typeof tokens !== 'object' || typeof stopwords !== 'object') {
// default to english stopword list
const removeStopwords = (tokens, stopwords = eng) => {
if (!Array.isArray(tokens) || !Array.isArray(stopwords)) {
throw new Error('expected Arrays try: removeStopwords(Array[, Array])')
}
return tokens.filter(function (value) {
return stopwords.indexOf(value.toLowerCase()) === -1
})
return tokens.filter(x => !stopwords.includes(x.toLowerCase()))
};

export { _123, afr, ara, ben, bre, bul, cat, ces, dan, deu, ell, eng, epo, est, eus, fas, fin, fra, gle, glg, guj, hau, heb, hin, hrv, hun, hye, ind, ita, jpn, kor, kur, lat, lav, lgg, lggNd, lit, mar, msa, mya, nld, nob, panGu, pol, por, porBr, removeStopwords, ron, rus, slk, slv, som, sot, spa, swa, swe, tgl, tha, tur, ukr, urd, vie, yor, zho, zul };
14 changes: 5 additions & 9 deletions dist/stopword.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -5150,7 +5150,7 @@
'alóluk',
'alólunk',
'amely',
'amelybol',
'amelyből',
'amelyek',
'amelyekben',
'amelyeket',
Expand Down Expand Up @@ -14275,16 +14275,12 @@
'ngelinye'
];

const defaultStopwords = eng;

const removeStopwords = function (tokens, stopwords) {
stopwords = stopwords || defaultStopwords;
if (typeof tokens !== 'object' || typeof stopwords !== 'object') {
// default to english stopword list
const removeStopwords = (tokens, stopwords = eng) => {
if (!Array.isArray(tokens) || !Array.isArray(stopwords)) {
throw new Error('expected Arrays try: removeStopwords(Array[, Array])')
}
return tokens.filter(function (value) {
return stopwords.indexOf(value.toLowerCase()) === -1
})
return tokens.filter(x => !stopwords.includes(x.toLowerCase()))
};

exports._123 = _123;
Expand Down
2 changes: 1 addition & 1 deletion dist/stopword.umd.min.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
{
"name": "stopword",
"version": "2.0.9",
"version": "3.0.0-rc3",
"description": "A module for node.js and the browser that takes in text and returns text that is stripped of stopwords. Has pre-defined stopword lists for 62 languages and also takes lists with custom stopwords as input.",
"main": "./dist/stopword.cjs.js",
"module": "./dist/stopword.esm.mjs",
"browser": "./dist/stopword.umd.js",
"main": "./src/stopword.js",
"module": "./src/stopword.js",
"browser": "./src/stopword.js",
"jsdelivr": "./dist/stopword.umd.min.js",
"files": [
"./dist",
"./src",
"./rollup.config.js"
],
"scripts": {
"build": "rollup --config",
"test": "standard './*.js' './test/*.js' && npm run build && npx ava ./test/test.cjs.js && npx ava ./test/test.esm.mjs && npx ava ./test/ui-test.js"
"lint": "standard --fix ./*.js src/*.js test/*.js",
"test": "npm run lint && npm run build && npx ava ./test/test.cjs.js && npx ava ./test/test.esm.mjs && npx ava ./test/ui-test.js"
},
"repository": {
"type": "git",
Expand All @@ -28,6 +30,7 @@
],
"devDependencies": {
"batr": "^2.1.10",
"standard": "^17.1.0",
"words-n-numbers": "^9.1.2"
},
"author": "Fergus McDowall",
Expand Down
80 changes: 71 additions & 9 deletions src/stopword.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,78 @@ import { vie } from './stopwords_vie.js'
import { yor } from './stopwords_yor.js'
import { zul } from './stopwords_zul.js'

const defaultStopwords = eng

const removeStopwords = function (tokens, stopwords) {
stopwords = stopwords || defaultStopwords
if (typeof tokens !== 'object' || typeof stopwords !== 'object') {
// default to english stopword list
const removeStopwords = (tokens, stopwords = eng) => {
if (!Array.isArray(tokens) || !Array.isArray(stopwords)) {
throw new Error('expected Arrays try: removeStopwords(Array[, Array])')
}
return tokens.filter(function (value) {
return stopwords.indexOf(value.toLowerCase()) === -1
})
return tokens.filter(x => !stopwords.includes(x.toLowerCase()))
}

export { removeStopwords, _123, afr, ara, hye, eus, ben, bre, bul, cat, zho, hrv, ces, dan, nld, eng, epo, est, fin, fra, glg, deu, ell, guj, hau, heb, hin, hun, ind, gle, ita, jpn, kor, kur, lat, lav, lit, lgg, lggNd, msa, mar, mya, nob, fas, pol, por, porBr, panGu, ron, rus, slk, slv, som, sot, spa, swa, swe, tha, tgl, tur, urd, ukr, vie, yor, zul }
export {
removeStopwords,
_123,
afr,
ara,
ben,
bre,
bul,
cat,
ces,
dan,
deu,
ell,
eng,
epo,
est,
eus,
fas,
fin,
fra,
gle,
glg,
guj,
hau,
heb,
hin,
hrv,
hun,
hye,
ind,
ita,
jpn,
kor,
kur,
lat,
lav,
lgg,
lggNd,
lit,
mar,
msa,
mya,
nld,
nob,
panGu,
pol,
por,
porBr,
ron,
rus,
slk,
slv,
som,
sot,
spa,
swa,
swe,
tgl,
tha,
tur,
ukr,
urd,
vie,
yor,
zho,
zul
}
1 change: 0 additions & 1 deletion src/stopwords__123.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

const num123 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
const numFas = ['۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹', '۰']
const numKor = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
Expand Down
Loading

0 comments on commit 0375972

Please sign in to comment.