TEZv commited on
Commit
2d1049d
·
verified ·
1 Parent(s): 71a6aba

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +51 -22
app.py CHANGED
@@ -1,27 +1,56 @@
1
  import gradio as gr
 
2
 
3
- def classify_project(desc):
4
- desc_l = desc.lower()
5
- scores = {"Science": 0, "Entrepreneurship": 0, "Technology": 0}
6
- sci_kw = ["research","biology","clinical","drug","gene","protein","study","trial","biomedical","cancer","ml","ai","model","data","analysis"]
7
- ent_kw = ["market","startup","investor","revenue","product","customer","business","venture","funding","mvp","saas","platform"]
8
- tech_kw = ["software","api","library","framework","pipeline","infrastructure","tool","package","dashboard","database","cloud","deploy"]
9
- for kw in sci_kw:
10
- if kw in desc_l: scores["Science"] += 1
11
- for kw in ent_kw:
12
- if kw in desc_l: scores["Entrepreneurship"] += 1
13
- for kw in tech_kw:
14
- if kw in desc_l: scores["Technology"] += 1
15
- total = max(sum(scores.values()), 1)
16
- sphere = max(scores, key=scores.get)
17
- confidence = scores[sphere] / total
18
- return f"Sphere: {sphere}\nConfidence: {confidence:.0%}\nScores: {scores}"
19
 
20
- with gr.Blocks(title="set-method") as demo:
21
- gr.Markdown("# SET Method — Classify Your Project\nClassify into Science / Entrepreneurship / Technology spheres")
22
- inp = gr.Textbox(label="Project Description", placeholder="Describe your project...")
23
- out = gr.Textbox(label="Classification Result")
24
- btn = gr.Button("Classify")
25
- btn.click(classify_project, inp, out)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
 
27
  demo.launch()
 
1
  import gradio as gr
2
+ from set_method import classify, score, recommend
3
 
4
+ PERSONALITIES = ["fighter", "operator", "accomplisher", "leader", "engineer", "developer"]
5
+ SPHERES = {"S": "Science", "E": "Entrepreneurship", "T": "Technology"}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
+ def classify_project(text):
8
+ if not text.strip():
9
+ return "Enter a project description above."
10
+ result = classify(text)
11
+ sphere_name = SPHERES.get(result["primary"], result["primary"])
12
+ output = f"**Primary Sphere: {sphere_name}** ({result['primary']})\n\n"
13
+ output += f"| Sphere | Score |\n|---|---|\n"
14
+ for s in ["science", "entrepreneurship", "technology"]:
15
+ bar = "█" * int(result[s] * 10)
16
+ output += f"| {s.title()} | {result[s]:.2f} {bar} |\n"
17
+ return output
18
+
19
+ def score_project(text, framework):
20
+ if not text.strip():
21
+ return "Enter a project description above."
22
+ s = score(text, framework=framework)
23
+ level = "🟢 High" if s >= 0.6 else "🟡 Medium" if s >= 0.3 else "🔴 Low"
24
+ return f"**Score: {s}** ({level})\nFramework: {framework.upper()}"
25
+
26
+ def recommend_quests(personality, sphere):
27
+ try:
28
+ quests = recommend(personality, sphere)
29
+ return f"Recommended quests for **{personality}** in **{SPHERES.get(sphere, sphere)}**:\n\n" + "\n".join(f"- {q}" for q in quests)
30
+ except ValueError as e:
31
+ return str(e)
32
+
33
+ with gr.Blocks(title="set-method — SET Method Toolkit", theme=gr.themes.Base()) as demo:
34
+ gr.Markdown("# SET Method — Classify, Score, Recommend\n[pip install set-method](https://pypi.org/project/set-method/) · [Source](https://github.com/K-RnD-Lab/SPHERE-III-TECHNOLOGY)")
35
+ with gr.Tab("Classify"):
36
+ gr.Markdown("Describe your project to classify it into Science / Entrepreneurship / Technology")
37
+ cls_inp = gr.Textbox(label="Project Description", placeholder="e.g. BRCA2 miRNA analysis with ML pipeline for oncology biomarker discovery", lines=3)
38
+ cls_btn = gr.Button("Classify", variant="primary")
39
+ cls_out = gr.Markdown()
40
+ cls_btn.click(classify_project, cls_inp, cls_out)
41
+ with gr.Tab("Score"):
42
+ gr.Markdown("Score a project against SET or ORBIT framework")
43
+ sc_inp = gr.Textbox(label="Project Description", lines=3)
44
+ sc_fw = gr.Radio(["set", "orbit"], value="set", label="Framework")
45
+ sc_btn = gr.Button("Score", variant="primary")
46
+ sc_out = gr.Markdown()
47
+ sc_btn.click(score_project, [sc_inp, sc_fw], sc_out)
48
+ with gr.Tab("Recommend"):
49
+ gr.Markdown("Get quest recommendations based on personality type and sphere")
50
+ rec_p = gr.Dropdown(PERSONALITIES, label="Personality Type")
51
+ rec_s = gr.Dropdown(["S", "E", "T"], value="S", label="Sphere")
52
+ rec_btn = gr.Button("Recommend", variant="primary")
53
+ rec_out = gr.Markdown()
54
+ rec_btn.click(recommend_quests, [rec_p, rec_s], rec_out)
55
 
56
  demo.launch()