# -*- coding: utf-8 -*-
"""emotions.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1gK9UTnsYKFtsIWUIDS1T2Srj4deta4as

# **About**
This is a Program which can **simulate** EMOTIONS and MOOD.                      
*This contains of the following parts:*


---




*   **Essential Information:**
    *This contains some essential snippets for core processing etc.*
*   **Knowladge Input:** 
    *Here the System processes and stores the Data in its ONLINE DATABASE.*
*   **Get Value:**
    *This fetches the value from the ***knowladge*** Database and is prossesed by removing unnecessary **" , "** and " [ , ] " for furthur processing if the data in **Mood** and **Emotion** part.* 
*   **Mood of the System:**
    *Here the System calculates its ***Mood*** from its Database.*
*   **Refine Input:**
    *As the Data is stored in a unique format in the Database, it is Decoded here.*
*   **Processing:**
    *Here the System calculates its ***Emotion*** from its Database.*
*   **Output:**
    **This is the final output or the status of imotion of the System.

## **Essential Information**
"""
"""## **pip install python-firebase**"""

ask = 'ghost'
inp = 0
feel = 'good'
stob = [0, 1 , 2 , 3 , 4]
stog = [6 , 7 , 8 , 9]
ovimo = 'happy'


"""## **Knowladge Input**"""

knoutings= 'covid-19'
emI = 0
from firebase import firebase
firebase = firebase.FirebaseApplication('https://ai-emotion.firebaseio.com/', None)
firebase.put('/knowlage',knoutings,emI)

count = firebase.get('/count',None)
count = str(count).replace('None, ', '')
count = str(count).replace('[', '')
count = str(count).replace(']', '')
count = str(count).replace(' ', '')

count2 = int(count) + 1

firebase.put('/count','1',count2)

print(count2)

if emI == 0 or 1 or 2 or 3 or 4:
  firebase.put('/oi',count2,0)

else:
  firebase.put('/oi',count2,10)

"""## **Get Value**"""

from firebase import firebase  
firebase = firebase.FirebaseApplication('https://ai-emotion.firebaseio.com/', None)  

ovalue = firebase.get('/oi',None)
ovalue = str(ovalue).replace('None, ', '')
ovalue = str(ovalue).replace('[', '')
ovalue = str(ovalue).replace(']', '')
ovalue = str(ovalue).replace(' ', '')
ovalue = ovalue.split(',')

b = firebase.get('/knowlage',None)
c=str(b).replace('{','')
c2=str(c).replace('}','')
c3= str(c2).replace("'",'')
c5= str(c3).replace(' ','')
c4=str(c5).split(',')

moodG = ovalue.count('10')
moodB = ovalue.count('0')

"""## **Mood of the System**"""

if moodG < moodB :
  ovimo = 'Frustrated'

if moodG > moodB :
  ovimo = 'Happy'

if moodG == len(ovalue) :
  ovimo = 'Very-Happy'

if moodB == len(ovalue) :
  ovimo = 'Depressed'

if moodB == moodG :
  ovimo = 'Moderate'

"""## **Refine Input**"""

for y in c4:
  compare = y.split(':')
  if ask == compare[0]:
    inp = int(compare[1])

"""## **Processing**"""

knowb = bad = sum(stob)/len(stob)
knowg = good = sum(stog)/len(stog)


# Bad
if inp > bad and inp<5 :
  feel = 'angry'
  print(feel)

if inp == bad and inp<5 :
  feel = 'sad'
  print(feel)

if inp < 1 and inp<5 :
  feel = 'scared'
  print(feel)

# Good
if inp > good and inp<10 and inp>5 :
  feel = 'excited'
  print(feel)

if inp < good and inp<10 and inp>5 :
  feel = 'happy'
  print(feel)

if inp == good and inp<10 and inp>5 :
  feel = 'h-cited'
  print(feel)

if inp == 5 :
  feel = 'nothing'
  print(feel)

"""## **Output**"""

print('I am feeling '+ feel+ ' about ' + ask)
print('mood:'+ ovimo)

def emotion (ask) :
  
  
  knowb = bad = sum(stob)/len(stob)
  knowg = good = sum(stog)/len(stog)

  
  if moodG < moodB :
    ovimo = 'Frustrated'

  if moodG > moodB :
    ovimo = 'Happy'

  if moodG == len(ovalue) :
    ovimo = 'Very-Happy'

  if moodB == len(ovalue) :
    ovimo = 'Depressed'

  if moodB == moodG :
    ovimo = 'Moderate'


  # Bad
  if inp > bad and inp<5 :
    feel = 'angry'
    print(feel)

  if inp == bad and inp<5 :
    feel = 'sad'

  if inp < 1 and inp<5 :
    feel = 'scared'

  # Good
  if inp > good and inp<10 and inp>5 :
    feel = 'excited'
    

  if inp < good and inp<10 and inp>5 :
    feel = 'happy'


  if inp == good and inp<10 and inp>5 :
    feel = 'h-cited'
    

  if inp == 5 :
    feel = 'nothing'
    

  emotion.feelings = 'I am feeling '+ feel+ ' about ' + ask
  emotion.mood = 'mood:'+ ovimo

def learn (input, emotion, url) :
  
  knoutings= input
  emI = emotion
  from firebase import firebase
  firebase = firebase.FirebaseApplication(url, None)
  firebase.put('/knowlage',knoutings,emI)

  count = firebase.get('/count',None)
  count = str(count).replace('None, ', '')
  count = str(count).replace('[', '')
  count = str(count).replace(']', '')
  count = str(count).replace(' ', '')

  count2 = int(count) + 1

  firebase.put('/count','1',count2)

  print(count2)

  if emI == 0 or 1 or 2 or 3 or 4:
    firebase.put('/oi',count2,0)

  else:
    firebase.put('/oi',count2,10)