def calcScore(self, article): """ when an article is passed this function calculates its overall score, by adding content score + feed score + feed update frequency(should be caluculated by taking the deviation from the mean update friquency.) """ # Get the Article title and content in plain text. text = purify.cleanText(article.description) titleText = purify.cleanText(article.title) #Calculate the Score for the texual content of the article (textTopic, textScore) = classifier.classifyArticleText(self.topic.title, text) textTopic = textTopic.replace("_", " ") # print "text : %s, %s" % (textTopic, textScore) #Calculate the Score for the title of the article. (titleTopic,titleScore) = classifier.classifyArticleTitle(self.topic.title, titleText) titleTopic = titleTopic.replace("_", " ") # print "Title : %s, %s" % (titleTopic,titleScore) #Now set the textual scores to minus values if the article "notTopic" if textTopic ==self.topic.title: textScore = textScore * 10000 else: textScore = textScore * (-100) if titleTopic ==self.topic.title+"Title": titleScore = titleScore * 10000 else: titleScore = titleScore * (-100) #Get the Score for the feed from the db scoreFeed = ScoreFeed.query.filter_by(feed = article.feed, topic = self.topic).first() feedScore = scoreFeed.score * 100 #updateFrequencyScore - score based on the feeds update frequncy. #less frequently updated content would get fairly better scores. # Set weights to be given for the calculated individual scores. #TODO: Give an option for the user to set the weights of these scores from GUI. textScoreWeight = TEXT_SCORE_WEIGHT titleScoreWeight = TITLE_SCORE_WEIGHT feedScoreWeight = FEED_SCORE_WEIGHT # updateFrequencyWeight = UPDATE_FREQUENCY_WEIGHT finalScore = ( ( textScoreWeight * textScore ) + ( titleScoreWeight * titleScore ) + ( feedScoreWeight * feedScore ) ) # ( updateFrequencyWeight * updateFrequencyScore ) ) return finalScore
def calcScore(self, article): """ when an article is passed this function calculates its overall score, by adding content score + feed score + feed update frequency(should be caluculated by taking the deviation from the mean update friquency.) """ # Get the Article title and content in plain text. text = purify.cleanText(article.description) titleText = purify.cleanText(article.title) #Calculate the Score for the texual content of the article (textTopic, textScore) = classifier.classifyArticleText(self.topic.title, text) # print "text : %s, %s" % (textTopic, textScore) #Calculate the Score for the title of the article. (titleTopic,titleScore) = classifier.classifyArticleTitle(self.topic.title, titleText) # print "Title : %s, %s" % (titleTopic,titleScore) #Now set the textual scores to minus values if the article "notTopic" if textTopic ==self.topic.title: textScore = textScore * 10000 else: textScore = textScore * (-100) if titleTopic ==self.topic.title+"Title": titleScore = titleScore * 10000 else: titleScore = titleScore * (-100) #Get the Score for the feed from the db feedScore = article.feed.numVotes * 200 #updateFrequencyScore - score based on the feeds update frequncy. #less frequently updated content would get fairly better scores. # Set weights to be given for the calculated individual scores. #TODO: Give an option for the user to set the weights of these scores from GUI. textScoreWeight = 0.55 titleScoreWeight = 0.35 feedScoreWeight = 0.1 # updateFrequencyWeight = 0.1 finalScore = ( ( textScoreWeight * textScore ) + ( titleScoreWeight * titleScore ) + ( feedScoreWeight * feedScore ) ) # ( updateFrequencyWeight * updateFrequencyScore ) ) return finalScore