-
-
Save rafaljanwojcik/724cb19bedc065f54784d3f43dbf1b8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def text_to_word_list(text, remove_polish_letters): | |
''' Pre process and convert texts to a list of words | |
method inspired by method from eliorc github repo: https://github.com/eliorc/Medium/blob/master/MaLSTM.ipynb''' | |
text = remove_polish_letters(text) | |
text = str(text) | |
text = text.lower() | |
# Clean the text | |
text = sub(r"[^A-Za-z0-9^,!?.\/'+]", " ", text) | |
text = sub(r"\+", " plus ", text) | |
text = sub(r",", " ", text) | |
text = sub(r"\.", " ", text) | |
text = sub(r"!", " ! ", text) | |
text = sub(r"\?", " ? ", text) | |
text = sub(r"'", " ", text) | |
text = sub(r":", " : ", text) | |
text = sub(r"\s{2,}", " ", text) | |
text = text.split() | |
return text |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment