hunspell-reader
Advanced tools
Comparing version 3.1.1 to 3.1.2
@@ -111,3 +111,3 @@ import { Converter } from './converter'; | ||
*/ | ||
applyRulesToDicEntry(line: string): AffWord[]; | ||
applyRulesToDicEntry(line: string, maxDepth?: number): AffWord[]; | ||
/** | ||
@@ -114,0 +114,0 @@ * @internal |
@@ -7,2 +7,3 @@ "use strict"; | ||
const GS = require("gensequence"); | ||
const util_1 = require("./util"); | ||
// cSpell:enableCompoundWords | ||
@@ -29,7 +30,11 @@ const log = false; | ||
*/ | ||
applyRulesToDicEntry(line) { | ||
applyRulesToDicEntry(line, maxDepth) { | ||
const maxSuffixDepth = maxDepth !== undefined ? maxDepth : this.maxSuffixDepth; | ||
const [lineLeft] = line.split(/\s+/, 1); | ||
const [word, rules = ''] = lineLeft.split('/', 2); | ||
return this.applyRulesToWord(asAffWord(word, rules), this.maxSuffixDepth) | ||
.map(affWord => (Object.assign(Object.assign({}, affWord), { word: this._oConv.convert(affWord.word) }))); | ||
const results = this.applyRulesToWord(asAffWord(word, rules), maxSuffixDepth) | ||
.map(affWord => (Object.assign(Object.assign({}, affWord), { word: this._oConv.convert(affWord.word) }))) | ||
.filter(util_1.uniqueFilter(10000, a => a.word)); | ||
results.sort((a, b) => a.word < b.word ? -1 : 1); | ||
return results; | ||
} | ||
@@ -86,3 +91,3 @@ /** | ||
.reduce((a, b) => a.concat(b), []) | ||
.filter(sub => sub.replace.test(word)) | ||
.filter(sub => sub.remove === '0' || sub.replace.test(word)) | ||
.map(sub => this.substitute(affix, partialAffWord, sub)) | ||
@@ -89,0 +94,0 @@ .map(affWord => logAffWord(affWord, 'applyAffixToWord')); |
@@ -129,3 +129,3 @@ "use strict"; | ||
replace: fixMatch(type, strip), | ||
affix, | ||
affix: cleanAffixAttach(affix), | ||
condition, | ||
@@ -136,2 +136,7 @@ extra, | ||
} | ||
function cleanAffixAttach(affix) { | ||
const [fix, rules] = affix.split('/', 2); | ||
const attach = fix === '0' ? '' : fix; | ||
return attach + (rules ? '/' + rules : ''); | ||
} | ||
function fixMatch(type, match) { | ||
@@ -138,0 +143,0 @@ const exp = affixMatchToRegExpString(match); |
{ | ||
"name": "hunspell-reader", | ||
"version": "3.1.1", | ||
"version": "3.1.2", | ||
"description": "A library for reading Hunspell Dictionary Files", | ||
@@ -47,3 +47,3 @@ "bin": "bin.js", | ||
"chai": "^4.2.0", | ||
"coveralls": "^3.0.7", | ||
"coveralls": "^3.0.8", | ||
"mocha": "^6.2.2", | ||
@@ -50,0 +50,0 @@ "nyc": "^14.1.1", |
46173
1112