Package miopia :: Package classifier :: Module BinaryStrategy
[hide private]
[frames] | no frames]

Source Code for Module miopia.classifier.BinaryStrategy

 1  ''' 
 2  Created on 29/01/2013 
 3   
 4  @author: David Vilares Calvo 
 5  ''' 
 6   
 7  from miopia.classifier.ClassificationStrategy import ClassificationStrategy 
 8  from miopia.classifier.PolarityType import PolarityType 
 9   
10 -class BinaryStrategy(ClassificationStrategy):
11 ''' 12 This strategy allows to classify texts such as Positive or Negative 13 ''' 14 15
16 - def __init__(self,threshold):
17 ''' 18 Constructor 19 @param threshold: A float. It establish a numerical threshold to distinguish between classes 20 ''' 21 super(BinaryStrategy,self).__init__(threshold)
22 23
24 - def _type(self, sentiment_info):
25 """ 26 @param sentiment_info: A L{SentimentInfo} object 27 @return: A L{PolarityType} value in {NEGATIVE, POSITIVE} 28 """ 29 if sentiment_info.get_so() > self._threshold: 30 return PolarityType.POSITIVE 31 return PolarityType.NEGATIVE
32