Code to convert lexical data into various matrices