-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
387 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
coverage/ | ||
lancaster-stemmer.js | ||
lancaster-stemmer.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,54 @@ | ||
#!/usr/bin/env node | ||
'use strict'; | ||
'use strict' | ||
|
||
var pack = require('./package.json'); | ||
var stemmer = require('.'); | ||
var pack = require('./package.json') | ||
var stemmer = require('.') | ||
|
||
var argv = process.argv.slice(2); | ||
var argv = process.argv.slice(2) | ||
|
||
if ( | ||
argv.indexOf('--help') !== -1 || | ||
argv.indexOf('-h') !== -1 | ||
) { | ||
console.log(help()); | ||
} else if ( | ||
argv.indexOf('--version') !== -1 || | ||
argv.indexOf('-v') !== -1 | ||
) { | ||
console.log(pack.version); | ||
if (argv.indexOf('--help') !== -1 || argv.indexOf('-h') !== -1) { | ||
console.log(help()) | ||
} else if (argv.indexOf('--version') !== -1 || argv.indexOf('-v') !== -1) { | ||
console.log(pack.version) | ||
} else if (argv.length === 0) { | ||
process.stdin.resume(); | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.on('data', function (data) { | ||
console.log(stem(data)); | ||
}); | ||
process.stdin.resume() | ||
process.stdin.setEncoding('utf8') | ||
process.stdin.on('data', function(data) { | ||
console.log(stem(data)) | ||
}) | ||
} else { | ||
console.log(stem(argv.join(' '))); | ||
console.log(stem(argv.join(' '))) | ||
} | ||
|
||
function stem(values) { | ||
return values.split(/\s+/g).map(stemmer).join(' '); | ||
return values | ||
.split(/\s+/g) | ||
.map(stemmer) | ||
.join(' ') | ||
} | ||
|
||
function help() { | ||
return [ | ||
'', | ||
'Usage: ' + pack.name + ' [options] <words...>', | ||
'', | ||
pack.description, | ||
'', | ||
'Options:', | ||
'', | ||
' -h, --help output usage information', | ||
' -v, --version output version number', | ||
'', | ||
'Usage:', | ||
'', | ||
'# output stems', | ||
'$ ' + pack.name + ' considerations', | ||
stem('considerations'), | ||
'', | ||
'# output stems from stdin', | ||
'$ echo "detestable vileness" | ' + pack.name, | ||
stem('detestable vileness') | ||
].join('\n ') + '\n'; | ||
return ( | ||
[ | ||
'', | ||
'Usage: ' + pack.name + ' [options] <words...>', | ||
'', | ||
pack.description, | ||
'', | ||
'Options:', | ||
'', | ||
' -h, --help output usage information', | ||
' -v, --version output version number', | ||
'', | ||
'Usage:', | ||
'', | ||
'# output stems', | ||
'$ ' + pack.name + ' considerations', | ||
stem('considerations'), | ||
'', | ||
'# output stems from stdin', | ||
'$ echo "detestable vileness" | ' + pack.name, | ||
stem('detestable vileness') | ||
].join('\n ') + '\n' | ||
) | ||
} |
Oops, something went wrong.