Skip to content

Commit

Permalink
1765 errors in 32016 words, not bad for a first pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Luis Rodrigues committed Jan 2, 2015
1 parent 652e2ed commit 5f35e0e
Showing 1 changed file with 21 additions and 45 deletions.
66 changes: 21 additions & 45 deletions spec/porter_stemmer_pt_spec.js
Expand Up @@ -25,50 +25,26 @@ var PorterStemmer = require('../lib/natural/stemmers/porter_stemmer_pt'),

describe('porter_stemmer_pt', function() {

it('should not stem stopwords', function() {

var words = [
'a', 'e', 'o'
];

for (var i in words) {
expect(PorterStemmer.stem(words[i])).toBe(words[i]);
}
});

it('should perform stemming on a few special case words', function() {

var words = {
'abastecem' : 'abastec',
'abastecer' : 'abastec',
'abastecida' : 'abastec',
'abastecimento' : 'abastec'
};

for (var word in words) {
expect(PorterStemmer.stem(word)).toBe(words[word]);
}
});

// it('should perform stemming on a lot of words', function() {
// var errors = [];
//
// fs.readFileSync('spec/test_data/snowball_pt.txt').toString().split('\n').forEach(function(line) {
// if (line) {
// var fields = line.replace(/\s+/g, ' ').split(' '),
// stemmed = PorterStemmer.stem(fields[0]);
//
// if (stemmed !== fields[1]) {
// errors.push({
// word: fields[0],
// expected: fields[1],
// actual: stemmed
// });
// }
// }
// });
//
// expect(errors.length).toBe(0);
// });
it('should perform stemming on a lot of words', function() {
var errors = [];

fs.readFileSync('spec/test_data/snowball_pt.txt').toString().split('\n').forEach(function(line) {
if (line) {
var fields = line.replace(/\s+/g, ' ').split(' '),
stemmed = PorterStemmer.stem(fields[0]);

if (stemmed !== fields[1]) {
console.log('Error:', fields[0], 'Expected:', fields[1], 'Got:', stemmed);
errors.push({
word: fields[0],
expected: fields[1],
actual: stemmed
});
}
}
});

expect(errors.length).toBe(0);
});

});

0 comments on commit 5f35e0e

Please sign in to comment.