datamatters24 commited on
Commit
5d50b4b
·
verified ·
1 Parent(s): 546ae02

Upload web/src/views/dashboard.php with huggingface_hub

Browse files
Files changed (1) hide show
  1. web/src/views/dashboard.php +44 -0
web/src/views/dashboard.php CHANGED
@@ -141,6 +141,50 @@ $sectionColors = [
141
  </div>
142
  <?php endif; ?>
143
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
144
  <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
145
 
146
  <!-- Collection Similarity -->
 
141
  </div>
142
  <?php endif; ?>
143
 
144
+ <!-- Sentiment Analysis -->
145
+ <?php if (!empty($sentimentSummary)): ?>
146
+ <div class="bg-white border border-gray-200 rounded-lg shadow-sm p-4 mb-8">
147
+ <h2 class="text-sm font-semibold text-gray-700 mb-4">Sentiment Analysis by Collection</h2>
148
+ <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
149
+ <?php foreach ($sentimentSummary as $section => $sent):
150
+ $pol = $sent['avg_polarity'];
151
+ $sub = $sent['avg_subjectivity'];
152
+ // Color based on polarity
153
+ if ($pol > 0.05) { $polColor = 'text-green-700'; $polBg = 'bg-green-100'; $polLabel = 'Positive'; }
154
+ elseif ($pol < -0.05) { $polColor = 'text-red-700'; $polBg = 'bg-red-100'; $polLabel = 'Negative'; }
155
+ else { $polColor = 'text-gray-700'; $polBg = 'bg-gray-100'; $polLabel = 'Neutral'; }
156
+ ?>
157
+ <div class="border border-gray-200 rounded-lg p-3">
158
+ <h3 class="text-xs font-semibold text-gray-900 mb-2"><?= htmlspecialchars($sectionNames[$section] ?? $section) ?></h3>
159
+ <div class="space-y-2">
160
+ <div>
161
+ <div class="flex justify-between text-[10px] text-gray-500 mb-0.5">
162
+ <span>Polarity</span>
163
+ <span class="font-medium <?= $polColor ?>"><?= $polLabel ?> (<?= number_format($pol, 3) ?>)</span>
164
+ </div>
165
+ <div class="relative w-full bg-gray-200 rounded-full h-2">
166
+ <div class="absolute left-1/2 w-0.5 h-2 bg-gray-400"></div>
167
+ <div class="<?= $pol >= 0 ? 'bg-green-400' : 'bg-red-400' ?> h-2 rounded-full absolute"
168
+ style="<?= $pol >= 0 ? 'left:50%;width:'.min(50,$pol*500).'%' : 'right:50%;width:'.min(50,abs($pol)*500).'%' ?>"></div>
169
+ </div>
170
+ </div>
171
+ <div>
172
+ <div class="flex justify-between text-[10px] text-gray-500 mb-0.5">
173
+ <span>Subjectivity</span>
174
+ <span class="font-medium"><?= number_format($sub, 3) ?></span>
175
+ </div>
176
+ <div class="w-full bg-gray-200 rounded-full h-2">
177
+ <div class="bg-blue-400 h-2 rounded-full" style="width: <?= min(100, $sub * 100) ?>%"></div>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ <p class="text-[10px] text-gray-400 mt-1"><?= number_format($sent['doc_count']) ?> documents</p>
182
+ </div>
183
+ <?php endforeach; ?>
184
+ </div>
185
+ </div>
186
+ <?php endif; ?>
187
+
188
  <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
189
 
190
  <!-- Collection Similarity -->