Professional Documents
Culture Documents
Final
Final
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
for char in punctuation_chars:
if char in word:
word = word.replace(char, "")
return word
*******
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
def strip_punctuation(word):
for char in punctuation_chars:
if char in word:
word = word.replace(char, "")
return word
positive_words = []
with open("positive_words.txt") as pos_f:
for lin in pos_f:
if lin[0] != ';' and lin[0] != '\n':
positive_words.append(lin.strip())
*******
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
def strip_punctuation(word):
for char in punctuation_chars:
if char in word:
word = word.replace(char, "")
return word
def get_neg(string_n):
string_n = string_n.split(" ")
count_negative = 0
for word_n in string_n:
word_n = word_n.lower()
if strip_punctuation(word_n) in negative_words:
count_negative = count_negative + 1
return count_negative
negative_words = []
with open("negative_words.txt") as pos_f:
for lin in pos_f:
if lin[0] != ';' and lin[0] != '\n':
negative_words.append(lin.strip())
********
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@']
def strip_punctuation(word):
for char in punctuation_chars:
if char in word:
word = word.replace(char, "")
return word
def get_pos(string_p):
string_p = string_p.split(" ")
count_positive = 0
for word_p in string_p:
word_p = word_p.lower()
if strip_punctuation(word_p) in positive_words:
count_positive = count_positive + 1
return count_positive
def get_neg(string_n):
string_n = string_n.split(" ")
count_negative = 0
for word_n in string_n:
word_n = word_n.lower()
if strip_punctuation(word_n) in negative_words:
count_negative = count_negative + 1
return count_negative
negative_words = []
with open("negative_words.txt") as pos_f:
for lin in pos_f:
if lin[0] != ';' and lin[0] != '\n':
negative_words.append(lin.strip())