_

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(" ");
  }
}

Hi, I’m Marcus Felix. I develop digital products, from design to implementation. More important than building is to know what to build. I write about my learnings and share my projects here.

0 people
liked this website
1.

Work

Muun GmbH

2.

Side project

memoria

3.

Listening

Steely Dan

4.

Learning

German A2

5.

Side project

Dracula

6.

Side project

Barney

7.

Reading

Fluent Forever

8.

Gaming

Hytale

8.

Gaming

Valheim

Articles