From 57cb5f0f932de0c1655c67a1e49e7783f513a1d4 Mon Sep 17 00:00:00 2001 From: Hugo ter Doest Date: Wed, 17 Feb 2021 20:32:04 +0100 Subject: [PATCH] Made the Japanese stemmer consistent with the other stemmers (#585) * Made the Japanese stemmer consistent with the other stemmers * Add stemmer.js (removed it by accident, stemmers.js had to be removed) --- lib/natural/stemmers/stemmer_ja.js | 2 +- lib/natural/stemmers/stemmers.js | 42 ------------------------------ spec/stemmer_ja_spec.js | 3 +-- 3 files changed, 2 insertions(+), 45 deletions(-) delete mode 100644 lib/natural/stemmers/stemmers.js diff --git a/lib/natural/stemmers/stemmer_ja.js b/lib/natural/stemmers/stemmer_ja.js index f70620c31..8ecbd0f9f 100644 --- a/lib/natural/stemmers/stemmer_ja.js +++ b/lib/natural/stemmers/stemmer_ja.js @@ -133,4 +133,4 @@ StemmerJa.prototype.attach = function () { } */ -module.exports = StemmerJa +module.exports = new StemmerJa() diff --git a/lib/natural/stemmers/stemmers.js b/lib/natural/stemmers/stemmers.js deleted file mode 100644 index 60cf7e158..000000000 --- a/lib/natural/stemmers/stemmers.js +++ /dev/null @@ -1,42 +0,0 @@ -/* -Copyright (c) 2011, Chris Umbel - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -*/ - -'use strict' - -exports.PorterStemmer = require('./stemmers/porter_stemmer') -exports.PorterStemmerFa = require('./stemmers/porter_stemmer_fa') -exports.PorterStemmerFr = require('./stemmers/porter_stemmer_fr') -exports.CarryStemmerFr = require('./stemmers/Carry') -exports.PorterStemmerRu = require('./stemmers/porter_stemmer_ru') -exports.PorterStemmerEs = require('./stemmers/porter_stemmer_es') -exports.PorterStemmerIt = require('./stemmers/porter_stemmer_it') -exports.PorterStemmerNo = require('./stemmers/porter_stemmer_no') -exports.PorterStemmerSv = require('./stemmers/porter_stemmer_sv') -exports.PorterStemmerPt = require('./stemmers/porter_stemmer_pt') -exports.PorterStemmerNl = require('./stemmers/porter_stemmer_nl') -exports.LancasterStemmer = require('./stemmers/lancaster_stemmer') -// StemmerFr and StemmerPl are not stemmers. A Polish stemmer is -// not available, and for French PorterStemmerFr should be used. -// exports.StemmerFr = require('./stemmers/stemmer_fr'); -// exports.StemmerPl = require('./stemmers/stemmer_pl'); -exports.StemmerJa = require('./stemmers/stemmer_ja') -exports.StemmerId = require('./stemmers/indonesian/stemmer_id') diff --git a/spec/stemmer_ja_spec.js b/spec/stemmer_ja_spec.js index fac35bb8f..47fadc769 100644 --- a/spec/stemmer_ja_spec.js +++ b/spec/stemmer_ja_spec.js @@ -22,8 +22,7 @@ THE SOFTWARE. 'use strict' -const StemmerJa = require('../lib/natural/stemmers/stemmer_ja') -const stemmer = new StemmerJa() +const stemmer = require('../lib/natural/stemmers/stemmer_ja') const test = ['コピー', 'コーヒー', 'タクシー', 'パーティー', 'パーティ', 'ヘルプ・センター'] const testResult = ['コピー', 'コーヒ', 'タクシ', 'パーティ', 'パーティ', 'ヘルプ・センタ']