hpratapsingh commited on
Commit
b7f68bd
·
verified ·
1 Parent(s): 594aee3

Upload 2 files

Browse files
Files changed (2) hide show
  1. Content.py +127 -113
  2. interface.py +14 -0
Content.py CHANGED
@@ -1,113 +1,127 @@
1
- # Content.py - Prakriti Analyzer Logic
2
-
3
- def starting(input):
4
- if any(word in input for word in ['hello', 'hii', 'hi', 'wake up']):
5
- response = ("Hii !! If you want to know about your body's constitution and wellness, "
6
- "you are at the right place.\nLet's start. Are you ready?")
7
- else:
8
- response = questions(input)
9
- return response
10
-
11
- response_list = []
12
- prakriti = ''
13
-
14
- def questions(input):
15
- if input == 'sure':
16
- return 'Q1. What is your age?'
17
-
18
- if 'years' in input or 'year' in input:
19
- response_list.append(int(input.split()[0]))
20
- return 'Q2. What is your weight? (Approx or Exact)'
21
-
22
- if any(unit in input for unit in ['kg', 'pounds', 'kgs', 'kilograms']):
23
- response_list.append(float(input.split()[0]))
24
- return 'Q3. What is your height? (Approx or Exact)'
25
-
26
- if any(unit in input for unit in ['ft', 'feet']):
27
- response_list.append(float(input.split()[0]))
28
- return 'Q4. In which region do you live? (Ex. Hilly, Plain, Deserty, Coastal, etc)'
29
-
30
- if input in ['hilly', 'coastal', 'plain', 'highlands', 'lowlands', 'desert', 'deserty', 'plateau']:
31
- response_list.append(input)
32
- return 'Q5. What is your skin type? (Cracked, Clear, Dry, Oily, Smooth, etc.)'
33
-
34
- if all(item in ['cracked', 'clear', 'dry', 'smooth', 'oily', 'cold', 'warm', 'and'] for item in input.split()):
35
- response_list.extend(input.split())
36
- return 'Q6. How does your hair feel? (Dry, Rough, Thin, Breaking, Oily, etc.)'
37
-
38
- if all(item in ['dry', 'rough', 'thin', 'breaking', 'oily', 'thick', 'glossy', 'curly'] for item in input.split()):
39
- response_list.extend(input.split())
40
- return 'Q7. What kind of food do you like normally? (Sweet, Hot, Warm, Cold, Fried, etc.)'
41
-
42
- if all(item in ['sweet', 'hot', 'cold', 'warm', 'fried', 'spicy', 'bitter', 'salty', 'sour'] for item in input.split()):
43
- response_list.extend(input.split())
44
- return "Q8. Does your body generally remain warm, cold, or hot?"
45
-
46
- if any(item in ['hot', 'cold', 'warm'] for item in input.split()):
47
- response_list.extend(input.split())
48
- return 'Q9. Do you get irritated or angry often?'
49
-
50
- if input in ['yes', 'no']:
51
- ynresponse(input, 'irritation')
52
- return 'Q10. How much is your appetite? (Large, Normal, Low)'
53
-
54
- if input in ['large', 'normal', 'low']:
55
- response_list.append(input)
56
- return answer(response_list)
57
-
58
- if input in ['yes why not', 'no not now']:
59
- return ynresponse(input.split()[0], 'know more')
60
-
61
- def ynresponse(yn, condition):
62
- global prakriti
63
- if condition == 'irritation':
64
- response_list.append("irritable" if yn == 'yes' else 'slight irritation')
65
-
66
- if condition == 'know more':
67
- if yn == "yes":
68
- if prakriti == 'vata':
69
- return ("Vata governs movements in the body. Characteristics include dry, light, cold, and energetic. "
70
- "Vata people are often creative and lively but may need to maintain balance by staying warm and eating regularly. Thank You.")
71
- elif prakriti == 'pitta':
72
- return ("Pitta controls metabolism and temperature. Characterized by fire and water elements, pitta brings intelligence, "
73
- "but excess can lead to anger. Stay cool and avoid spicy food for balance. Thank You.")
74
- else:
75
- return ("Kapha brings calmness and stability but may cause laziness in excess. Balance Kapha with exercise and lighter foods. Thank You.")
76
-
77
- def answer(response):
78
- global prakriti
79
- bmi_index = (response[1] / (response[2] * response[2]))
80
-
81
- if bmi_index < 18.44:
82
- response.append('underweight')
83
- elif 18.44 <= bmi_index < 24.88:
84
- response.append('normal')
85
- else:
86
- response.append('overweight')
87
-
88
- if response[2] > 5.9 and response[1] < 66:
89
- response.append('tall')
90
-
91
- if 5.3 < response[2] < 5.9 and response[1] <= 66:
92
- response.append('normal height')
93
- elif response[2] < 5.3 and response[1] > 65:
94
- response.append('short')
95
-
96
- # Categorize based on responses
97
- vata_traits = ['underweight', 'tall', 'dry', 'rough', 'cold', 'slight irritation']
98
- pitta_traits = ['normal', 'smooth', 'oily', 'irritable', 'spicy', 'hot']
99
- kapha_traits = ['overweight', 'short', 'oily', 'sweet', 'salty', 'warm']
100
-
101
- vatacount = sum(1 for item in response if item in vata_traits)
102
- pittacount = sum(1 for item in response if item in pitta_traits)
103
- kaphacount = sum(1 for item in response if item in kapha_traits)
104
-
105
- if vatacount > pittacount and vatacount > kaphacount:
106
- prakriti = 'vata'
107
- return 'Your prakriti is Vata. Do you wish to know more?'
108
- elif pittacount > vatacount and pittacount > kaphacount:
109
- prakriti = 'pitta'
110
- return 'Your prakriti is Pitta. Do you wish to know more?'
111
- else:
112
- prakriti = 'kapha'
113
- return 'Your prakriti is Kapha. Do you wish to know more?'
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ def starting(input):
3
+ if 'hello' in input or 'hii' in input or 'hi' in input or 'wake up' in input:
4
+ response = "Hii !! If you want to know about your body's constituion and wellness, you are at the right place.\nLet's start. Are you ready?"
5
+ else:
6
+ response = questions(input)
7
+ return response
8
+
9
+
10
+ response_list = []
11
+
12
+ prakriti1 = ''
13
+ def questions(input):
14
+ if input == 'sure':
15
+ return 'Q1. What is your age?'
16
+ if 'years' in input or 'year' in input:
17
+ response_list.append(int(input.split()[0]))
18
+ return 'Q2. What is your weight? (Approx or Exact)'
19
+ if 'kg' in input or 'pounds' in input or 'kgs' in input or 'kilograms' in input:
20
+ response_list.append(float(input.split()[0]))
21
+ return 'Q3. What is your height?(Approx or Exact)'
22
+ if 'ft' in input or 'feet' in input:
23
+ response_list.append(float(input.split()[0]))
24
+ return 'Q4. In which region do you live? (Ex. Hilly, Plain, Deserty, Coastal, etc)'
25
+ if input in ['hilly', 'coastal', 'plain', 'highlands', 'lowlands', 'desert', 'deserty', 'plateau']:
26
+ response_list.append(input)
27
+ return 'Q5. What is your skin type? (Cracked, Clear, Dry, Oily, Smooth, etc.)'
28
+ if all(item in ['cracked', 'clear', 'dry', 'smooth', 'oily', 'cold', 'warm', ',', 'and'] for item in input.split()):
29
+ response_list.extend(input.split())
30
+ return 'Q6. How does your hair feel?(Dry, Rough, Thin, Breaking, Scanty, Oily, Thick, Glossy, Long, Curly, Medium, etc.)'
31
+ if all(item in ['dry', 'rough', 'thin', 'breaking', 'scanty', 'oily', 'thick', 'glossy', 'long', 'curly', ',', 'and'] for item in input.split()):
32
+ response_list.extend(input.split())
33
+ return 'Q7. What kind of food you like normally?(Sweet, Hot, Warm, Cold, Fried, Watery foods, Spicy, Bitter, Salty, Junk Food, etc.)'
34
+ if all(item in['sweet', 'hot', 'warm', 'cold', 'fried', 'watery', 'spicy','salty', 'sour', 'bitter', ',', 'and', 'salty', 'junk', 'food', 'foods'] for item in input.split()):
35
+ response_list.extend(input.split())
36
+ return "Q8. Does your body generally remain warm, cold or hot?"
37
+ if input.split()[0] in ['hot', 'cold', 'warm', 'generally', 'and']:
38
+ response_list.extend(input.split())
39
+ return 'Q9. Do you get irritated or angry often?'
40
+ if input == 'yes' or input == 'no':
41
+ ynresponse(input, 'irritation')
42
+ return 'Q10. How much is your appetite? (Like it large, mormal or low)'
43
+ if input in ['large', 'normal', 'low']:
44
+ response_list.append(input)
45
+ return answer(response_list)
46
+ if input == 'yes why not' or input == 'no not now':
47
+ return ynresponse(input.split()[0], 'know more')
48
+
49
+
50
+
51
+
52
+ def ynresponse(yn, condition):
53
+ if condition == 'irritation':
54
+ if yn == 'yes':
55
+ response_list.append("irritable")
56
+ else:
57
+ response_list.append('slight irritation')
58
+
59
+ if condition == 'know more':
60
+ if yn == "yes":
61
+ if prakriti == 'vata':
62
+ return 'Vata is one of the three doshas in Ayurvedic medicine, along with pitta and kapha. It is responsible for controlling various movements in the body, such as blood flow, elimination, and breath. Vata is a combination of air and ether, and it is characterized as dry, light, cold, rough, moving, and always changing. People with a predominantly vata dosha are often energetic, creative, and lively. They tend to be light sleepers with sensitive digestion.To bring the vata dosha back into balance, it is recommended to go to bed earlier, eat regularly, and keep the body warm. Physical activities that focus on balance and flexibility, such as yoga, dancing, or tai chi, are also beneficial. Thank You'
63
+ elif prakriti == 'pitta':
64
+ return 'Pitta is one of the three doshas in Ayurveda, a traditional Indian system of medicine. According to Ayurveda, the world is made up of five elements: air, water, fire, earth, and space. These elements combine to form three doshas: vata, kapha, and pitta. Pitta is believed to be responsible for the body’s metabolic system, temperature regulation, and transformation of the body and mind. The main qualities of pitta are hot, sharp, intense, light, bitter, and spreading Pitta’s elemental makeup consists of fire and water. It is responsible for all chemical and metabolic transformations in the body. When in balance, pitta brings intelligence, courage, clarity, charisma, and the light of understanding. However, when in excess, it can cause imbalances related to excess heat such as anger, jealousy, irritated skin, sharp hunger, and difficulty sleeping. Thank You'
65
+ else:
66
+ return 'Kapha is one of the three doshas in Ayurveda, a system of holistic medicine from India. It is influenced by water and earth elements and has qualities such as cold, heaviness, steadiness, softness, and stability. Kapha body type is characterized by a large frame, stocky body, oily and smooth skin, thick and wavy hair, and strong bones and muscles. Kapha personality is calm, sensitive, romantic, cool, cheerful, lazy, forgiving, and tolerant. Thank You'
67
+
68
+
69
+
70
+
71
+ def answer(response : list):
72
+
73
+ global prakriti
74
+ bmi_index = (0.37*0.37)*(response[1]/(response[2]*response[2]))
75
+ if bmi_index <18.44:
76
+ response.append('underweight')
77
+ elif bmi_index>18.44 and bmi_index<24.88:
78
+ response.append('normal')
79
+ elif bmi_index>24.88:
80
+ response.append('overweight')
81
+
82
+ if response[2]>5.9 and response[1]<66:
83
+ response.append('tall')
84
+
85
+ height = response[2]
86
+ age = response[0]
87
+ weight = response[1]
88
+
89
+ if height<5.9 and height>5.3 and weight<=66:
90
+ response.append('normal height')
91
+
92
+ if height<5.3 and weight>65:
93
+ response.append('short')
94
+
95
+ vata = ['underweight', 'thin', 'tall', 'hilly', 'plain', 'cracked', 'dry', 'rough', 'thin', 'breaking', 'sweet', 'sour', 'salty', 'cold', 'slight irritation']
96
+ pitta = ['normal', 'normal height', 'deserty', 'plain', 'smooth', 'oily', 'scanty', 'good', 'medium', 'spicy', 'hot', 'fried', 'irritable' ]
97
+ kapha = ['overweight', 'short', 'coastal','oily', 'glossy','oily', 'hot','warm', 'hot', 'low', 'irritable' ]
98
+
99
+ vatacount = 0
100
+ for i in range(len(response)):
101
+ if response[i] in vata:
102
+ vatacount += 1
103
+
104
+ pittacount = 0
105
+ for i in range(len(response)):
106
+ if response[i] in pitta:
107
+ pittacount += 1
108
+
109
+ kaphacount = 0
110
+ for i in range(len(response)):
111
+ if response[i] in kapha:
112
+ kaphacount += 1
113
+
114
+ if vatacount>pittacount and vatacount>kaphacount:
115
+ ans = 'After carefully analyzing your responses I say your prakriti is Vata. Do you wish to know more about your prakriti?'
116
+ prakriti = 'vata'
117
+ elif pittacount>vatacount and pittacount>kaphacount:
118
+ ans = 'After carefully analyzing your responses I say your prakriti is Pitta. Do you wish to know more about your prakriti?'
119
+ prakriti = 'pitta'
120
+ else:
121
+ ans = 'After carefully analyzing your responses I say your prakriti is Kapha. Do you wish to know more about your prakriti?'
122
+ prakriti = 'kapha'
123
+
124
+ return ans
125
+
126
+ ans = questions('hot')
127
+ print(ans)
interface.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import time
3
+ import Content as con
4
+
5
+
6
+ def random_response(message,history):
7
+ answer = con.starting(message.lower())
8
+ for i in range(len(answer)):
9
+ time.sleep(0.03)
10
+ yield answer[:i+1]
11
+
12
+
13
+ demo = gr.ChatInterface(random_response, title= "Prakriti Analyzer", description='This bot is made with love and care to guide you towards a better life by giving you a knowlege about your prakriti or your body costitution.',).queue()
14
+ demo.launch(inbrowser=True)