Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 13 additions & 19 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
{
"env": {
"development": {
"presets": [
["@babel/env"]
],
"plugins": [
"add-module-exports"
]
},
"production": {
"presets": [
["@babel/env"],
"minify"
],
"plugins": [
"add-module-exports"
]
}
}
"env": {
"test": {
"plugins": ["@babel/plugin-transform-modules-commonjs"]
},
"development": {
"presets": [["@babel/env"]],
"plugins": ["add-module-exports"]
},
"production": {
"presets": [["@babel/env"], "minify"],
"plugins": ["add-module-exports"]
}
}
}
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
indent_style = tab

[*.md]
trim_trailing_whitespace = false
19 changes: 0 additions & 19 deletions .eslintrc

This file was deleted.

21 changes: 21 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
env: {
browser: true,
node: true,
es2021: true,
jest: true
},
extends: ['eslint:recommended'],
parserOptions: {
ecmaVersion: 12,
sourceType: 'module'
},
rules: {
quotes: ['error', 'single', { avoidEscape: true }],
semi: ['error', 'never'],
indent: 'off',
'no-mixed-spaces-and-tabs': ['warn', 'smart-tabs'],
'linebreak-style': ['error', 'unix'],
'no-unused-vars': 'warn'
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ jspm_packages
.idea
lib
package-lock.json
yarn.lock
.DS_Store
Thumbs.db
11 changes: 8 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
*.log
npm-debug.log*
coverage
docs
.vscode
.nyc_output
node_modules
package-lock.json
yarn.lock
src
test
CHANGELOG.md
.travis.yml
CONTRIBUTING.md
.editorconfig
.eslintrc
.eslintrc.js
.vscode
.babelrc
webpack.config.js
.gitignore
.DS_Store
Thumb.db
7 changes: 7 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"trailingComma": "none",
"tabWidth": 4,
"useTabs": true,
"semi": false,
"singleQuote": true
}
10 changes: 0 additions & 10 deletions .travis.yml

This file was deleted.

3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode"]
}
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"editor.formatOnSave": true,
"files.insertFinalNewline": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.useTabs": true
}
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,24 @@

All notable changes to this project will be documented in this file.

## [2.0.1] - 2023-02-05

### Changed

- Fixed all instances of improper object literal type checks
- Fixed bug where terms were added to the model vocabulary when making predictions
- Migrated tests from Mocha/Chai to Jest

## [2.0.0] - 2020-08-28

### Breaking changes

* Removed `minimumConfidence` from `Model`
- Removed `minimumConfidence` from `Model`

## [1.0.0] - 2020-08-26

Initial release

[2.0.1]: https://github.com/andreekeberg/ml-classify-text-js/releases/tag/2.0.1
[2.0.0]: https://github.com/andreekeberg/ml-classify-text-js/releases/tag/2.0.0
[1.0.0]: https://github.com/andreekeberg/ml-classify-text-js/releases/tag/1.0.0
28 changes: 14 additions & 14 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

This document contains basic guidelines to make contributing to this project as easy and transparent as possible, whether it's:

- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer
- Reporting a bug
- Discussing the current state of the code
- Submitting a fix
- Proposing new features
- Becoming a maintainer

## Pull requests are actively welcomed

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've changed APIs, update the documentation.
5. Make sure your code lints.
6. Issue your pull request.
4. Make sure your code lints.
5. Issue your pull request.

## Any contributions you make will be under the MIT Software License

Expand All @@ -28,13 +28,13 @@ All bugs are tracked using GitHub issues to track public bugs. Report a bug by [

**Great bug reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)
- A quick summary and/or background
- Steps to reproduce
- Be specific!
- Give sample code if you can.
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

## License

Expand Down
44 changes: 22 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ const classifier = new Classifier()
### Training a model

```javascript
let positive = [
'This is great, so cool!',
'Wow, I love it!',
'It really is amazing',
const positive = [
'This is great, so cool!',
'Wow, I love it!',
'It really is amazing'
]

let negative = [
'This is really bad',
'I hate it with a passion',
'Just terrible!',
const negative = [
'This is really bad',
'I hate it with a passion',
'Just terrible!'
]

classifier.train(positive, 'positive')
Expand All @@ -64,10 +64,10 @@ classifier.train(negative, 'negative')
### Getting a prediction

```javascript
let predictions = classifier.predict('It sure is pretty great!')
const predictions = classifier.predict('It sure is pretty great!')

if (predictions.length) {
predictions.forEach(prediction => {
predictions.forEach((prediction) => {
console.log(`${prediction.label} (${prediction.confidence})`)
})
} else {
Expand All @@ -89,12 +89,12 @@ The following configuration options can be passed both directly to a new [Model]

#### Options

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| **nGramMin** | `int` | `1` | Minimum n-gram size |
| **nGramMax** | `int` | `1` | Maximum n-gram size |
| **vocabulary** | `Array` \| `Set` \| `false` | `[]` | Terms mapped to indexes in the model data, set to `false` to store terms directly in the data entries |
| **data** | `Object` | `{}` | Key-value store of labels and training data vectors |
| Property | Type | Default | Description |
| -------------- | --------------------------- | ------- | ----------------------------------------------------------------------------------------------------- |
| **nGramMin** | `int` | `1` | Minimum n-gram size |
| **nGramMax** | `int` | `1` | Maximum n-gram size |
| **vocabulary** | `Array` \| `Set` \| `false` | `[]` | Terms mapped to indexes in the model data, set to `false` to store terms directly in the data entries |
| **data** | `Object` | `{}` | Key-value store of labels and training data vectors |

### Using n-grams

Expand All @@ -112,7 +112,7 @@ const classifier = new Classifier({
nGramMax: 2
})

let tokens = classifier.tokenize('I really dont like it')
const tokens = classifier.tokenize('I really dont like it')

console.log(tokens)
```
Expand All @@ -135,7 +135,7 @@ After training a model with large sets of data, you'll want to store all this da
To do this, simply use the `serialize` method on your [Model](docs/model.md), and either save the data structure to a file, send it to a server, or store it in any other way you want.

```javascript
let model = classifier.model
const model = classifier.model

console.log(model.serialize())
```
Expand Down Expand Up @@ -173,10 +173,10 @@ Returning:

## Documentation

* [Classifier](docs/classifier.md)
* [Model](docs/model.md)
* [Vocabulary](docs/vocabulary.md)
* [Prediction](docs/prediction.md)
- [Classifier](docs/Classifier.md)
- [Model](docs/Model.md)
- [Vocabulary](docs/Vocabulary.md)
- [Prediction](docs/Prediction.md)

## Contributing

Expand Down
Loading