https://github.com/casprwang/word-metrics
use node to analyze a paragraph
https://github.com/casprwang/word-metrics
node-module npm npm-package
Last synced: 2 months ago
JSON representation
use node to analyze a paragraph
- Host: GitHub
- URL: https://github.com/casprwang/word-metrics
- Owner: casprwang
- License: mit
- Created: 2017-09-22T16:59:27.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-22T17:32:54.000Z (about 8 years ago)
- Last Synced: 2025-06-29T12:08:05.805Z (3 months ago)
- Topics: node-module, npm, npm-package
- Language: JavaScript
- Size: 33.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# word-count
show the word count of an article/paragraph## Install
```
npm i word-count
```## Usage
```js
const wordCount = require('word-count')const simplifiedWords = wordCount.simplify('Hello! My name is Song Wang 1 2 3, I am creeeeeazy #@$@!% n\n\n\t\t\t')
simplifiedWords
//=> 'hello my name is song wang 1 2 3 i am creeeeeazy n'wordCount.createMetrics(simplifiedWords)
//=>
{
totalLetters: 50,
totalWords: 13,
uniqueWords: 13,
longWords: 1,
averageWordLength: 2.923076923076923,
wordOccurrences:
{ '1': 1,
'2': 1,
'3': 1,
hello: 1,
my: 1,
name: 1,
is: 1,
song: 1,
wang: 1,
i: 1,
am: 1,
creeeeeazy: 1,
n: 1 }
}```
## API
#### wordCount.simplify(text: string): string
#### wordCount.metrics(text: string): object## License
MIT © [Song Wang](https://songwang.io)