def __init__(self): self.general = general.extractor() self.microblogs = microblogs.extractor() self.review = review.extractor() self.comments = comments.extractor() self.blogs_news = blogs_news.extractor() self.scalerLargeText = scorer(1.0) self.scalerMediumText = scorer(0.5) self.scalerSmallText = scorer(1.5)
def getSentiment(self, text): score_sentiment = scorer().scaleScore( self.senti_object.getSentimentScore(text)) if score_sentiment <= -2: return "Negative" elif score_sentiment >= 2: return "Positive" else: return "Neutral"
comment_tag_clean = comment_tag.dropna() comments = comment_tag_clean['Comment'] tags = comment_tag_clean['tags'] S = extractor() comments = np.array(comments) tags = np.array(tags) total_correct = 0 for i in range(0, comments.shape[0]): # print i predictions = [] true_values = [] current_pred = "" from scoreScaler import scorer score_sentiment = scorer().scaleScore(S.getSentimentScore(comments[i])) if score_sentiment <= -2: predictions.append("untrustworthy") current_pred = "untrustworthy" elif score_sentiment >= 2: predictions.append("trustworthy") current_pred = "trustworthy" else: predictions.append("mixed") current_pred = "mixed" true_values.append(tags[i]) print current_pred, tags[i], score_sentiment if current_pred == tags[i]: total_correct = total_correct + 1 print comment_tag_clean.shape[0], total_correct
comment_tag_clean = comment_tag.dropna() comments = comment_tag_clean['Comment'] tags = comment_tag_clean['tags'] S = extractor() comments = np.array(comments) tags = np.array(tags) total_correct = 0 for i in range(0,comments.shape[0]): # print i predictions = [] true_values = [] current_pred = "" from scoreScaler import scorer score_sentiment = scorer().scaleScore(S.getSentimentScore(comments[i])) if score_sentiment <= -2: predictions.append("untrustworthy") current_pred = "untrustworthy" elif score_sentiment >= 2: predictions.append("trustworthy") current_pred = "trustworthy" else: predictions.append("mixed") current_pred = "mixed" true_values.append(tags[i]) print current_pred, tags[i],score_sentiment if current_pred == tags[i]: total_correct = total_correct + 1 print comment_tag_clean.shape[0], total_correct
def __init__(self): self.SentiModel = self.load_obj("_model") self.ch2 = self.load_obj("_feature_selector") self.vectorizer = self.load_obj("_vectorizer") self.Scorer = scorer(1.0)