_
class StochasticParrot {
data = {};
train(text) {
const words = text.toLowerCase().split(/\s+/);
words.forEach((w, i) => {
if (words[i + 1]) (this.data[w] ??= []).push(words[i + 1]);
});
}
complete(str, len = 5) {
let res = str.toLowerCase().split(/\s+/);
while (len--) {
const next = this.data[res.at(-1)];
if (!next) break;
res.push(next[Math.floor(Math.random() * next.length)]);
}
return res.join(" ");
}
}
parrot.complete("")
Hi, I’m Marcus Felix. I develop digital products through the lens of design. By prioritizing human factors and purpose, I transform complex technical requirements into simple, intuitive experiences.
0 people
liked this website
liked this website
Articles
1.
2.