Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
| print("Hello World") |
This file contains hidden or 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 get_non_empty_lines(lines): | |
| """ | |
| returns non empty lines from a list of lines | |
| """ | |
| clean_lines = [] | |
| for line in lines: | |
| str_line = line.strip() | |
| if str_line: | |
| clean_lines.append(str_line) | |
| return clean_lines |
This file contains hidden or 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
| # remove the following punctuation/characters from cudf | |
| filters = [ '!', '"', '#', '$', '%', '&', '(', ')', '*', '+', '-', '.', '/', '\\', ':', ';', '<', '=', '>', | |
| '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '\~', '\t','\\n',"'",",",'~' , '—'] | |
| text_col_sample = df.head(5) | |
| text_col_sample['text'].to_pandas() | |
| text_col_sample['text_clean'] = text_col_sample['text'].str.replace_multi(filters, ' ', regex=False) | |
| text_col_sample['text_clean'] = text_col_sample['text_clean'].str.lower() | |
| text_col_sample['text_clean'].to_pandas() |
This file contains hidden or 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
| text_col_sample['text_clean'] = text_col_sample['text_clean'].str.lower() | |
| text_col_sample['text_clean'].to_pandas() |
This file contains hidden or 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
| STOPWORDS = nltk.corpus.stopwords.words('english') | |
| STOPWORDS = nvstrings.to_device(STOPWORDS) | |
| text_col_sample['text_clean'] = nvtext.replace_tokens(text_col_sample['text_clean'].data, STOPWORDS, ' ') | |
| text_col_sample['text_clean'].to_pandas() |
This file contains hidden or 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
| text_col_sample['text_clean'] = text_col_sample['text_clean'].str.replace(r"\s+", ' ',regex=True) | |
| text_col_sample['text_clean'] = text_col_sample['text_clean'].str.strip(' ') | |
| text_col_sample['text_clean'].to_pandas() |
This file contains hidden or 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
| STOPWORDS = nltk.corpus.stopwords.words('english') | |
| filters = [ '!', '"', '#', '$', '%', '&', '(', ')', '*', '+', '-', '.', '/', '\\', ':', ';', '<', '=', '>', | |
| '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '\~', '\t','\\n',"'",",",'~' , '—'] | |
| def preprocess_text(input_strs , filters=None , stopwords=STOPWORDS): | |
| """ | |
| * filter punctuation | |
| * to_lower | |
| * remove stop words (from nltk corpus) |