Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jamesmh/tagbuilder
Builds Tags (common words) from text.
https://github.com/jamesmh/tagbuilder
Last synced: about 1 month ago
JSON representation
Builds Tags (common words) from text.
- Host: GitHub
- URL: https://github.com/jamesmh/tagbuilder
- Owner: jamesmh
- License: apache-2.0
- Created: 2017-02-24T03:11:28.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-01-29T14:46:10.000Z (almost 6 years ago)
- Last Synced: 2024-11-03T03:32:37.855Z (about 2 months ago)
- Language: JavaScript
- Size: 103 KB
- Stars: 0
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TagBuilder
Blogs, for example, may want to keep track of the most common words within a blog post. This small utility can help to solve this problem.
Give the utility some text and it will give you the number of occurances for each word in the text.
Only words with more than 3 characters are counted.
Also, all words are converted to lowercase (case-insensitive).
## Install
Run ```npm install --save-dev tagbuilder```If you clone this repo, you can ```npm install``` then run the jest unit tests by ```npm test```.
## Usage
### Single String
```javascript
const TagBuilder = require('tagbuilder').TagBuilder;
const builder = new TagBuilder();//then...
builder.Generate("i am some text here we go text");
//output
//[ { name: 'some', amount: 1 },
// { name: 'text', amount: 2 },
// { name: 'here', amount: 1 } ]
```### Array Of Strings
Alternatively, you may supply an array of strings to the ```Generate()``` method.
The results will be calculated/aggregated for all the strings supplied (as one unit).
```javascript
const texts = [`hello i am
some weird
text but my tags still count!`,
`hello i am more text`,
`some weird text ...`]
console.log(b.Generate(texts));///output
/// [ { name: 'hello', amount: 2 },
/// { name: 'some', amount: 2 },
/// { name: 'weird', amount: 2 },
/// { name: 'text', amount: 3 },
/// { name: 'tags', amount: 1 },
/// { name: 'still', amount: 1 },
/// { name: 'count', amount: 1 },
/// { name: 'more', amount: 1 } ]```