File size: 3,855 Bytes
901117e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Sentiment Analysis - TinyBERT</title>
    <script src="https://cdn.tailwindcss.com"></script>
  </head>
  <body class="bg-gradient-to-br from-slate-50 to-slate-100 min-h-screen">
    <div class="container mx-auto px-4 py-12 max-w-3xl">
      <!-- Header -->
      <div class="text-center mb-12">
        <h1 class="text-4xl font-bold text-slate-800 mb-3">
          Sentiment Analysis
        </h1>
        <p class="text-slate-600">
          Powered by Fine-tuned TinyBERT
        </p>
      </div>

      <!-- Main Card -->
      <div class="bg-white rounded-2xl shadow-xl p-8 mb-6">
        <form method="post" action="/predict" class="space-y-6">
          <!-- Text Input -->
          <div>
            <label for="text" class="block text-sm font-medium text-slate-700 mb-2">
              Enter text to analyze
            </label>
            <textarea

              id="text"

              name="text"

              rows="5"

              class="w-full px-4 py-3 border border-slate-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent transition resize-none"

              placeholder="Type or paste your text here..."

              required

            >{% if text %}{{ text }}{% endif %}</textarea>
          </div>

          <!-- Submit Button -->
          <button

            type="submit"

            class="w-full bg-blue-600 hover:bg-blue-700 text-white font-medium py-3 px-6 rounded-lg transition duration-200 shadow-md hover:shadow-lg"

          >
            Analyze Sentiment
          </button>
        </form>

        <!-- Error Message -->
        {% if error %}
        <div class="mt-6 bg-red-50 border-l-4 border-red-500 p-4 rounded">
          <p class="text-red-700">{{ error }}</p>
        </div>
        {% endif %}

        <!-- Results -->
        {% if sentiment %}
        <div class="mt-8 border-t pt-6">
          <h2 class="text-xl font-semibold text-slate-800 mb-4">Results</h2>
          
          <div class="grid grid-cols-2 gap-4">
            <!-- Sentiment -->
            <div class="bg-slate-50 rounded-lg p-4">
              <p class="text-sm text-slate-600 mb-1">Sentiment</p>
              <div class="flex items-center">
                <span class="text-2xl mr-2">
                  {% if sentiment == "Positive" %}
                    ๐Ÿ˜Š
                  {% else %}
                    ๐Ÿ˜”
                  {% endif %}
                </span>
                <p class="text-2xl font-bold {% if sentiment == 'Positive' %}text-green-600{% else %}text-red-600{% endif %}">
                  {{ sentiment }}
                </p>
              </div>
            </div>

            <!-- Confidence -->
            <div class="bg-slate-50 rounded-lg p-4">
              <p class="text-sm text-slate-600 mb-1">Confidence</p>
              <p class="text-2xl font-bold text-blue-600">
                {{ confidence }}%
              </p>
            </div>
          </div>

          <!-- Confidence Bar -->
          <div class="mt-4">
            <div class="w-full bg-slate-200 rounded-full h-3 overflow-hidden">
              <div

                class="h-full {% if sentiment == 'Positive' %}bg-green-500{% else %}bg-red-500{% endif %} transition-all duration-500"

                style="width: {{ confidence }}%"

              ></div>
            </div>
          </div>
        </div>
        {% endif %}
      </div>

      <!-- Footer -->
      <div class="text-center text-slate-500 text-sm">
        <p>Fine-tuned TinyBERT model for sentiment classification</p>
      </div>
    </div>
  </body>
</html>