def getPhraseOutcomeState(self,phrase = [] , currentState = emotionState(),i=0):
     eStates =[]
     CES = currentState
     for w in phrase:
         CES = self.getNextEState(w, CES,i)
         eStates.append(CES)
     return eStates.pop()
   def getVector(self, ES =emotionState()):
       output = [0,0]
       #if self.operator == 0:
       output[self.targetVector] = self.weight
 #      else:
 #          output[self.targetVector] =
       return output
    def getNextEState(self,newWord = word(),  currentEState = emotionState(), chIndex =0):
        newES = emotionState()
        fitness=[]
        newES.initNewES(currentEState, newWord)
        c = self.chromozones[chIndex]
        newChEvaluation = c.evaluate(currentEState)
        newValence = newChEvaluation[0] + newWord.valence #this could be adjusted a lot posibly
        if newValence >=4.99:
            newValence = 4.99
        newArousal = newChEvaluation[1] + newWord.arousal
        if newArousal >= 4.99:
            newArousal = 4.99
        nextValence = self.binder.evaluate(currentEState.previousVector[0], newValence)
        nextArousal = self.binder.evaluate(currentEState.previousVector[1], newArousal)

        nextV = [nextValence,nextArousal]
        newES.setCurrentVector(nextV)
        return newES
 def getFitness(self,phrase=[], expectedOutcomeVector=[0,0], startingState=emotionState(),):
     chIndependentOutComeVectors = [self.getPhraseOutcomeState(phrase, startingState, i).currentVector for i in range(self.numCh)]
     return [10-numpy.sqrt((chIndependentOutComeVectors[i][0] - expectedOutcomeVector[0])**2 + (chIndependentOutComeVectors[i][1] - expectedOutcomeVector[1])**2) for i in range(self.numCh)]
    def getPhraseOutcomeVector(self, phrase=[], currentState=emotionState()):
        chIndependentOutComeVectors =[self.getPhraseOutcomeState(phrase, currentState, i).currentVector for i in range (self.numCh)]

        return [sum(chIndependentOutComeVectors[:][i])/len(self.chromozones) for i in range(2)]
 def run(self, ES = emotionState()):
     if self.conditionObject==0:
         if self.condition<4:
             if ES.currentVector[0]<0 and abs(ES.currentVector[0])>self.condition:
                 return self.getVector()
         if self.condition ==4:
             if abs(ES.currentVector[0])<=self.condition:
                 return self.getVector()
         else:
             if ES.currentVector[0]>(self.condition-4):
                 return self.getVector()
     elif self.conditionObject == 1:
         if self.condition < 4:
             if ES.currentVector[1] < 0 and abs(ES.currentVector[1]) >  self.condition:
                 return self.getVector()
         if self.condition == 4:
             if abs(ES.currentVector[1]) <=  self.condition:
                 return self.getVector()
         else:
             if ES.currentVector[1] >  (self.condition - 4):
                 return self.getVector()
     elif self.conditionObject==2:
         if self.condition == 0 and ES.currentPOS.startswith('NN'): #nounn
             return self.getVector()
         if self.condition == 1 and ES.currentPOS.startswith('V'): #verb
             return self.getVector()
         if self.condition == 2 and ES.currentPOS.startswith('RB'):
             return self.getVector()
         if self.condition == 3 and ES.currentPOS.startswith('JJ'):
             return self.getVector()
         if self.condition == 4  and ES.currentPOS.startswith('W'):
             return self.getVector()
         if self.condition == 5  and ES.currentPOS.startswith('P'):
             return self.getVector()
         if self.condition == 6 and ES.currentPOS.startswith('C'):
             return self.getVector()
         if self.condition == 7 and ES.currentPOS.startswith('DT'):
             return self.getVector()
         if self.condition == 8:
             return self.getVector()
     elif self.conditionObject==3:
         if self.condition<4:
             if ES.previousVector[0]<0 and abs(ES.previousVector[0])>self.condition:
                 return self.getVector()
         if self.condition ==4:
             if abs(ES.previousVector[0])<=self.condition:
                 return self.getVector()
         else:
             if ES.previousVector[0]>(self.condition-4):
                 return self.getVector()
     elif self.conditionObject == 4:
         if self.condition < 4:
             if ES.previousVector[1] < 0 and abs(ES.previousVector[1]) > self.condition:
                 return self.getVector()
         if self.condition == 4:
             if abs(ES.previousVector[1]) <= self.condition:
                 return self.getVector()
         else:
             if ES.previousVector[1] > (self.condition - 4):
                 return self.getVector()
     elif self.conditionObject==5:
         if self.condition == 0 and ES.previousPOS.startswith('NN'): #nounn
             return self.getVector()
         if self.condition == 1 and ES.previousPOS.startswith('V'): #verb
             return self.getVector()
         if self.condition == 2 and ES.previousPOS.startswith('RB'):
             return self.getVector()
         if self.condition == 3 and ES.previousPOS.startswith('JJ'):
             return self.getVector()
         if self.condition == 4  and ES.previousPOS.startswith('W'):
             return self.getVector()
         if self.condition == 5  and ES.previousPOS.startswith('P'):
             return self.getVector()
         if self.condition == 6 and ES.previousPOS.startswith('C'):
             return self.getVector()
         if self.condition == 7 and ES.previousPOS.startswith('DT'):
             return self.getVector()
         if self.condition == 8:
             return self.getVector()
     elif self.conditionObject==6:
         if self.condition<4:
             if ES.previous2Vector[0]<0 and abs(ES.previous2Vector[0])>self.condition:
                 return self.getVector()
         if self.condition ==4:
             if abs(ES.previous2Vector[0])<=self.condition:
                 return self.getVector()
         else:
             if ES.previous2Vector[0]>(self.condition-4):
                 return self.getVector()
     elif self.conditionObject == 7:
         if self.condition < 4:
             if ES.previous2Vector[1] < 0 and abs(ES.previous2Vector[1]) >  self.condition:
                 return self.getVector()
         if self.condition == 4:
             if abs(ES.previous2Vector[1]) <= self.condition:
                 return self.getVector()
         else:
             if ES.previous2Vector[1] > (self.condition - 4):
                 return self.getVector()
     elif self.conditionObject==8:
         if self.condition == 0 and ES.previous2POS.startswith('NN'): #nounn
             return self.getVector()
         if self.condition == 1 and ES.previous2POS.startswith('V'): #verb
             return self.getVector()
         if self.condition == 2 and ES.previous2POS.startswith('RB'):
             return self.getVector()
         if self.condition == 3 and ES.previous2POS.startswith('JJ'):
             return self.getVector()
         if self.condition == 4  and ES.previous2POS.startswith('W'):
             return self.getVector()
         if self.condition == 5  and ES.previous2POS.startswith('P'):
             return self.getVector()
         if self.condition == 6 and ES.previous2POS.startswith('C'):
             return self.getVector()
         if self.condition == 7 and ES.previous2POS.startswith('DT'):
             return self.getVector()
         if self.condition == 8:
             return self.getVector()
     elif self.conditionObject == 9:#size of phrase
         if self.condition == 0 and ES.currentPhraseLength > self.condition:
             return self.getVector()
     return [0,0]
 def evaluate(self,ES=emotionState()):
     vector=[0,0]
     for g in self.genes:
         newV = g.run(ES)
         vector = [vector[0] +newV[0],vector[1] +newV[1]]
     return vector