WENior commited on
Commit
99a738e
·
verified ·
1 Parent(s): 945c653

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -35
app.py CHANGED
@@ -62,60 +62,74 @@ def analyze_ec(expression):
62
 
63
 
64
 
65
- # ---- 前端 UI(升级美化版) ----
66
  with gr.Blocks(
67
- theme=gr.themes.Soft(
68
- primary_hue="indigo",
69
- secondary_hue="blue",
70
- neutral_hue="gray",
71
- radius_size="md",
72
- text_size="lg",
73
- ),
74
  css="""
75
- .gradio-container {background: linear-gradient(135deg, #eef2ff, #e0f2fe);}
76
  .card {
77
- background: rgba(255, 255, 255, 0.73);
78
- padding: 18px;
79
  border-radius: 12px;
80
- box-shadow: 0 4px 12px rgba(0,0,0,0.05);
81
  margin-bottom: 12px;
82
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  """
84
  ) as demo:
85
 
86
- gr.Markdown(
87
- """
88
- <div style='text-align:center; margin-bottom: 20px;'>
89
- <h1 style='color:#334155;'>🧠 Entrenchment & Conventionalization Model</h1>
90
- <h3 style='color:#475569;'>语言固着(E) × 社群常规化(C)的动态可视化平台</h3>
91
- </div>
92
- """
93
- )
94
 
95
  with gr.Row():
 
96
  with gr.Column(scale=1):
97
- with gr.Box(elem_classes="card"):
98
- expression = gr.Textbox(
99
- label="输入一个表达",
100
- placeholder="如:kind of / 内卷 / OMG / 摆烂",
101
- )
102
- btn = gr.Button("生成 E&C 分析", variant="primary")
103
-
 
 
104
  with gr.Column(scale=2):
105
- with gr.Box(elem_classes="card"):
106
- output_text = gr.Markdown("等待输入表达…")
 
 
107
 
108
  with gr.Row():
109
  with gr.Column():
110
- with gr.Box(elem_classes="card"):
111
- fig1 = gr.Plot(label="Entrenchment Curve")
 
112
 
113
  with gr.Column():
114
- with gr.Box(elem_classes="card"):
115
- fig2 = gr.Plot(label="Conventionalization Curve")
 
116
 
117
- with gr.Box(elem_classes="card"):
118
- ec_summary = gr.Markdown("")
 
119
 
120
  btn.click(analyze_ec, inputs=[expression],
121
  outputs=[output_text, fig1, fig2, ec_summary])
 
62
 
63
 
64
 
65
+ # ---- UI(Gradio 3.x 兼容,美化版,不含 gr.Box) ----
66
  with gr.Blocks(
 
 
 
 
 
 
 
67
  css="""
 
68
  .card {
69
+ background: rgba(255, 255, 255, 0.78);
70
+ padding: 15px;
71
  border-radius: 12px;
72
+ box-shadow: 0 4px 12px rgba(0,0,0,0.06);
73
  margin-bottom: 12px;
74
  }
75
+ .title-area {
76
+ text-align:center;
77
+ margin-bottom: 20px;
78
+ }
79
+ .title-area h1 {
80
+ color:#334155;
81
+ margin-bottom:5px;
82
+ }
83
+ .title-area h3 {
84
+ color:#475569;
85
+ font-weight: normal;
86
+ }
87
+ body {
88
+ background: linear-gradient(135deg, #eef2ff, #e0f2fe);
89
+ }
90
  """
91
  ) as demo:
92
 
93
+ # 页面标题
94
+ gr.HTML("""
95
+ <div class='title-area'>
96
+ <h1>🧠 Entrenchment & Conventionalization Model</h1>
97
+ <h3>语言固着(E) × 社群常规化(C)的动态可视化平台</h3>
98
+ </div>
99
+ """)
 
100
 
101
  with gr.Row():
102
+ # 输入区
103
  with gr.Column(scale=1):
104
+ gr.HTML("<div class='card'>")
105
+ expression = gr.Textbox(
106
+ label="输入一个表达",
107
+ placeholder="如:kind of / 内卷 / OMG / 摆烂",
108
+ )
109
+ btn = gr.Button("生成 E&C 分析")
110
+ gr.HTML("</div>")
111
+
112
+ # 输出区
113
  with gr.Column(scale=2):
114
+
115
+ gr.HTML("<div class='card'>")
116
+ output_text = gr.Markdown("等待输入表达…")
117
+ gr.HTML("</div>")
118
 
119
  with gr.Row():
120
  with gr.Column():
121
+ gr.HTML("<div class='card'>")
122
+ fig1 = gr.Plot()
123
+ gr.HTML("</div>")
124
 
125
  with gr.Column():
126
+ gr.HTML("<div class='card'>")
127
+ fig2 = gr.Plot()
128
+ gr.HTML("</div>")
129
 
130
+ gr.HTML("<div class='card'>")
131
+ ec_summary = gr.Markdown("")
132
+ gr.HTML("</div>")
133
 
134
  btn.click(analyze_ec, inputs=[expression],
135
  outputs=[output_text, fig1, fig2, ec_summary])