Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
<!DOCTYPE html>
<html lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="index.js"></script>
let model = new CPT();
let data = [
['hello', 'how', 'are', 'you'],
['hello', 'how', 'are', 'your', 'studies', 'going', '?'],
['This', 'is', 'a', 'test'],
['How', 'does', 'this', 'work']
data // Training Data
let target = [
['how', 'are']
let predictions = model.predict(
target, // Test input
2, // The number of last elements that will be used
// to find similar sequences, (default: target.length)
2 // The number of predictions required.
console.log(predictions) // [['you'], ['your']]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment