Shirjannn commited on
Commit
20d5aa5
·
verified ·
1 Parent(s): 660ce25

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py CHANGED
@@ -111,6 +111,62 @@ def create_semantic_plot(user_vec, best_quote, best_school):
111
  fig.update_layout(title="🧭 Conceptual Map", showlegend=False)
112
  return fig
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  # رابط کاربری با Gradio
115
  with gr.Blocks(title="Philosophical Analyzer") as demo:
116
  gr.Markdown("## 📝 Enter Philosophical Text")
 
111
  fig.update_layout(title="🧭 Conceptual Map", showlegend=False)
112
  return fig
113
 
114
+ def psychological_analysis(text):
115
+ rules = [
116
+ {
117
+ "keywords": ["guilt", "remorse"],
118
+ "aspect": "Moral guilt",
119
+ "followed": "Helps in personal growth, emotional release, and reconciliation.",
120
+ "ignored": "Can lead to chronic anxiety, regret, or depression."
121
+ },
122
+ {
123
+ "keywords": ["freedom", "free will"],
124
+ "aspect": "Freedom & Will",
125
+ "followed": "Encourages autonomy and a sense of responsibility.",
126
+ "ignored": "May result in feelings of helplessness or existential crisis."
127
+ },
128
+ {
129
+ "keywords": ["altruism", "help", "others"],
130
+ "aspect": "Altruism",
131
+ "followed": "Improves social bonding and personal satisfaction.",
132
+ "ignored": "May cause loneliness or self-centered thinking."
133
+ },
134
+ {
135
+ "keywords": ["anxiety", "fear"],
136
+ "aspect": "Anxiety & Fear",
137
+ "followed": "Leads to caution and preparedness.",
138
+ "ignored": "Might cause mental blocks, phobia, or stress disorders."
139
+ },
140
+ {
141
+ "keywords": ["reason", "logic"],
142
+ "aspect": "Rationality",
143
+ "followed": "Supports wise decision-making and clarity.",
144
+ "ignored": "Can result in poor judgments and emotional impulses."
145
+ }
146
+ ]
147
+
148
+ results = []
149
+ lower_text = text.lower()
150
+
151
+ for rule in rules:
152
+ if any(keyword in lower_text for keyword in rule["keywords"]):
153
+ results.append({
154
+ "aspect": rule["aspect"],
155
+ "followed": rule["followed"],
156
+ "ignored": rule["ignored"]
157
+ })
158
+
159
+ return results
160
+
161
+ psychological_results = psychological_analysis(user_input)
162
+
163
+ psych_output = ""
164
+ for item in psychological_results:
165
+ psych_output += f"🧠 Psychological Aspect: {item['aspect']}\n"
166
+ psych_output += f"✅ If Followed: {item['followed']}\n"
167
+ psych_output += f"❌ If Ignored: {item['ignored']}\n\n"
168
+
169
+
170
  # رابط کاربری با Gradio
171
  with gr.Blocks(title="Philosophical Analyzer") as demo:
172
  gr.Markdown("## 📝 Enter Philosophical Text")