complete code for processing text data