hunspell-reader
Advanced tools
+5
| #!/usr/bin/env node | ||
| 'use strict'; | ||
| require('./dist/app'); |
+5
-0
| # Release Notes | ||
| ## 3.0.0 | ||
| - **Breaking Change** dropping support for Node 8 and 9 | ||
| - Removed dependency upon `cspell-lib` and `rxjs` | ||
| - Improved processing speed. | ||
| ## 2.1.0 | ||
@@ -4,0 +9,0 @@ - Add an Iterable Reader, this works much better for very large dictionaries. |
| import { AffInfo, Aff } from './aff'; | ||
| import { Observable } from 'rxjs'; | ||
| export interface ConvEntry { | ||
@@ -8,3 +7,3 @@ from: string; | ||
| export declare function parseAffFile(filename: string, encoding?: string): Promise<AffInfo>; | ||
| export declare function parseAff(lines: Observable<string>, _encoding?: string): Promise<AffInfo>; | ||
| export declare function parseAff(affFileContent: string, _encoding?: string): AffInfo; | ||
| export declare function parseAffFileToAff(filename: string, encoding?: string): Promise<Aff>; |
+30
-10
| "use strict"; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const fileReader_1 = require("./fileReader"); | ||
| const aff_1 = require("./aff"); | ||
| const operators_1 = require("rxjs/operators"); | ||
| // cSpell:enableCompoundWords | ||
| const fs_extra_1 = require("fs-extra"); | ||
| const iconv_lite_1 = require("iconv-lite"); | ||
| const fixRegex = { | ||
@@ -15,2 +22,3 @@ 'SFX': { m: /$/, r: '$' }, | ||
| const commentRegex = /(?:^\s*#.*)|(?:\s+#.*)/; | ||
| const UTF8 = 'UTF-8'; | ||
| function convEntry(fieldValue, _, args) { | ||
@@ -119,2 +127,6 @@ if (fieldValue === undefined) { | ||
| } | ||
| /* | ||
| cspell:ignore COMPOUNDBEGIN COMPOUNDEND COMPOUNDMIDDLE COMPOUNDMIN COMPOUNDPERMITFLAG COMPOUNDRULE FORBIDDENWORD KEEPCASE | ||
| cspell:ignore MAXDIFF NEEDAFFIX WORDCHARS | ||
| */ | ||
| const affTableField = { | ||
@@ -156,7 +168,9 @@ AF: afEntry, | ||
| }; | ||
| function parseAffFile(filename, encoding = 'UTF-8') { | ||
| return parseAff(fileReader_1.lineReader(filename, encoding), encoding) | ||
| .then(affInfo => { | ||
| function parseAffFile(filename, encoding = UTF8) { | ||
| return __awaiter(this, void 0, void 0, function* () { | ||
| const buffer = yield fs_extra_1.readFile(filename); | ||
| const file = iconv_lite_1.decode(buffer, encoding); | ||
| const affInfo = parseAff(file, encoding); | ||
| if (affInfo.SET && affInfo.SET.toLowerCase() !== encoding.toLowerCase()) { | ||
| return parseAff(fileReader_1.lineReader(filename, affInfo.SET), affInfo.SET); | ||
| return parseAff(iconv_lite_1.decode(buffer, affInfo.SET.toLowerCase()), affInfo.SET); | ||
| } | ||
@@ -167,4 +181,10 @@ return affInfo; | ||
| exports.parseAffFile = parseAffFile; | ||
| function parseAff(lines, _encoding = 'UTF-8') { | ||
| return lines.pipe(operators_1.map(line => line.replace(commentRegex, '')), operators_1.filter(line => line.trim() !== ''), operators_1.map(line => line.split(spaceRegex)), operators_1.reduce((aff, line) => { | ||
| function parseAff(affFileContent, _encoding = UTF8) { | ||
| const lines = affFileContent.split(/\r?\n/g); | ||
| return lines | ||
| .map(line => line.trimLeft()) | ||
| .map(line => line.replace(commentRegex, '')) | ||
| .filter(line => line.trim() !== '') | ||
| .map(line => line.split(spaceRegex)) | ||
| .reduce((aff, line) => { | ||
| const [field, ...args] = line; | ||
@@ -179,3 +199,3 @@ const fn = affTableField[field]; | ||
| return aff; | ||
| }, {})).toPromise(); | ||
| }, {}); | ||
| } | ||
@@ -182,0 +202,0 @@ exports.parseAff = parseAff; |
+5
-1
@@ -12,2 +12,3 @@ #!/usr/bin/env node | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| // cSpell:ignore findup | ||
| const commander = require("commander"); | ||
@@ -37,2 +38,3 @@ const IterableHunspellReader_1 = require("./IterableHunspellReader"); | ||
| .option('-p, --progress', 'Show progress.') | ||
| .option('-n, --number <limit>', 'Limit the number of words to output.') | ||
| .description('Output all the words in the <hunspell.dic> file.') | ||
@@ -98,2 +100,3 @@ .action(action); | ||
| if (reason.code === 'EPIPE') { | ||
| console.log(reason); | ||
| return; | ||
@@ -144,3 +147,3 @@ } | ||
| const applyTransformers = (aff) => transformers.reduce((aff, fn) => fn(aff), aff); | ||
| const words = seqWords | ||
| const allWords = seqWords | ||
| .map(applyTransformers) | ||
@@ -150,2 +153,3 @@ .filter(filterUnique) | ||
| .map(a => a.word + '\n'); | ||
| const words = options.number ? allWords.take(options.number) : allWords; | ||
| if (sort) { | ||
@@ -152,0 +156,0 @@ log('Sorting...'); |
+1
-1
@@ -1,2 +0,2 @@ | ||
| export * from './HunspellReader'; | ||
| export * from './IterableHunspellReader'; | ||
| export { IterableHunspellReader as HunspellReader } from './IterableHunspellReader'; |
+2
-1
@@ -6,4 +6,5 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| __export(require("./HunspellReader")); | ||
| __export(require("./IterableHunspellReader")); | ||
| var IterableHunspellReader_1 = require("./IterableHunspellReader"); | ||
| exports.HunspellReader = IterableHunspellReader_1.IterableHunspellReader; | ||
| //# sourceMappingURL=index.js.map |
@@ -14,2 +14,3 @@ "use strict"; | ||
| const fs = require("fs-extra"); | ||
| const iconv_lite_1 = require("iconv-lite"); | ||
| const defaultEncoding = 'UTF-8'; | ||
@@ -66,3 +67,4 @@ class IterableHunspellReader { | ||
| const aff = yield affReader_1.parseAffFileToAff(affFile); | ||
| const dicFileContent = yield fs.readFile(dicFile, aff.affInfo.SET || defaultEncoding); | ||
| const buffer = yield fs.readFile(dicFile); | ||
| const dicFileContent = iconv_lite_1.decode(buffer, aff.affInfo.SET || defaultEncoding); | ||
| const dic = dicFileContent.split('\n') | ||
@@ -69,0 +71,0 @@ .slice(1) // The first entry is the count of entries. |
+23
-22
| { | ||
| "name": "hunspell-reader", | ||
| "version": "2.1.2", | ||
| "version": "3.0.1", | ||
| "description": "A library for reading Hunspell Dictionary Files", | ||
| "bin": "./dist/app.js", | ||
| "bin": "bin.js", | ||
| "main": "dist/index.js", | ||
| "typings": "dist/index.d.ts", | ||
| "files": [ | ||
| "dist/", | ||
| "src/", | ||
| "dist", | ||
| "bin.js", | ||
| "!**/*.map", | ||
| "!**/*.test.*" | ||
@@ -15,8 +16,10 @@ ], | ||
| "test": "mocha --recursive ./dist/*.test.js", | ||
| "build": "tsc", | ||
| "clean": "rimraf ./dist/", | ||
| "build": "tsc -p .", | ||
| "prepare": "npm run build", | ||
| "prepublishOnly": "npm run test", | ||
| "clean": "rimraf ./dist", | ||
| "coverage": "npm run generate-code-coverage", | ||
| "generate-code-coverage": "NODE_ENV=test nyc npm run test-ts", | ||
| "test-ts": "NODE_ENV=test mocha --require ts-node/register --recursive --bail \"src/**/*.test.ts\"", | ||
| "test-watch": "npm run build && mocha --require ts-node/register --watch --recursive \"src/**/*.test.ts\"", | ||
| "test-ts": "NODE_ENV=test mocha --require ts-node/register --recursive \"src/**/*.test.ts\"", | ||
| "test-watch": "mocha --require ts-node/register --watch --recursive \"src/**/*.test.ts\"", | ||
| "coverage-coveralls": "nyc report --reporter=text-lcov | coveralls", | ||
@@ -41,20 +44,18 @@ "travis-coverage": "npm run generate-code-coverage && npm run coverage-coveralls", | ||
| "@types/chai": "^4.1.7", | ||
| "@types/fs-extra": "^5.0.4", | ||
| "@types/mocha": "^5.2.5", | ||
| "@types/node": "^8.10.39", | ||
| "@types/fs-extra": "^7.0.0", | ||
| "@types/mocha": "^5.2.6", | ||
| "@types/node": "^10.14.7", | ||
| "chai": "^4.2.0", | ||
| "coveralls": "^3.0.2", | ||
| "mocha": "^5.2.0", | ||
| "nyc": "^13.1.0", | ||
| "coveralls": "^3.0.3", | ||
| "mocha": "^6.1.4", | ||
| "nyc": "^14.1.1", | ||
| "rimraf": "^2.6.3", | ||
| "ts-node": "^7.0.1", | ||
| "typescript": "^3.2.2" | ||
| "ts-node": "^8.1.0", | ||
| "typescript": "^3.4.5" | ||
| }, | ||
| "dependencies": { | ||
| "commander": "^2.19.0", | ||
| "cspell-lib": "^3.0.5", | ||
| "fs-extra": "^7.0.1", | ||
| "commander": "^2.20.0", | ||
| "fs-extra": "^8.0.1", | ||
| "gensequence": "^2.1.2", | ||
| "rxjs": "^6.3.3", | ||
| "rxjs-stream": "^3.0.1" | ||
| "iconv-lite": "^0.4.24" | ||
| }, | ||
@@ -74,3 +75,3 @@ "eslintConfig": { | ||
| "engines": { | ||
| "node": ">=8.0.0" | ||
| "node": ">=10.0.0" | ||
| }, | ||
@@ -77,0 +78,0 @@ "nyc": { |
+1
-1
| # hunspell-reader | ||
| [](https://travis-ci.org/Jason3S/cSpell-Tools) | ||
| [](https://travis-ci.org/streetsidesoftware/hunspell-reader) | ||
@@ -4,0 +4,0 @@ A library for reading Hunspell Dictionary files |
| {"version":3,"file":"aff.js","sourceRoot":"","sources":["../src/aff.ts"],"names":[],"mappings":";;AAAA,6BAA6B;AAC7B,2CAAsC;AACtC,6CAAwD;AACxD,kCAAkC;AAGlC,6BAA6B;AAE7B,MAAM,GAAG,GAAG,KAAK,CAAC;AAgDjB,CAAC;AA6DF,MAAa,GAAG;IAKZ,YAAmB,OAAgB;QAAhB,YAAO,GAAP,OAAO,CAAS;QAC/B,IAAI,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAS,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,IAAI,qBAAS,CAAC,OAAO,CAAC,KAAK,IAAI,EAA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":[],"mappings":";;AAOA,MAAM,sBAAsB,GAAG,qBAAqB,CAAC;AAErD,MAAa,SAAS;IAIlB,YAAY,QAAoB;QAC5B,MAAM,KAAK,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAC,IAAI,EAAC,EAAE,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/F,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAChC,QAAQ,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAC,IAAI,EAAE,EAAE,EAAC,EAAE,EAAE,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACrF,CAAC;IAED,OAAO,CAAC,KAAa;QACjB,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,EAAE;YACpC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;QAC9B,CAAC,CAAC,CAAC;IACP,CAAC;CACJ;AAhBD,8BAgBC"} |
| export { lineReaderRx as lineReader } from 'cspell-lib'; | ||
| export { textFileStreamRx as textFileStream } from 'cspell-lib'; | ||
| export { stringsToLinesRx as stringsToLines } from 'cspell-lib'; |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| var cspell_lib_1 = require("cspell-lib"); | ||
| exports.lineReader = cspell_lib_1.lineReaderRx; | ||
| var cspell_lib_2 = require("cspell-lib"); | ||
| exports.textFileStream = cspell_lib_2.textFileStreamRx; | ||
| var cspell_lib_3 = require("cspell-lib"); | ||
| exports.stringsToLines = cspell_lib_3.stringsToLinesRx; | ||
| //# sourceMappingURL=fileReader.js.map |
| {"version":3,"file":"fileReader.js","sourceRoot":"","sources":["../src/fileReader.ts"],"names":[],"mappings":";;AAAA,yCAAsD;AAA9C,kCAAA,YAAY,CAAc;AAClC,yCAA8D;AAAtD,sCAAA,gBAAgB,CAAkB;AAC1C,yCAA8D;AAAtD,sCAAA,gBAAgB,CAAkB"} |
| import { Aff, AffWord } from './aff'; | ||
| import { Observable } from 'rxjs'; | ||
| import { WordInfo } from './types'; | ||
| export interface HunspellSrcInfo { | ||
| aff: Aff; | ||
| dic: Observable<string>; | ||
| } | ||
| export declare class HunspellReader { | ||
| readonly src: HunspellSrcInfo; | ||
| readonly aff: Aff; | ||
| constructor(src: HunspellSrcInfo); | ||
| /** | ||
| * @internal | ||
| */ | ||
| readDicWords(): Observable<WordInfo>; | ||
| readWordsRx(): Observable<AffWord>; | ||
| /** | ||
| * Reads all the word combinations out of a hunspell dictionary. | ||
| */ | ||
| readWords(): Observable<string>; | ||
| /** | ||
| * Reads the words in the dictionary without applying the transformation rules. | ||
| */ | ||
| readRootWords(): Observable<string>; | ||
| /** | ||
| * @internal | ||
| */ | ||
| private static readDicEntries; | ||
| static createFromFiles(affFile: string, dicFile: string): Promise<HunspellReader>; | ||
| } | ||
| export declare class HunspellSrcInfoWithGetDic implements HunspellSrcInfo { | ||
| aff: Aff; | ||
| readonly getDic: () => Observable<string>; | ||
| constructor(aff: Aff, getDic: () => Observable<string>); | ||
| readonly dic: Observable<string>; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| const affReader_1 = require("./affReader"); | ||
| const fileReader_1 = require("./fileReader"); | ||
| const operators_1 = require("rxjs/operators"); | ||
| const monitor = require("./monitor"); | ||
| class HunspellReader { | ||
| constructor(src) { | ||
| this.src = src; | ||
| this.aff = src.aff; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| readDicWords() { | ||
| return this.src.dic.pipe(operators_1.skip(1), // The first entry is the count of entries. | ||
| operators_1.map(line => { | ||
| const [word, rules] = line.split('/', 2); | ||
| return { word, rules }; | ||
| })); | ||
| } | ||
| readWordsRx() { | ||
| const r = this.src.dic.pipe(operators_1.tap(() => monitor.incCounter('cntIn')), operators_1.concatMap(dicWord => this.aff.applyRulesToDicEntry(dicWord)), operators_1.tap(() => monitor.incCounter('cntOut'))); | ||
| return r; | ||
| } | ||
| /** | ||
| * Reads all the word combinations out of a hunspell dictionary. | ||
| */ | ||
| readWords() { | ||
| return this.readWordsRx() | ||
| .pipe(operators_1.map(affWord => affWord.word)); | ||
| } | ||
| /** | ||
| * Reads the words in the dictionary without applying the transformation rules. | ||
| */ | ||
| readRootWords() { | ||
| return this.readDicWords() | ||
| .pipe(operators_1.map(w => w.word)); | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| static readDicEntries(aff, dicFile) { | ||
| return fileReader_1.lineReader(dicFile, aff.affInfo.SET); | ||
| } | ||
| static createFromFiles(affFile, dicFile) { | ||
| return affReader_1.parseAffFileToAff(affFile) | ||
| .then(aff => { | ||
| return new HunspellSrcInfoWithGetDic(aff, () => HunspellReader.readDicEntries(aff, dicFile)); | ||
| }) | ||
| .then(src => new HunspellReader(src)); | ||
| } | ||
| } | ||
| exports.HunspellReader = HunspellReader; | ||
| class HunspellSrcInfoWithGetDic { | ||
| constructor(aff, getDic) { | ||
| this.aff = aff; | ||
| this.getDic = getDic; | ||
| } | ||
| get dic() { | ||
| return this.getDic(); | ||
| } | ||
| } | ||
| exports.HunspellSrcInfoWithGetDic = HunspellSrcInfoWithGetDic; | ||
| //# sourceMappingURL=HunspellReader.js.map |
| {"version":3,"file":"HunspellReader.js","sourceRoot":"","sources":["../src/HunspellReader.ts"],"names":[],"mappings":";;AAAA,2CAA8C;AAE9C,6CAAwC;AAExC,8CAAyD;AACzD,qCAAqC;AAQrC,MAAa,cAAc;IAIvB,YAAqB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;QACrC,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,GAAG,CAAC,CAAC;IAChD,CAAC;IAED,MAAM,CAAC,eAAe,CAAC,OAAe,EAAE,OAAe;QACnD,OAAO,6BAAiB,CAAC,OAAO,CAAC;aAC5B,IAAI,CAAC,GAAG,CAAC,EAAE;YACR,OAAO,IAAI,yBAAyB,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC;QACjG,CAAC,CAAC;aACD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;IAC9C,CAAC;CACJ;AA7DD,wCA6DC;AAED,MAAa,yBAAyB;IAClC,YAAmB,GAAQ,EAAW,MAAgC;QAAnD,QAAG,GAAH,GAAG,CAAK;QAAW,WAAM,GAAN,MAAM,CAA0B;IAAG,CAAC;IAC1E,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;CACJ;AALD,8DAKC"} |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,sCAAiC;AACjC,8CAAyC"} |
| {"version":3,"file":"IterableHunspellReader.js","sourceRoot":"","sources":["../src/IterableHunspellReader.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA8C;AAE9C,6CAAoD;AAEpD,+BAA+B;AAE/B,MAAM,eAAe,GAAG,OAAO,CAAC;AAahC,MAAa,sBAAsB;IAI/B,YAAqB,GAAoB;QAApB,QAAG,GAAH,GAAG,CAAiB;QACrC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IACvB,CAAC;IAED,IAAI,GAAG;QACH,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,WAAW;QACP,OAAO,yBAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;aAC3B,GAAG,CAAC,IAAI,CAAC,EAA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IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;aAC3C,IAAI,CAAC,IAAI,CAAC,GAAG,GAAG,GAAG,OAAO,CAAC;QAChC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;KAC3B;AACL,CAAC;AAPD,kBAOC"} |
| {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""} |
| {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;AAEA,SAAgB,eAAe,CAAC,CAAC,OAAO,EAAE,WAAW,CAAW;IAC5D,OAAO,OAAO,GAAG,WAAW,GAAG,UAAU,CAAC;AAC9C,CAAC;AAFD,0CAEC;AAID,SAAgB,YAAY,CAAI,WAAmB,EAAE,GAAiB;IAClE,MAAM,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IACvC,MAAM,EAAE,GAAG,IAAI,GAAG,EAAK,CAAC;IACxB,MAAM,EAAE,GAAG,IAAI,GAAG,EAAK,CAAC;IACxB,MAAM,KAAK,GAAG,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3B,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,CAAI,EAAE,EAAE;QACZ,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACpB,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACnB,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAC;QAC3B,MAAM,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;QACvB,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QACT,IAAI,CAAC,CAAC,IAAI,IAAI,WAAW,EAAE;YACvB,CAAC,CAAC,KAAK,EAAE,CAAC;YACV,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC;SACnB;QACD,OAAO,CAAC,CAAC;IACb,CAAC,CAAC;AACN,CAAC;AAnBD,oCAmBC;AAED,QAAgB,CAAC,CAAA,KAAK,CAAI,CAAc,EAAE,IAAY;IAClD,IAAI,IAAI,GAAQ,EAAE,CAAC;IACnB,KAAK,MAAM,CAAC,IAAI,CAAC,EAAE;QACf,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACb,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE;YACtB,MAAM,IAAI,CAAC;YACX,IAAI,GAAG,EAAE,CAAC;SACb;KACJ;IAED,IAAI,IAAI,CAAC,MAAM,EAAE;QACb,MAAM,IAAI,CAAC;KACd;AACL,CAAC;AAbD,sBAaC"} |
-342
| import * as util from 'util'; | ||
| import {Converter} from './converter'; | ||
| import {genSequence as gs, Sequence} from 'gensequence'; | ||
| import * as GS from 'gensequence'; | ||
| import { Dictionary } from './types'; | ||
| // cSpell:enableCompoundWords | ||
| const log = false; | ||
| export interface Fx { | ||
| type: string; | ||
| id: string; | ||
| combinable: boolean; | ||
| substitutionSets: Substitutions; | ||
| count?: string; // number of line items for this rule. | ||
| extra?: string[]; // extra items on the line. | ||
| } | ||
| export type Substitutions = Map<string, SubstitutionSet>; | ||
| export interface Substitution { | ||
| remove: string; | ||
| attach: string; | ||
| attachRules?: string; | ||
| replace: RegExp; | ||
| extra?: string[]; | ||
| } | ||
| export interface SubstitutionSet { | ||
| match: RegExp; | ||
| substitutions: Substitution[]; | ||
| } | ||
| export interface Rep { | ||
| match: string; | ||
| replaceWith: string; | ||
| } | ||
| export interface Conv { | ||
| from: string; | ||
| to: string; | ||
| } | ||
| export interface AffTransformFlags { | ||
| KEEPCASE?: string; | ||
| WARN?: string; | ||
| NEEDAFFIX?: string; | ||
| FORCEUCASE?: string; | ||
| FORBIDDENWORD?: string; | ||
| NOSUGGEST?: string; | ||
| COMPOUNDBEGIN?: string; | ||
| COMPOUNDMIDDLE?: string; | ||
| COMPOUNDEND?: string; | ||
| COMPOUNDPERMITFLAG?: string; | ||
| ONLYINCOMPOUND?: string; | ||
| }; | ||
| export interface AffInfo extends AffTransformFlags { | ||
| SET?: string; // Characterset encoding of the .aff and .dic file | ||
| TRY?: string; | ||
| KEY?: string; | ||
| WORDCHARS?: string; | ||
| NOSPLITSUGS?: boolean; | ||
| MAXCPDSUGS?: number; | ||
| ONLYMAXDIFF?: boolean; | ||
| MAXDIFF?: number; | ||
| BREAK?: number; | ||
| FLAG?: string; // 'long' | 'num' | ||
| MAP?: string[]; | ||
| ICONV?: Conv[]; | ||
| OCONV?: Conv[]; | ||
| REP?: Rep[]; | ||
| AF?: string[]; | ||
| COMPOUNDMIN?: number; | ||
| COMPOUNDRULE?: string[]; | ||
| CHECKCOMPOUNDCASE?: boolean; | ||
| CHECKCOMPOUNDDUP?: boolean; | ||
| CHECKCOMPOUNDREP?: boolean; | ||
| CHECKCOMPOUNDPATTERN?: string[][]; | ||
| PFX?: Map<string, Fx>; | ||
| SFX?: Map<string, Fx>; | ||
| } | ||
| export interface Rule { | ||
| id: string; | ||
| type: string; | ||
| flags?: AffWordFlags; | ||
| pfx?: Fx; | ||
| sfx?: Fx; | ||
| } | ||
| export interface AffWordFlags { | ||
| isCompoundPermitted?: boolean; // default false | ||
| canBeCompoundBegin?: boolean; // default false | ||
| canBeCompoundMiddle?: boolean; // default false | ||
| canBeCompoundEnd?: boolean; // default false | ||
| isOnlyAllowedInCompound?: boolean; // default false | ||
| isWarning?: boolean; | ||
| isKeepCase?: boolean; | ||
| isForceUCase?: boolean; | ||
| isForbiddenWord?: boolean; | ||
| isNoSuggest?: boolean; | ||
| isNeedAffix?: boolean; | ||
| } | ||
| export interface AffWord { | ||
| word: string; | ||
| rules: string; | ||
| flags: AffWordFlags; | ||
| rulesApplied: string; | ||
| base: string; // the base | ||
| suffix: string; // suffixes applied | ||
| prefix: string; // prefixes applied | ||
| dic: string; // dictionary entry | ||
| } | ||
| export class Aff { | ||
| protected rules: Map<string, Rule>; | ||
| protected _oConv: Converter; | ||
| protected _iConv: Converter; | ||
| constructor(public affInfo: AffInfo) { | ||
| this.rules = processRules(affInfo); | ||
| this._iConv = new Converter(affInfo.ICONV || []); | ||
| this._oConv = new Converter(affInfo.OCONV || []); | ||
| } | ||
| /** | ||
| * Takes a line from a hunspell.dic file and applies the rules found in the aff file. | ||
| * @param {string} line - the line from the .dic file. | ||
| */ | ||
| applyRulesToDicEntry(line: string): AffWord[] { | ||
| const [lineLeft] = line.split(/\s+/, 1); | ||
| const [word, rules = ''] = lineLeft.split('/', 2); | ||
| return this.applyRulesToWord(asAffWord(word, rules)) | ||
| .map(affWord => ({...affWord, word: this._oConv.convert(affWord.word) })); | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| applyRulesToWord(affWord: AffWord): AffWord[] { | ||
| const { word, base, suffix, prefix, dic } = affWord; | ||
| const allRules = this.getMatchingRules(affWord.rules); | ||
| const { rulesApplied, flags } = allRules | ||
| .filter(rule => !!rule.flags) | ||
| .reduce((acc, rule) => ({ | ||
| rulesApplied: [acc.rulesApplied, rule.id].join(' '), | ||
| flags: {...acc.flags, ...rule.flags}, | ||
| }), { rulesApplied: affWord.rulesApplied, flags: affWord.flags}); | ||
| const rules = this.joinRules(allRules.filter(rule => !rule.flags).map(rule => rule.id)); | ||
| const affixRules = allRules.map(rule => rule.sfx! || rule.pfx!).filter(a => !!a); | ||
| const wordWithFlags = {word, flags, rulesApplied, rules: '', base, suffix, prefix, dic}; | ||
| return [ | ||
| wordWithFlags, | ||
| ...this.applyAffixesToWord(affixRules, { ...wordWithFlags, rules }) | ||
| ] | ||
| .filter(({flags}) => !flags.isNeedAffix) | ||
| .map(affWord => logAffWord(affWord, 'applyRulesToWord')) | ||
| ; | ||
| } | ||
| applyAffixesToWord(affixRules: Fx[], affWord: AffWord): AffWord[] { | ||
| const combineableRules = affixRules | ||
| .filter(rule => rule.type === 'SFX') | ||
| .filter(rule => rule.combinable === true) | ||
| .map(({id}) => id); | ||
| const combinableSfx = this.joinRules(combineableRules); | ||
| const r = affixRules | ||
| .map(affix => this.applyAffixToWord(affix, affWord, combinableSfx)) | ||
| .reduce((a, b) => a.concat(b), []) | ||
| .map(affWord => this.applyRulesToWord(affWord)) | ||
| .reduce((a, b) => a.concat(b), []) | ||
| ; | ||
| return r; | ||
| } | ||
| applyAffixToWord(affix: Fx, affWord: AffWord, combinableSfx: string): AffWord[] { | ||
| const {word} = affWord; | ||
| const combineRules = (affix.type === 'PFX' && affix.combinable && !!combinableSfx) | ||
| ? combinableSfx | ||
| : ''; | ||
| const flags = { ...affWord.flags, isNeedAffix: false }; | ||
| const matchingSubstitutions = [...affix.substitutionSets.values()] | ||
| .filter(sub => sub.match.test(word)); | ||
| const partialAffWord = {...affWord, flags, rules: combineRules}; | ||
| return matchingSubstitutions | ||
| .map(sub => sub.substitutions) | ||
| .reduce((a, b) => a.concat(b), []) | ||
| .filter(sub => sub.replace.test(word)) | ||
| .map(sub => this.substitute(affix, partialAffWord, sub)) | ||
| .map(affWord => logAffWord(affWord, 'applyAffixToWord')) | ||
| ; | ||
| } | ||
| substitute(affix: Fx, affWord: AffWord, sub: Substitution): AffWord { | ||
| const { word: origWord, rulesApplied, flags, dic } = affWord; | ||
| const rules = affWord.rules + (sub.attachRules || ''); | ||
| const word = origWord.replace(sub.replace, sub.attach); | ||
| const stripped = origWord.replace(sub.replace, ''); | ||
| let p = affWord.prefix.length; | ||
| let s = origWord.length - affWord.suffix.length; | ||
| if (affix.type === 'SFX') { | ||
| s = Math.min(stripped.length, s); | ||
| p = Math.min(p, s); | ||
| } else { | ||
| const d = word.length - origWord.length; | ||
| p = Math.max(p, word.length - stripped.length); | ||
| s = Math.max(s + d, p); | ||
| } | ||
| const base = word.slice(p, s); | ||
| const prefix = word.slice(0, p); | ||
| const suffix = word.slice(s); | ||
| return { | ||
| word, | ||
| rulesApplied: rulesApplied + ' ' + affix.id, | ||
| rules, | ||
| flags, | ||
| base, | ||
| suffix, | ||
| prefix, | ||
| dic, | ||
| }; | ||
| } | ||
| getMatchingRules(rules: string): Rule[] { | ||
| const { AF = [] } = this.affInfo; | ||
| const rulesToSplit = AF[rules] || rules; | ||
| return this.separateRules(rulesToSplit) | ||
| .map(key => this.rules[key]) | ||
| .filter(a => !!a); | ||
| } | ||
| joinRules(rules: string[]): string { | ||
| switch (this.affInfo.FLAG) { | ||
| case 'long': | ||
| return rules.join(''); | ||
| case 'num': | ||
| return rules.join(','); | ||
| } | ||
| return rules.join(''); | ||
| } | ||
| separateRules(rules: string): string[] { | ||
| switch (this.affInfo.FLAG) { | ||
| case 'long': | ||
| return rules.replace(/(..)/g, '$1//').split('//').slice(0, -1); | ||
| case 'num': | ||
| return rules.split(','); | ||
| } | ||
| return rules.split(''); | ||
| } | ||
| get iConv() { | ||
| return this._iConv; | ||
| } | ||
| get oConv() { | ||
| return this._oConv; | ||
| } | ||
| } | ||
| export function processRules(affInfo: AffInfo): Map<string, Rule> { | ||
| const sfxRules: Sequence<Rule> = gs(affInfo.SFX || []).map(([, sfx]) => sfx).map(sfx => ({ id: sfx.id, type: 'sfx', sfx })); | ||
| const pfxRules: Sequence<Rule> = gs(affInfo.PFX || []).map(([, pfx]) => pfx).map(pfx => ({ id: pfx.id, type: 'pfx', pfx })); | ||
| const flagRules: Sequence<Rule> = GS.sequenceFromObject(affInfo as AffTransformFlags) | ||
| .filter(([key, value]) => !!affFlag[key] && !!value) | ||
| .map(([key, value]) => ({ id: value!, type: 'flag', flags: affFlag[key]})); | ||
| const rules = sfxRules.concat(pfxRules).concat(flagRules) | ||
| .reduce<Map<string, Rule>>((acc, rule) => { acc[rule.id] = rule; return acc; }, new Map<string, Rule>()); | ||
| return rules; | ||
| } | ||
| const affFlag: Dictionary<AffWordFlags> = { | ||
| KEEPCASE : { isKeepCase : true }, | ||
| WARN : { isWarning : true }, | ||
| FORCEUCASE : { isForceUCase : true }, | ||
| FORBIDDENWORD : { isForbiddenWord : true }, | ||
| NOSUGGEST : { isNoSuggest : true }, | ||
| NEEDAFFIX : { isNeedAffix : true }, | ||
| COMPOUNDBEGIN : { canBeCompoundBegin : true }, | ||
| COMPOUNDMIDDLE : { canBeCompoundMiddle : true }, | ||
| COMPOUNDEND : { canBeCompoundEnd : true }, | ||
| COMPOUNDPERMITFLAG: { isCompoundPermitted : true }, | ||
| ONLYINCOMPOUND : { isOnlyAllowedInCompound: true }, | ||
| }; | ||
| const flagToStringMap: Dictionary<string> = { | ||
| isCompoundPermitted : 'C', | ||
| canBeCompoundBegin : 'B', | ||
| canBeCompoundMiddle : 'M', | ||
| canBeCompoundEnd : 'E', | ||
| isOnlyAllowedInCompound: 'O', | ||
| isWarning : 'W', | ||
| isKeepCase : 'K', | ||
| isForceUCase : 'U', | ||
| isForbiddenWord : 'F', | ||
| isNoSuggest : 'N', | ||
| isNeedAffix : 'A', | ||
| }; | ||
| export function logAffWord(affWord: AffWord, message: string) { | ||
| /* istanbul ignore if */ | ||
| if (log) { | ||
| const dump = util.inspect(affWord, { showHidden: false, depth: 5, colors: true }); | ||
| console.log(`${message}: ${dump}`); | ||
| } | ||
| return affWord; | ||
| } | ||
| /* istanbul ignore next */ | ||
| export function affWordToColoredString(affWord: AffWord) { | ||
| return util.inspect( | ||
| {...affWord, flags: flagsToString(affWord.flags)}, | ||
| { showHidden: false, depth: 5, colors: true }).replace(/(\s|\n|\r)+/g, ' '); | ||
| } | ||
| /* istanbul ignore next */ | ||
| export function flagsToString(flags: AffWordFlags) { | ||
| return GS.sequenceFromObject(flags) | ||
| .filter(([, v]) => !!v) | ||
| // convert the key to a string | ||
| .map(([k]) => flagToStringMap[k]) | ||
| .toArray() | ||
| .sort() | ||
| .join('_'); | ||
| } | ||
| export function asAffWord(word: string, rules: string = ''): AffWord { | ||
| return { | ||
| word, | ||
| base: word, | ||
| prefix: '', | ||
| suffix: '', | ||
| rulesApplied: '', | ||
| rules: rules || '', | ||
| flags: {}, | ||
| dic: word + '/' + rules | ||
| }; | ||
| } |
-211
| import { lineReader } from './fileReader'; | ||
| import { AffInfo, Aff, Fx, SubstitutionSet } from './aff'; | ||
| import { Observable } from 'rxjs'; | ||
| import { map, filter, reduce } from 'rxjs/operators'; | ||
| // cSpell:enableCompoundWords | ||
| const fixRegex = { | ||
| 'SFX': { m: /$/, r: '$'}, | ||
| 'PFX': { m: /^/, r: '^'}, | ||
| }; | ||
| const emptyZeroRegex = /^0$/; | ||
| const yesRegex = /[yY]/; | ||
| const spaceRegex = /\s+/; | ||
| const commentRegex = /(?:^\s*#.*)|(?:\s+#.*)/; | ||
| export interface ConvEntry { from: string; to: string; } | ||
| function convEntry(fieldValue: ConvEntry[], _: string, args: string[]) { | ||
| if (fieldValue === undefined) { | ||
| return []; | ||
| } | ||
| fieldValue.push({ from: args[0], to: args[1] }); | ||
| return fieldValue; | ||
| } | ||
| function afEntry(fieldValue: string[], _: string, args: string[]) { | ||
| if (fieldValue === undefined) { | ||
| return ['']; | ||
| } | ||
| fieldValue.push(args[0]); | ||
| return fieldValue; | ||
| } | ||
| function simpleTable(fieldValue, _: string, args: string[]) { | ||
| if (fieldValue === undefined) { | ||
| const [ count, ...extraValues ] = args; | ||
| const extra = extraValues.length ? extraValues : undefined; | ||
| return { count, extra, values: [] }; | ||
| } | ||
| fieldValue.values.push(args); | ||
| return fieldValue; | ||
| } | ||
| const regExpStartsWithPlus = /^\+/; | ||
| function tablePfxOrSfx(fieldValue: Map<string, Fx>, _: string, args: string[], type: string) { | ||
| /* | ||
| Fields of an affix rules: | ||
| (0) Option name | ||
| (1) Flag | ||
| (2) stripping characters from beginning (at prefix rules) or end (at suffix rules) of the word | ||
| (3) affix (optionally with flags of continuation classes, separated by a slash) | ||
| (4) condition. | ||
| Zero stripping or affix are indicated by zero. Zero condition is indicated by dot. | ||
| Condition is a simplified, regular expression-like pattern, which must be met before the affix can be applied. | ||
| (Dot signs an arbitrary character. Characters in braces sign an arbitrary character from the character subset. | ||
| Dash hasn't got special meaning, but circumflex (^) next the first brace sets the complementer character set.) | ||
| (5) Optional morphological fields separated by spaces or tabulators. | ||
| */ | ||
| const posCondition = 2; | ||
| if (fieldValue === undefined) { | ||
| fieldValue = new Map<string, Fx>(); | ||
| } | ||
| const [ subField, ...subValues ] = args; | ||
| if (! fieldValue.has(subField)) { | ||
| const id = subField; | ||
| const [ combinable, count, ...extra ] = subValues; | ||
| fieldValue.set(subField, { | ||
| id, | ||
| type, | ||
| combinable: !!combinable.match(yesRegex), | ||
| count, | ||
| extra, | ||
| substitutionSets: new Map<string, SubstitutionSet>() | ||
| }); | ||
| return fieldValue; | ||
| } | ||
| if (subValues.length < 2) { | ||
| console.log(`Affix rule missing values: ${args.join(' ')}`); | ||
| return; | ||
| } | ||
| if (regExpStartsWithPlus.test(subValues[posCondition] || '')) { | ||
| // sometimes the condition is left off, but there are morphological fields | ||
| // so we need to inject a '.'. | ||
| subValues.splice(posCondition, 0, '.'); | ||
| } | ||
| const fixRuleSet = fieldValue.get(subField)!; | ||
| const substitutionSets = fixRuleSet.substitutionSets; | ||
| const [removeValue, attach, ruleAsString = '.', ...extraValues] = subValues; | ||
| const [attachText, attachRules] = attach.split('/', 2); | ||
| const extra = extraValues.length ? extraValues : undefined; | ||
| const remove = removeValue.replace(emptyZeroRegex, ''); | ||
| const insertText = attachText.replace(emptyZeroRegex, ''); | ||
| const fixUp = fixRegex[type]; | ||
| const replace = new RegExp(remove.replace(fixUp.m, fixUp.r)); | ||
| if (!substitutionSets.has(ruleAsString)) { | ||
| const match = new RegExp(ruleAsString.replace(fixUp.m, fixUp.r)); | ||
| substitutionSets.set(ruleAsString, { | ||
| match, | ||
| substitutions: [], | ||
| }); | ||
| } | ||
| const substitutionSet = substitutionSets.get(ruleAsString)!; | ||
| substitutionSet.substitutions.push({ remove, replace, attach: insertText, attachRules, extra }); | ||
| return fieldValue; | ||
| } | ||
| function asPfx(fieldValue, field: string, args: string[]) { | ||
| return tablePfxOrSfx(fieldValue, field, args, 'PFX'); | ||
| } | ||
| function asSfx(fieldValue, field: string, args: string[]) { | ||
| return tablePfxOrSfx(fieldValue, field, args, 'SFX'); | ||
| } | ||
| function asString(_fieldValue, _field: string, args: string[]) { | ||
| return args[0]; | ||
| } | ||
| function asBoolean(_fieldValue, _field: string, args: string[]) { | ||
| const [ value = '1' ] = args; | ||
| const iValue = parseInt(value); | ||
| return !!iValue; | ||
| } | ||
| function asNumber(_fieldValue, _field: string, args: string[]) { | ||
| const [ value = '0' ] = args; | ||
| return parseInt(value); | ||
| } | ||
| const affTableField = { | ||
| AF : afEntry, | ||
| BREAK : asNumber, | ||
| CHECKCOMPOUNDCASE : asBoolean, | ||
| CHECKCOMPOUNDDUP : asBoolean, | ||
| CHECKCOMPOUNDPATTERN: simpleTable, | ||
| CHECKCOMPOUNDREP : asBoolean, | ||
| COMPOUNDBEGIN : asString, | ||
| COMPOUNDEND : asString, | ||
| COMPOUNDMIDDLE : asString, | ||
| COMPOUNDMIN : asNumber, | ||
| COMPOUNDPERMITFLAG : asString, | ||
| COMPOUNDRULE : simpleTable, | ||
| FLAG : asString, // 'long' | 'num' | ||
| FORBIDDENWORD : asString, | ||
| FORCEUCASE : asString, | ||
| ICONV : convEntry, | ||
| KEEPCASE : asString, | ||
| KEY : asString, | ||
| MAP : simpleTable, | ||
| MAXCPDSUGS : asNumber, | ||
| MAXDIFF : asNumber, | ||
| NEEDAFFIX : asString, | ||
| NOSPLITSUGS : asBoolean, | ||
| NOSUGGEST : asString, | ||
| OCONV : convEntry, | ||
| ONLYINCOMPOUND : asString, | ||
| ONLYMAXDIFF : asBoolean, | ||
| PFX : asPfx, | ||
| REP : simpleTable, | ||
| SET : asString, | ||
| SFX : asSfx, | ||
| TRY : asString, | ||
| WARN : asString, | ||
| WORDCHARS : asString, | ||
| }; | ||
| export function parseAffFile(filename: string, encoding: string = 'UTF-8') { | ||
| return parseAff(lineReader(filename, encoding), encoding) | ||
| .then(affInfo => { | ||
| if (affInfo.SET && affInfo.SET.toLowerCase() !== encoding.toLowerCase()) { | ||
| return parseAff(lineReader(filename, affInfo.SET), affInfo.SET); | ||
| } | ||
| return affInfo; | ||
| }); | ||
| } | ||
| export function parseAff(lines: Observable<string>, _encoding: string = 'UTF-8') { | ||
| return lines.pipe( | ||
| map(line => line.replace(commentRegex, '')), | ||
| filter(line => line.trim() !== ''), | ||
| map(line => line.split(spaceRegex)), | ||
| reduce<string[], AffInfo>((aff, line) => { | ||
| const [ field, ...args ] = line; | ||
| const fn = affTableField[field]; | ||
| if (fn) { | ||
| aff[field] = fn(aff[field], field, args); | ||
| } else { | ||
| aff[field] = args; | ||
| } | ||
| return aff; | ||
| }, {}) | ||
| ).toPromise(); | ||
| } | ||
| export function parseAffFileToAff(filename: string, encoding?: string) { | ||
| return parseAffFile(filename, encoding) | ||
| .then(affInfo => new Aff(affInfo)) | ||
| ; | ||
| } | ||
-184
| #!/usr/bin/env node | ||
| // cSpell:ignore findup | ||
| import * as commander from 'commander'; | ||
| import { IterableHunspellReader } from './IterableHunspellReader'; | ||
| import * as fs from 'fs-extra'; | ||
| import { uniqueFilter, batch } from './util'; | ||
| import { genSequence, Sequence } from 'gensequence'; | ||
| import { AffWord, asAffWord } from './aff'; | ||
| import { iterableToStream } from './iterableToStream'; | ||
| const uniqueHistorySize = 500000; | ||
| const packageInfo = require('../package.json'); | ||
| const version = packageInfo['version']; | ||
| let displayHelp = true; | ||
| let logStream = process.stderr; | ||
| commander | ||
| .version(version); | ||
| commander | ||
| .command('words <hunspell_dic_file>') | ||
| .option('-o, --output <file>', 'output file - defaults to stdout') | ||
| .option('-s, --sort', 'sort the list of words') | ||
| .option('-u, --unique', 'make sure the words are unique.') | ||
| .option('-l, --lower_case', 'output in lower case') | ||
| .option('-T, --no-transform', 'Do not apply the prefix and suffix transforms. Root words only.') | ||
| .option('-x, --infix', 'Return words with prefix / suffix breaks. ex: "un<do>ing"') | ||
| .option('-r, --rules', 'Append rules used to generate word.') | ||
| .option('-p, --progress', 'Show progress.') | ||
| .description('Output all the words in the <hunspell.dic> file.') | ||
| .action(action); | ||
| commander.parse(process.argv); | ||
| if (displayHelp) { | ||
| commander.help(); | ||
| } | ||
| function notify(message: string, newLine = true) { | ||
| message = message + (newLine ? '\n' : ''); | ||
| logStream.write(message, 'utf-8'); | ||
| } | ||
| function yesNo(value: boolean) { | ||
| return value ? 'Yes' : 'No'; | ||
| } | ||
| function affWordToInfix(aff: AffWord): AffWord { | ||
| return { ...aff, word: aff.prefix + '<' + aff.base + '>' + aff.suffix }; | ||
| } | ||
| function mapWord(map: (word: string) => string): (aff: AffWord) => AffWord { | ||
| return (aff: AffWord) => ({ ...aff, word: map(aff.word) }); | ||
| } | ||
| function appendRules(aff: AffWord): AffWord { | ||
| return { ...aff, word: aff.word + '\t[' + aff.rulesApplied + ' ]\t' + '(' + aff.dic + ')' }; | ||
| } | ||
| function writeSeqToFile(seq: Sequence<string>, outFile: string | undefined): Promise<void> { | ||
| return new Promise((resolve, reject) => { | ||
| let resolved = false; | ||
| const out = outFile ? fs.createWriteStream(outFile) : process.stdout; | ||
| const bufferedSeq = genSequence(batch(seq, 500)).map(batch => batch.join('')); | ||
| const dataStream = iterableToStream(bufferedSeq); | ||
| const fileStream = dataStream.pipe(out); | ||
| const endEvents = ['finish', 'close', 'end']; | ||
| function resolvePromise() { | ||
| if (!resolved) { | ||
| resolved = true; | ||
| resolve(); | ||
| } | ||
| } | ||
| const endHandler = () => { | ||
| cleanupStreams(); | ||
| setTimeout(resolvePromise, 10); | ||
| }; | ||
| const errorHandler = (e: Error) => { | ||
| cleanupStreams(); | ||
| reject(e); | ||
| }; | ||
| listenToStreams(); | ||
| function listenToStreams() { | ||
| endEvents.forEach(event => fileStream.addListener(event, endHandler)); | ||
| fileStream.addListener('error', errorHandler); | ||
| dataStream.addListener('end', endHandler); | ||
| } | ||
| function cleanupStreams() { | ||
| endEvents.forEach(event => fileStream.removeListener(event, endHandler)); | ||
| fileStream.removeListener('error', errorHandler); | ||
| dataStream.removeListener('end', endHandler); | ||
| } | ||
| }); | ||
| } | ||
| function action(hunspellDicFilename: string, options: any): Promise<void> { | ||
| return actionPrime(hunspellDicFilename, options).catch((reason: { code: string }) => { | ||
| if (reason.code === 'EPIPE') { | ||
| return; | ||
| } | ||
| console.error(reason); | ||
| }); | ||
| } | ||
| interface Options { | ||
| sort?: boolean; | ||
| unique?: boolean; | ||
| lower_case?: boolean; | ||
| output?: string; | ||
| transform?: boolean; | ||
| infix?: boolean; | ||
| rules?: boolean; | ||
| progress?: boolean; | ||
| } | ||
| async function actionPrime(hunspellDicFilename: string, options: Options) { | ||
| displayHelp = false; | ||
| const { | ||
| sort = false, | ||
| unique = false, | ||
| output: outputFile, | ||
| lower_case: lowerCase = false, | ||
| transform = true, | ||
| infix = false, | ||
| rules = false, | ||
| progress: showProgress = false, | ||
| } = options; | ||
| logStream = outputFile ? process.stdout : process.stderr; | ||
| const log = notify; | ||
| log('Write words'); | ||
| log(`Sort: ${yesNo(sort)}`); | ||
| log(`Unique: ${yesNo(unique)}`); | ||
| const baseFile = hunspellDicFilename.replace(/\.(dic|aff)$/, ''); | ||
| const dicFile = baseFile + '.dic'; | ||
| const affFile = baseFile + '.aff'; | ||
| log(`Dic file: ${dicFile}`); | ||
| log(`Aff file: ${affFile}`); | ||
| log(`Generating Words...`); | ||
| const reader = await IterableHunspellReader.createFromFiles(affFile, dicFile); | ||
| const transformers: ((_: AffWord) => AffWord)[] = []; | ||
| if (infix) { transformers.push(affWordToInfix); } | ||
| if (lowerCase) { transformers.push(mapWord(a => a.toLowerCase())); } | ||
| if (rules) { transformers.push(appendRules); } | ||
| transformers.push(mapWord(a => a.trim())); | ||
| const dicSize = reader.dic.length; | ||
| let current = 0; | ||
| const calcProgress = () => '\r' + current + ' / ' + dicSize; | ||
| const reportProgressRate = 253; | ||
| const callback = showProgress | ||
| ? () => { | ||
| current++; | ||
| !(current % reportProgressRate) && process.stderr.write(calcProgress(), 'UTF-8'); | ||
| } | ||
| : () => {}; | ||
| const seqWords = transform ? reader.seqAffWords(callback) : reader.seqRootWords().map(asAffWord); | ||
| const filterUnique = unique ? uniqueFilter(uniqueHistorySize, (aff: AffWord) => aff.word) : (_: AffWord) => true; | ||
| const applyTransformers = (aff: AffWord) => transformers.reduce((aff, fn) => fn(aff), aff); | ||
| const words = seqWords | ||
| .map(applyTransformers) | ||
| .filter(filterUnique) | ||
| .filter(a => !!a.word) | ||
| .map(a => a.word + '\n') | ||
| ; | ||
| if (sort) { | ||
| log('Sorting...'); | ||
| const data = words.toArray().sort().join(''); | ||
| const fd = outputFile ? fs.openSync(outputFile, 'w') : 1; | ||
| fs.writeSync(fd, data); | ||
| } else { | ||
| await writeSeqToFile(words, outputFile); | ||
| } | ||
| if (showProgress) { console.error(calcProgress()); } | ||
| log('Done.'); | ||
| } |
| import { Dictionary } from './types'; | ||
| export interface ConvItem { | ||
| from: string; | ||
| to: string; | ||
| } | ||
| const regexSpecialCharacters = /[|\\{}()[\]^$+*?.]/g; | ||
| export class Converter { | ||
| private _match: RegExp; | ||
| private _map: Dictionary<string>; | ||
| constructor(convList: ConvItem[]) { | ||
| const match = convList.map(({from}) => from.replace(regexSpecialCharacters, '\\$&')).join('|'); | ||
| this._match = new RegExp(match, 'g'); | ||
| this._map = Object.create(null); | ||
| convList.reduce((map, {from, to}) => { map[from] = to; return map; }, this._map); | ||
| } | ||
| convert(input: string) { | ||
| return input.replace(this._match, (m) => { | ||
| return this._map[m] || ''; | ||
| }); | ||
| } | ||
| } |
| export {lineReaderRx as lineReader} from 'cspell-lib'; | ||
| export {textFileStreamRx as textFileStream} from 'cspell-lib'; | ||
| export {stringsToLinesRx as stringsToLines} from 'cspell-lib'; | ||
| import {parseAffFileToAff} from './affReader'; | ||
| import {Aff, AffWord} from './aff'; | ||
| import {lineReader} from './fileReader'; | ||
| import {Observable} from 'rxjs'; | ||
| import {map, skip, tap, concatMap} from 'rxjs/operators'; | ||
| import * as monitor from './monitor'; | ||
| import { WordInfo } from './types'; | ||
| export interface HunspellSrcInfo { | ||
| aff: Aff; | ||
| dic: Observable<string>; | ||
| } | ||
| export class HunspellReader { | ||
| readonly aff: Aff; | ||
| constructor(readonly src: HunspellSrcInfo) { | ||
| this.aff = src.aff; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| readDicWords(): Observable<WordInfo> { | ||
| return this.src.dic.pipe( | ||
| skip(1), // The first entry is the count of entries. | ||
| map(line => { | ||
| const [word, rules] = line.split('/', 2); | ||
| return { word, rules }; | ||
| }), | ||
| ); | ||
| } | ||
| readWordsRx(): Observable<AffWord> { | ||
| const r = this.src.dic.pipe( | ||
| tap(() => monitor.incCounter('cntIn')), | ||
| concatMap(dicWord => this.aff.applyRulesToDicEntry(dicWord)), | ||
| tap(() => monitor.incCounter('cntOut')), | ||
| ); | ||
| return r; | ||
| } | ||
| /** | ||
| * Reads all the word combinations out of a hunspell dictionary. | ||
| */ | ||
| readWords(): Observable<string> { | ||
| return this.readWordsRx() | ||
| .pipe(map(affWord => affWord.word)); | ||
| } | ||
| /** | ||
| * Reads the words in the dictionary without applying the transformation rules. | ||
| */ | ||
| readRootWords(): Observable<string> { | ||
| return this.readDicWords() | ||
| .pipe(map(w => w.word)); | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| private static readDicEntries(aff: Aff, dicFile: string): Observable<string> { | ||
| return lineReader(dicFile, aff.affInfo.SET); | ||
| } | ||
| static createFromFiles(affFile: string, dicFile: string) { | ||
| return parseAffFileToAff(affFile) | ||
| .then(aff => { | ||
| return new HunspellSrcInfoWithGetDic(aff, () => HunspellReader.readDicEntries(aff, dicFile)); | ||
| }) | ||
| .then(src => new HunspellReader(src)); | ||
| } | ||
| } | ||
| export class HunspellSrcInfoWithGetDic implements HunspellSrcInfo { | ||
| constructor(public aff: Aff, readonly getDic: () => Observable<string>) {} | ||
| get dic(): Observable<string> { | ||
| return this.getDic(); | ||
| } | ||
| } |
| export * from './HunspellReader'; | ||
| export * from './IterableHunspellReader'; |
| import {parseAffFileToAff} from './affReader'; | ||
| import {Aff} from './aff'; | ||
| import { genSequence, Sequence } from 'gensequence'; | ||
| import { WordInfo } from './types'; | ||
| import * as fs from 'fs-extra'; | ||
| const defaultEncoding = 'UTF-8'; | ||
| export interface WordInfo { | ||
| word: string; | ||
| rules: string; | ||
| } | ||
| export interface HunspellSrcData { | ||
| aff: Aff; | ||
| dic: string[]; | ||
| } | ||
| export class IterableHunspellReader implements Iterable<string> { | ||
| readonly aff: Aff; | ||
| constructor(readonly src: HunspellSrcData) { | ||
| this.aff = src.aff; | ||
| } | ||
| get dic() { | ||
| return this.src.dic; | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| dicWordsSeq(): Sequence<WordInfo> { | ||
| return genSequence(this.src.dic) | ||
| .map(line => { | ||
| const [word, rules] = line.split('/', 2); | ||
| return { word, rules, prefixes: [], suffixes: [] }; | ||
| }) | ||
| ; | ||
| } | ||
| /** | ||
| * iterates through the root words of the dictionary | ||
| */ | ||
| iterateRootWords(): Iterable<string> { | ||
| return this.seqRootWords(); | ||
| } | ||
| iterateWords(): Iterable<string> { | ||
| return this.seqWords(); | ||
| } | ||
| [Symbol.iterator]() { return this.seqWords(); } | ||
| seqAffWords(tapPreApplyRules?: (w: string) => any) { | ||
| const seq = genSequence(this.src.dic); | ||
| const dicWords = tapPreApplyRules ? seq.map(a => (tapPreApplyRules(a), a)) : seq; | ||
| return dicWords | ||
| .filter(a => !!a.trim()) | ||
| .concatMap(dicWord => this.aff.applyRulesToDicEntry(dicWord)); | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| seqWords() { | ||
| return this.seqAffWords().map(w => w.word); | ||
| } | ||
| /** | ||
| * @internal | ||
| */ | ||
| seqRootWords() { | ||
| return this.dicWordsSeq().map(w => w.word); | ||
| } | ||
| static async createFromFiles(affFile: string, dicFile: string) { | ||
| const aff = await parseAffFileToAff(affFile); | ||
| const dicFileContent = await fs.readFile(dicFile, aff.affInfo.SET || defaultEncoding); | ||
| const dic = dicFileContent.split('\n') | ||
| .slice(1) // The first entry is the count of entries. | ||
| .filter(line => !!line); | ||
| return new IterableHunspellReader({ aff, dic }); | ||
| } | ||
| } |
| import * as stream from 'stream'; | ||
| // cspell:words streamable | ||
| export type Streamable = string | Buffer; | ||
| export type IterableLike<T> = Iterable<T> | IterableIterator<T>; | ||
| /** | ||
| * Transform an iterable into a node readable stream. | ||
| */ | ||
| export function iterableToStream<T extends Streamable>( | ||
| src: IterableLike<T>, | ||
| options: stream.ReadableOptions = { encoding: 'utf8' } | ||
| ): stream.Readable { | ||
| return new ReadableObservableStream(src, options); | ||
| } | ||
| class ReadableObservableStream<T> extends stream.Readable { | ||
| private iter: Iterator<T>; | ||
| private done = false; | ||
| constructor( | ||
| private _source: IterableLike<T>, | ||
| options: stream.ReadableOptions, | ||
| ) { | ||
| super(options); | ||
| } | ||
| _read() { | ||
| if (!this.iter) { | ||
| this.iter = this._source[Symbol.iterator](); | ||
| } | ||
| if (this.done) { | ||
| this.push(null); | ||
| return; | ||
| } | ||
| let r = this.iter.next(); | ||
| while (!r.done && this.push(r.value)) { | ||
| r = this.iter.next(); | ||
| } | ||
| if (r.done) { | ||
| this.done = true; | ||
| // since it is possible for r.value to have something meaningful, we must check. | ||
| if (r.value !== null && r.value !== undefined) { | ||
| this.push(r.value); | ||
| } | ||
| this.push(null); | ||
| } | ||
| } | ||
| } | ||
| export default iterableToStream; |
| const counters = new Map<string, number>(); | ||
| let isLoggingOn = true; | ||
| export function incCounter(name: string, count = 1) { | ||
| counters.set(name, (counters.get(name) || 0) + count); | ||
| return counters.get(name)!; | ||
| } | ||
| /* istanbul ignore next */ | ||
| export function log(message: string) { | ||
| if (isLoggingOn) { | ||
| const logMessage = [...counters] | ||
| .map(([name, value]) => name + ': ' + value) | ||
| .join('; ') + ' ' + message; | ||
| console.log(logMessage); | ||
| } | ||
| } |
| export interface WordInfo { | ||
| word: string; | ||
| rules: string; | ||
| } | ||
| export interface Dictionary<T>{ | ||
| [index: string]: T; | ||
| } |
-43
| export function hrTimeToSeconds([seconds, nanoseconds]: number[]) { | ||
| return seconds + nanoseconds / 1000000000; | ||
| } | ||
| export function uniqueFilter<T>(historySize: number): (i: T) => boolean; | ||
| export function uniqueFilter<T, K>(historySize: number, key: (t: T) => K): (i: T) => boolean; | ||
| export function uniqueFilter<T>(historySize: number, key?: (t: T) => T): (i: T) => boolean { | ||
| const getKey = key ? key : (a: T) => a; | ||
| const f0 = new Set<T>(); | ||
| const f1 = new Set<T>(); | ||
| const found = [f0, f1, f0]; | ||
| let g = 0; | ||
| return (t: T) => { | ||
| const w = getKey(t); | ||
| const p = found[g]; | ||
| if (p.has(w)) return false; | ||
| const s = found[g + 1]; | ||
| const r = !s.has(w); | ||
| p.add(w); | ||
| if (p.size >= historySize) { | ||
| s.clear(); | ||
| g = (g + 1) % 2; | ||
| } | ||
| return r; | ||
| }; | ||
| } | ||
| export function *batch<T>(i: Iterable<T>, size: number): Iterable<T[]> { | ||
| let data: T[] = []; | ||
| for (const t of i) { | ||
| data.push(t); | ||
| if (data.length === size) { | ||
| yield data; | ||
| data = []; | ||
| } | ||
| } | ||
| if (data.length) { | ||
| yield data; | ||
| } | ||
| } |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
4
-33.33%41903
-60.73%25
-51.92%993
-50.35%+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated