https://github.com/shadowtime2000/easy-text-prediction
An easy text prediction package that doesn't use a complicated neural network.
https://github.com/shadowtime2000/easy-text-prediction
text-prediction
Last synced: 9 months ago
JSON representation
An easy text prediction package that doesn't use a complicated neural network.
- Host: GitHub
- URL: https://github.com/shadowtime2000/easy-text-prediction
- Owner: shadowtime2000
- Created: 2020-06-28T08:42:36.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-07-04T02:33:56.000Z (almost 6 years ago)
- Last Synced: 2025-03-30T06:27:59.581Z (about 1 year ago)
- Topics: text-prediction
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# easy-text-prediction
An easy text prediction package that doesn't use a complicated neural network.
## Installation
You can install this package from npm with:
```
npm install easy-text-prediction
```
## Usage
You can use this package like this:
```javascript
const EasyTextPrediction = require("easy-text-prediction");
var textPredictionTool = new EasyTextPrediction.WordPrediction();
textPredictionTool.train("Everyone is evil", 1);
textPredictionTool.train("Everyone is good", 9);
textPredictionTool.predict("is"); // 10% chance -> evil, 90% chance -> good
textPredictionTool.saveToFile("textPredictionTool.json"); // Save to file
textPredictionTool.loadFromFile("textPredictionTool.json"); // Load from file
textPredictionTool.generate("is", 50); // Generate 50 words that could follow that word. Warning! An error will occur if you do not have sufficient training data.
```
Warning! Your code will not work without specifying a weight.
There are two types of prediction tools:
* Word Prediction predicts by words
* Char Prediction predicts by characters
You can easily swap prediction tools by changing it from ```var textPredictionTool = new EasyTextPrediction.WordPrediction();``` to ```var textPredictionTool = new EasyTextPrediction.CharPrediction();```
## TODO
- [ ] Have text prediction tool remember all text up to that word