def analyse(self, **params):
        
        logger.debug("Hashtag SVM Analysing with params {}".format(params))
                
        text_input = params.get("input", None)
        self.ESTIMATOR = params.get("estimator", 'LinearSVC')
        
        
        # EXTRACTING FEATURES
        
        text = self._text_preprocessor(text_input)      
        X = self._convert_text_to_vector(text=text, text_input=text_input, Dictionary=self._Dictionary)   
        feature_text = self._extract_features(X=X, classifiers=self._classifiers, estimator=self.ESTIMATOR)              
            
            
        # GENERATING RESPONSE
        
        response = Results()
        entry = Entry()
        entry.nif__isString = text_input

        emotionSet = EmotionSet()
        emotionSet.id = "Emotions"
        
        if self.ESTIMATOR == 'SVC':
            emotionSet.onyx__maxIntensityValue = float(100.0)

        emotion1 = Emotion()        

        for dimension in ['V','A','D']:            
            weights = [feature_text[i] for i in feature_text if (i != 'surprise')]              
            if not all(v == 0 for v in weights):
                value = np.average([self.centroids[i][dimension] for i in feature_text if (i != 'surprise')], weights=weights) 
            else:
                value = 5.0
            emotion1[self.centroid_mappings[dimension]] = value 
        

        emotionSet.onyx__hasEmotion.append(emotion1)    
                    
        for i in feature_text:
            if(self.ESTIMATOR == 'SVC'):
                emotionSet.onyx__hasEmotion.append(Emotion(
                                    onyx__hasEmotionCategory=self.wnaffect_mappings[i],
                                    onyx__hasEmotionIntensity=feature_text[i]))
            else:
                if(feature_text[i] > 0):
                    emotionSet.onyx__hasEmotion.append(Emotion(
                            onyx__hasEmotionCategory=self.wnaffect_mappings[i]))
        
        entry.emotions = [emotionSet,]        
        response.entries.append(entry)
            
        return response
    def analyse(self, **params):
        
        logger.debug("emotionService with params {}".format(params))      
                
        filename = params.get("i", None)        
             
        ## FILE MANIPULATIONS ------------------------------- \ 
        
        if validators.url(filename): 
            filename = self._download_file(saveFolder = self._storage_path, url = filename)
        else:            
            filename = os.path.join(self._storage_path,filename)
        
        logger.info("{} {}".format(datetime.now(), filename))
        
        if not os.path.isfile(filename):
            raise Error("File %s does not exist" % filename) 
            
        
        ## EXTRACTING FEATURES ------------------------------- \ 
        
        feature_set = self._extract_features(filename, convert=True)
        # self._remove_file(filename)
        
        
        ## GENERATING OUTPUT --------------------------------- \        
                
        response = Results()
        entry = Entry()   
        entry['filename'] = os.path.basename(filename)
        
        emotionSet = EmotionSet()
        emotionSet.id = "Emotions"
        
        emotion1 = Emotion() 
        
        for dimension in self._dimensions:
            emotion1[ self._centroid_mappings[dimension] ] = 5*(1+feature_set[dimension])           

        emotionSet.onyx__hasEmotion.append(emotion1)
    
        entry.emotions = [emotionSet,]        
        response.entries.append(entry)
        
        return response
    def analyse(self, **params):

        logger.debug("Analysing with params {}".format(params))

        text_input = params.get("input", None)

        text=self._my_preprocessor(text_input)

        feature_text=self._extract_features(text)

        response = Results()

        entry = Entry(id="Entry",
                      text=text_input)
        emotionSet = EmotionSet(id="Emotions0")
        emotions = emotionSet.onyx__hasEmotion

        for i in feature_text:
            emotions.append(Emotion(onyx__hasEmotionCategory=self._wnaffect_mappings[i],
                                    onyx__hasEmotionIntensity=feature_text[i]))

        entry.emotions = [emotionSet]
        response.entries.append(entry)
        return response
    def analyse(self, **params):
        logger.debug(
            "wassaRegression LSTM Analysing with params {}".format(params))

        st = datetime.now()

        text_input = params.get("input", None)
        text = self._text_preprocessor(text_input)

        self.ESTIMATOR = params.get("estimator", 'LSTM')

        if self.ESTIMATOR == 'LSTM':
            X_lstm = self._lists_to_vectors(text=text)
            feature_text = self._extract_features(X_lstm)

        elif self.ESTIMATOR == 'averaged':
            X_lstm = self._lists_to_vectors(text=text)
            X_svr = self._convert_text_to_vector(text=text,
                                                 text_input=text_input)

            feature_text_lstm = self._extract_features(X_lstm)
            feature_text_svr = self._extract_features_svr(X_svr)

            feature_text = {
                emo: np.mean([feature_text_lstm[emo], feature_text_svr[emo]])
                for emo in self._emoNames
            }

        else:
            X_svr = self._convert_text_to_vector(text=text,
                                                 text_input=text_input)
            feature_text = self._extract_features_svr(X_svr)

        logger.info("{} {}".format(datetime.now() - st, "string analysed"))

        response = Results()

        entry = Entry()
        entry.nif__isString = text_input

        emotionSet = EmotionSet()
        emotionSet.id = "Emotions"

        emotionSet.onyx__maxIntensityValue = float(100.0)

        emotion1 = Emotion()
        for dimension in ['V', 'A', 'D']:
            weights = [feature_text[i] for i in feature_text]
            if not all(v == 0 for v in weights):
                value = np.average(
                    [self.centroids[i][dimension] for i in feature_text],
                    weights=weights)
            else:
                value = 5.0
            emotion1[self.centroid_mappings[dimension]] = value

        emotionSet.onyx__hasEmotion.append(emotion1)

        for i in feature_text:
            emotionSet.onyx__hasEmotion.append(
                Emotion(onyx__hasEmotionCategory=self.wnaffect_mappings[i],
                        onyx__hasEmotionIntensity=float(feature_text[i]) *
                        emotionSet.onyx__maxIntensityValue))

        entry.emotions = [
            emotionSet,
        ]

        response.entries.append(entry)

        return response
    def analyse(self, **params):

        logger.debug("Hashtag LSTM Analysing with params {}".format(params))

        text_input = params.get("input", None)
        self._ESTIMATION = params.get("estimation", 'Probabilities')

        # EXTRACTING FEATURES

        text = self._text_preprocessor(text_input)

        X = self._lists_to_vectors(text=text)
        feature_text = self._extract_features(X=X)

        # GENERATING RESPONSE

        response = Results()

        entry = Entry()
        entry.nif__isString = text_input

        emotionSet = EmotionSet()
        emotionSet.id = "Emotions"

        if self._ESTIMATION == 'Probabilities':
            emotionSet.onyx__maxIntensityValue = float(100.0)

        emotion1 = Emotion()
        for dimension in ['V', 'A', 'D']:
            weights = [
                feature_text[i] for i in feature_text if (i != 'surprise')
            ]
            if not all(v == 0 for v in weights):
                value = np.average([
                    self.centroids[i][dimension]
                    for i in feature_text if (i != 'surprise')
                ],
                                   weights=weights)
            else:
                value = 5.0
            emotion1[self.centroid_mappings[dimension]] = value

        emotionSet.onyx__hasEmotion.append(emotion1)

        for i in feature_text:
            if self._ESTIMATION == 'Probabilities':
                emotionSet.onyx__hasEmotion.append(
                    Emotion(onyx__hasEmotionCategory=self.wnaffect_mappings[i],
                            onyx__hasEmotionIntensity=float(feature_text[i]) *
                            100))
            elif self._ESTIMATION == 'Classes':
                if feature_text[i] > 0:
                    emotionSet.onyx__hasEmotion.append(
                        Emotion(onyx__hasEmotionCategory=self.
                                wnaffect_mappings[i]))
                    #onyx__hasEmotionIntensity=int(feature_text[i])))

        entry.emotions = [
            emotionSet,
        ]
        response.entries.append(entry)

        return response