week #2
The assignment for this week was to create a new online chatting experience. My first idea was to create this experience where each message will start with the last word from the previous message, but after thinking about it I realized I could maybe try to do something a bit more interesting like throwing some form of sentence generation into the mix. I decided to use a Markov Chain — a type of a statistical model that is useful for predicting the next word (or letter) after each word (or letter), based on a corpus of sentences (or words). It would add a number of words to each message that's sent, essentially interfering between the clients, but in a way that I thought could be playful, especially if the goal is something like creating a story together. It took me an incredibly long time to get it to work, as I don't really know js very well, and this is the first time I'm working with servers and web sockets, but it worked eventually! The main problem is it requires an extremely big corpus in order to actually allow people to send whatever they want. Initially if someone used a word that wasn't in the corpus it just ignored that and didn't generate anything, which was weird. There really isn't a perfect solution to this but I settled on a solution where if a client uses words that aren't part of the corpus, it would add a dot (".") after it, then randomly choose any one word from the corpus and extend the sentence with that. Again, not a perfect solution, but it's better than not doing what it's supposed to do at all.
Unfortunately I didn't get to finish it all, but ideally I would add a different color assigned to each client. I guess that would involve using cookies. I'd also like to have a much larger corpus. I just included it in the script.js file, but ideally I would love to use some substantial databases, like what ML scientists use for NLP projects.