Taking a stab at writing a text prediction algorithm