Created
April 16, 2019 02:41
-
-
Save octoparse/f148e81f4c8f61d16195ca231d37eb53 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
import re | |
import json | |
with open('positive.txt') as f: | |
p_txt = f.read() | |
p_txt = re.sub('[,\.()":;!@#$%^&*\d]|\'s|\'', '', p_txt) | |
p_list = p_txt.replace('\n',' ').replace(' ',' ').lower().split(' ') | |
# test if cool is in the list | |
print 'cool is in the postive list: ', 'cool' in p_list | |
with open('negative.txt') as f: | |
n_txt = f.read() | |
n_txt = re.sub('[,\.()":;!@#$%^&*\d]|\'s|\'', '', n_txt) | |
n_list = n_txt.replace('\n',' ').replace(' ',' ').lower().split(' ') | |
# test if abrade is in the list | |
print 'abrade is in the negative list: ', 'abrade' in n_list | |
# test if cool is in the list | |
print 'cool is in the negative list: ', 'cool' in p_list |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment