Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="index.js"></script>
</head>
<body>
<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']
]
model.train(
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.
);
document.write(predictions)
console.log(predictions) // [['you'], ['your']]
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment