File size: 1,818 Bytes
fae2f17
 
4e79507
fae2f17
33c8dfc
fae2f17
 
4e79507
fae2f17
33c8dfc
 
 
 
fae2f17
33c8dfc
4e79507
 
 
fae2f17
 
4e79507
fae2f17
4e79507
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
fae2f17
4e79507
 
 
fae2f17
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import gradio as gr
from huggingface_hub import InferenceClient
import pandas as pd

df = pd.read_csv("Diemthi2024_processed.csv")

def respond(
    sbd, khoi
):
    score = df[df['sbd'] == int(sbd)]
    count_all = (df[khoi] >= score[khoi].iloc[0]).sum()
    count_kv = ((df[khoi] >= score[khoi].iloc[0]) & (df['kv'] == score['kv'].iloc[0])).sum()
    count_tinh = ((df[khoi] >= score[khoi].iloc[0]) & (df['tinh'] == score['tinh'].iloc[0])).sum()

    return f"""Your score is {score[khoi].iloc[0]}
    National Ranking: {count_all}
    Regional Ranking: {count_kv}
    Provincal Ranking: {count_tinh}"""

"""
Chatbot
"""
with gr.Blocks() as demo:
    gr.Markdown(
        """
        <style>
        .gr-button-secondary {
            width: 100px;
            height: 30px;
            padding: 5px;
        }
        .gr-row {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        .gr-block {
            padding: 20px;
        }
        .gr-markdown p {
            font-size: 16px;
        }
        </style>
        <span style='font-family: Arial, sans-serif; font-size: 20px;'>National Graduation Exam Score Ranking</span>
        <p style='font-family: Arial, sans-serif;'>Input your ID and your combination:</p>
        """
    )
    with gr.Row():
        id = gr.Textbox(placeholder="Input your ID", label="", lines=1)
        comb = gr.Dropdown(
                ["A00", "A01", "B00", "C00", "C03", "D01", "D07"], label="Combination", info="Will add more combinations later!"
            )
    
    with gr.Row():
        check_button = gr.Button("Rank now!", variant="primary")

    out = gr.Textbox(label="OUTPUT", placeholder="", lines=2)
    
    check_button.click(fn=respond, inputs=[id,comb], outputs=out)

if __name__ == "__main__":
    demo.launch()