Spaces:
Running
Running
fetch the file_name from 'file' of that row from the csv - Initial Deployment
Browse files- README.md +7 -5
- index.html +484 -18
- prompts.txt +19 -0
README.md
CHANGED
|
@@ -1,10 +1,12 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
|
|
|
|
|
|
| 8 |
---
|
| 9 |
|
| 10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
+
title: misra-annotation-tool
|
| 3 |
+
emoji: 🐳
|
| 4 |
+
colorFrom: green
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: static
|
| 7 |
pinned: false
|
| 8 |
+
tags:
|
| 9 |
+
- deepsite
|
| 10 |
---
|
| 11 |
|
| 12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
|
@@ -1,19 +1,485 @@
|
|
| 1 |
-
<!
|
| 2 |
-
<html>
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
</html>
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Code Annotation Tool</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
|
| 9 |
+
<script src="https://unpkg.com/aos@2.3.1/dist/aos.js"></script>
|
| 10 |
+
<script src="https://cdn.jsdelivr.net/npm/feather-icons/dist/feather.min.js"></script>
|
| 11 |
+
<script src="https://unpkg.com/feather-icons"></script>
|
| 12 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
|
| 13 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
|
| 14 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/github.min.css">
|
| 15 |
+
<style>
|
| 16 |
+
.code-block {
|
| 17 |
+
font-family: 'Courier New', monospace;
|
| 18 |
+
white-space: pre;
|
| 19 |
+
overflow-x: auto;
|
| 20 |
+
padding: 1rem;
|
| 21 |
+
border-radius: 0.375rem;
|
| 22 |
+
background-color: #f8f9fa;
|
| 23 |
+
border: 1px solid #e9ecef;
|
| 24 |
+
color: #212529;
|
| 25 |
+
tab-size: 4;
|
| 26 |
+
}
|
| 27 |
+
.hljs {
|
| 28 |
+
background: transparent !important;
|
| 29 |
+
}
|
| 30 |
+
.file-input-wrapper {
|
| 31 |
+
position: relative;
|
| 32 |
+
overflow: hidden;
|
| 33 |
+
display: inline-block;
|
| 34 |
+
}
|
| 35 |
+
.file-input-wrapper input[type=file] {
|
| 36 |
+
position: absolute;
|
| 37 |
+
left: 0;
|
| 38 |
+
top: 0;
|
| 39 |
+
opacity: 0;
|
| 40 |
+
}
|
| 41 |
+
.sticky-header {
|
| 42 |
+
position: sticky;
|
| 43 |
+
top: 0;
|
| 44 |
+
background-color: white;
|
| 45 |
+
z-index: 10;
|
| 46 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
| 47 |
+
}
|
| 48 |
+
.virtual-scroll {
|
| 49 |
+
height: calc(100vh - 200px);
|
| 50 |
+
overflow-y: auto;
|
| 51 |
+
}
|
| 52 |
+
.code-block {
|
| 53 |
+
font-size: 0.95rem;
|
| 54 |
+
line-height: 1.6;
|
| 55 |
+
min-height: 100px;
|
| 56 |
+
}
|
| 57 |
+
.code-block .error-marker {
|
| 58 |
+
color: #d73a49;
|
| 59 |
+
font-weight: bold;
|
| 60 |
+
margin-bottom: 0.5rem;
|
| 61 |
+
display: block;
|
| 62 |
+
}
|
| 63 |
+
.virtual-scroll {
|
| 64 |
+
height: calc(100vh - 150px);
|
| 65 |
+
}
|
| 66 |
+
</style>
|
| 67 |
+
</head>
|
| 68 |
+
<body class="bg-gray-50">
|
| 69 |
+
<div class="container mx-auto px-0">
|
| 70 |
+
<div class="text-center mb-8">
|
| 71 |
+
<h1 class="text-3xl font-bold text-gray-800 mb-2">Code Annotation Tool</h1>
|
| 72 |
+
<p class="text-gray-600">Compare and annotate C code from CSV files</p>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<!-- Upload Section -->
|
| 76 |
+
<div id="upload-section" class="bg-white rounded-lg shadow-md p-6 mb-8 mx-4">
|
| 77 |
+
<h2 class="text-xl font-semibold mb-4">1. Upload CSV File</h2>
|
| 78 |
+
<div id="drop-zone" class="border-2 border-dashed border-gray-300 rounded-lg p-8 text-center mb-4 transition-colors hover:border-blue-500 hover:bg-blue-50">
|
| 79 |
+
<div class="flex flex-col items-center justify-center">
|
| 80 |
+
<i data-feather="upload" class="w-12 h-12 text-gray-400 mb-3"></i>
|
| 81 |
+
<p class="text-gray-600 mb-2">Drag & drop your CSV file here</p>
|
| 82 |
+
<p class="text-gray-400 text-sm mb-4">or</p>
|
| 83 |
+
<div class="file-input-wrapper">
|
| 84 |
+
<label class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center cursor-pointer">
|
| 85 |
+
<i data-feather="upload" class="mr-2"></i>
|
| 86 |
+
Choose CSV File
|
| 87 |
+
<input id="csv-file" type="file" accept=".csv" class="hidden">
|
| 88 |
+
</label>
|
| 89 |
+
</div>
|
| 90 |
+
</div>
|
| 91 |
+
</div>
|
| 92 |
+
<span id="file-name" class="ml-4 text-gray-600">No file selected</span>
|
| 93 |
+
<div class="mt-4 text-sm text-gray-500">
|
| 94 |
+
<p>Note: Large files (>100MB) are supported. Processing may take a moment.</p>
|
| 95 |
+
</div>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<!-- Column Selection (Hidden Initially) -->
|
| 99 |
+
<div id="column-selection" class="bg-white rounded-lg shadow-md p-6 mb-8 mx-4 hidden">
|
| 100 |
+
<h2 class="text-xl font-semibold mb-4">2. Select Columns to Compare</h2>
|
| 101 |
+
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
|
| 102 |
+
<div>
|
| 103 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Left Column</label>
|
| 104 |
+
<select id="left-column" class="w-full border border-gray-300 rounded-md py-2 px-3 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 105 |
+
<option value="">Select a column</option>
|
| 106 |
+
</select>
|
| 107 |
+
</div>
|
| 108 |
+
<div>
|
| 109 |
+
<label class="block text-sm font-medium text-gray-700 mb-1">Right Column</label>
|
| 110 |
+
<select id="right-column" class="w-full border border-gray-300 rounded-md py-2 px-3 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 111 |
+
<option value="">Select a column</option>
|
| 112 |
+
</select>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
<button id="load-data-btn" class="bg-blue-600 hover:bg-blue-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center">
|
| 116 |
+
<i data-feather="play" class="mr-2"></i>
|
| 117 |
+
Load Data
|
| 118 |
+
</button>
|
| 119 |
+
</div>
|
| 120 |
+
|
| 121 |
+
<!-- Comparison Viewer (Hidden Initially) -->
|
| 122 |
+
<div id="comparison-viewer" class="hidden w-full">
|
| 123 |
+
<div class="flex justify-between items-center mb-4">
|
| 124 |
+
<h2 class="text-xl font-semibold">Code Comparison</h2>
|
| 125 |
+
<div class="flex items-center">
|
| 126 |
+
<div class="relative">
|
| 127 |
+
<input type="text" id="search-input" placeholder="Search..." class="border border-gray-300 rounded-md py-2 px-3 pl-10 focus:outline-none focus:ring-2 focus:ring-blue-500">
|
| 128 |
+
<i data-feather="search" class="absolute left-3 top-2.5 text-gray-400"></i>
|
| 129 |
+
</div>
|
| 130 |
+
<button id="export-btn" class="ml-4 bg-green-600 hover:bg-green-700 text-white font-medium py-2 px-4 rounded-lg transition duration-200 flex items-center">
|
| 131 |
+
<i data-feather="download" class="mr-2"></i>
|
| 132 |
+
Export Annotations
|
| 133 |
+
</button>
|
| 134 |
+
</div>
|
| 135 |
+
</div>
|
| 136 |
+
|
| 137 |
+
<div class="bg-white shadow-md overflow-hidden w-full">
|
| 138 |
+
<div class="sticky-header grid grid-cols-12 bg-gray-100 border-b border-gray-200 p-4 font-medium text-gray-700">
|
| 139 |
+
<div class="col-span-1">File Name</div>
|
| 140 |
+
<div class="col-span-5">Left Code</div>
|
| 141 |
+
<div class="col-span-4">Right Code</div>
|
| 142 |
+
<div class="col-span-2">Expert Comments</div>
|
| 143 |
+
</div>
|
| 144 |
+
<div id="comparison-content" class="virtual-scroll">
|
| 145 |
+
<!-- Content will be loaded here dynamically -->
|
| 146 |
+
</div>
|
| 147 |
+
</div>
|
| 148 |
+
</div>
|
| 149 |
+
|
| 150 |
+
<!-- Loading Indicator -->
|
| 151 |
+
<div id="loading-indicator" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden z-50">
|
| 152 |
+
<div class="bg-white rounded-lg p-6 max-w-md w-full text-center">
|
| 153 |
+
<div class="animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500 mx-auto mb-4"></div>
|
| 154 |
+
<h3 class="text-lg font-medium text-gray-900">Processing File</h3>
|
| 155 |
+
<p class="mt-2 text-gray-600" id="loading-text">Reading CSV data...</p>
|
| 156 |
+
<div class="w-full bg-gray-200 rounded-full h-2.5 mt-4">
|
| 157 |
+
<div id="progress-bar" class="bg-blue-600 h-2.5 rounded-full" style="width: 0%"></div>
|
| 158 |
+
</div>
|
| 159 |
+
</div>
|
| 160 |
+
</div>
|
| 161 |
+
</div>
|
| 162 |
+
|
| 163 |
+
<script>
|
| 164 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 165 |
+
feather.replace();
|
| 166 |
+
AOS.init();
|
| 167 |
+
|
| 168 |
+
const fileInput = document.getElementById('csv-file');
|
| 169 |
+
const fileNameDisplay = document.getElementById('file-name');
|
| 170 |
+
const columnSelection = document.getElementById('column-selection');
|
| 171 |
+
|
| 172 |
+
// Add click handler for file input label
|
| 173 |
+
document.querySelector('.file-input-wrapper label').addEventListener('click', function(e) {
|
| 174 |
+
if (e.target.tagName !== 'INPUT') {
|
| 175 |
+
fileInput.click();
|
| 176 |
+
}
|
| 177 |
+
});
|
| 178 |
+
|
| 179 |
+
// Drag and drop handlers
|
| 180 |
+
const dropZone = document.getElementById('drop-zone');
|
| 181 |
+
|
| 182 |
+
dropZone.addEventListener('dragover', (e) => {
|
| 183 |
+
e.preventDefault();
|
| 184 |
+
dropZone.classList.add('border-blue-500', 'bg-blue-50');
|
| 185 |
+
});
|
| 186 |
+
|
| 187 |
+
dropZone.addEventListener('dragleave', () => {
|
| 188 |
+
dropZone.classList.remove('border-blue-500', 'bg-blue-50');
|
| 189 |
+
});
|
| 190 |
+
|
| 191 |
+
dropZone.addEventListener('drop', (e) => {
|
| 192 |
+
e.preventDefault();
|
| 193 |
+
e.stopPropagation();
|
| 194 |
+
dropZone.classList.remove('border-blue-500', 'bg-blue-50');
|
| 195 |
+
|
| 196 |
+
if (e.dataTransfer.files.length) {
|
| 197 |
+
const file = e.dataTransfer.files[0];
|
| 198 |
+
if (file && (file.name.endsWith('.csv') || file.type === 'text/csv')) {
|
| 199 |
+
handleFile(file);
|
| 200 |
+
} else {
|
| 201 |
+
alert('Please upload a valid CSV file');
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
});
|
| 205 |
+
|
| 206 |
+
// File upload handler
|
| 207 |
+
fileInput.addEventListener('change', function(e) {
|
| 208 |
+
if (e.target.files.length) {
|
| 209 |
+
const file = e.target.files[0];
|
| 210 |
+
if (file && (file.name.endsWith('.csv') || file.type === 'text/csv')) {
|
| 211 |
+
handleFile(file);
|
| 212 |
+
} else {
|
| 213 |
+
alert('Please upload a valid CSV file');
|
| 214 |
+
}
|
| 215 |
+
}
|
| 216 |
+
});
|
| 217 |
+
|
| 218 |
+
function handleFile(file) {
|
| 219 |
+
// Update the file input
|
| 220 |
+
const dataTransfer = new DataTransfer();
|
| 221 |
+
dataTransfer.items.add(file);
|
| 222 |
+
fileInput.files = dataTransfer.files;
|
| 223 |
+
|
| 224 |
+
// Update UI
|
| 225 |
+
fileNameDisplay.textContent = file.name;
|
| 226 |
+
showLoading('Reading CSV file...');
|
| 227 |
+
|
| 228 |
+
// Process file with slight delay to ensure UI updates
|
| 229 |
+
setTimeout(() => {
|
| 230 |
+
processFile(file);
|
| 231 |
+
}, 100);
|
| 232 |
+
}
|
| 233 |
+
const leftColumnSelect = document.getElementById('left-column');
|
| 234 |
+
const rightColumnSelect = document.getElementById('right-column');
|
| 235 |
+
const loadDataBtn = document.getElementById('load-data-btn');
|
| 236 |
+
const comparisonViewer = document.getElementById('comparison-viewer');
|
| 237 |
+
const comparisonContent = document.getElementById('comparison-content');
|
| 238 |
+
const loadingIndicator = document.getElementById('loading-indicator');
|
| 239 |
+
const loadingText = document.getElementById('loading-text');
|
| 240 |
+
const progressBar = document.getElementById('progress-bar');
|
| 241 |
+
const searchInput = document.getElementById('search-input');
|
| 242 |
+
const exportBtn = document.getElementById('export-btn');
|
| 243 |
+
|
| 244 |
+
let csvData = [];
|
| 245 |
+
let headers = [];
|
| 246 |
+
let leftColumn = '';
|
| 247 |
+
let rightColumn = '';
|
| 248 |
+
let filteredData = [];
|
| 249 |
+
let chunkSize = 1000; // Number of rows to process at a time
|
| 250 |
+
let currentChunk = 0;
|
| 251 |
+
let totalChunks = 0;
|
| 252 |
+
|
| 253 |
+
// Handle file processing
|
| 254 |
+
function processFile(file) {
|
| 255 |
+
if (!file) {
|
| 256 |
+
alert('No file selected');
|
| 257 |
+
hideLoading();
|
| 258 |
+
return;
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
try {
|
| 262 |
+
// Use PapaParse to read the file
|
| 263 |
+
Papa.parse(file, {
|
| 264 |
+
worker: true,
|
| 265 |
+
header: true,
|
| 266 |
+
preview: 10,
|
| 267 |
+
skipEmptyLines: true,
|
| 268 |
+
step: function(results) {
|
| 269 |
+
// Just get headers from first row
|
| 270 |
+
if (!headers.length && results.meta.fields) {
|
| 271 |
+
headers = results.meta.fields;
|
| 272 |
+
populateColumnSelects();
|
| 273 |
+
hideLoading();
|
| 274 |
+
columnSelection.classList.remove('hidden');
|
| 275 |
+
return false; // Stop parsing after getting headers
|
| 276 |
+
}
|
| 277 |
+
},
|
| 278 |
+
error: function(error) {
|
| 279 |
+
console.error('Error reading CSV:', error);
|
| 280 |
+
hideLoading();
|
| 281 |
+
alert('Error reading CSV file: ' + error.message);
|
| 282 |
+
},
|
| 283 |
+
complete: function() {
|
| 284 |
+
hideLoading();
|
| 285 |
+
}
|
| 286 |
+
});
|
| 287 |
+
} catch (error) {
|
| 288 |
+
console.error('File processing error:', error);
|
| 289 |
+
hideLoading();
|
| 290 |
+
alert('Error processing file: ' + error.message);
|
| 291 |
+
}
|
| 292 |
+
}
|
| 293 |
+
|
| 294 |
+
// Populate column dropdowns
|
| 295 |
+
function populateColumnSelects() {
|
| 296 |
+
leftColumnSelect.innerHTML = '<option value="">Select a column</option>';
|
| 297 |
+
rightColumnSelect.innerHTML = '<option value="">Select a column</option>';
|
| 298 |
+
|
| 299 |
+
headers.forEach(header => {
|
| 300 |
+
const option1 = document.createElement('option');
|
| 301 |
+
option1.value = header;
|
| 302 |
+
option1.textContent = header;
|
| 303 |
+
leftColumnSelect.appendChild(option1);
|
| 304 |
+
|
| 305 |
+
const option2 = document.createElement('option');
|
| 306 |
+
option2.value = header;
|
| 307 |
+
option2.textContent = header;
|
| 308 |
+
rightColumnSelect.appendChild(option2);
|
| 309 |
+
});
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
// Load data button handler
|
| 313 |
+
loadDataBtn.addEventListener('click', function() {
|
| 314 |
+
leftColumn = leftColumnSelect.value;
|
| 315 |
+
rightColumn = rightColumnSelect.value;
|
| 316 |
+
|
| 317 |
+
if (!leftColumn || !rightColumn) {
|
| 318 |
+
alert('Please select both columns to compare');
|
| 319 |
+
return;
|
| 320 |
+
}
|
| 321 |
+
|
| 322 |
+
if (!fileInput.files || !fileInput.files[0]) {
|
| 323 |
+
alert('No file selected');
|
| 324 |
+
return;
|
| 325 |
+
}
|
| 326 |
+
|
| 327 |
+
showLoading('Loading CSV data...');
|
| 328 |
+
csvData = [];
|
| 329 |
+
filteredData = [];
|
| 330 |
+
currentChunk = 0;
|
| 331 |
+
|
| 332 |
+
// Read the entire file at once (PapaParse handles large files well)
|
| 333 |
+
const file = fileInput.files[0];
|
| 334 |
+
|
| 335 |
+
Papa.parse(file, {
|
| 336 |
+
worker: true,
|
| 337 |
+
header: true,
|
| 338 |
+
skipEmptyLines: true,
|
| 339 |
+
step: function(results) {
|
| 340 |
+
csvData.push(results.data);
|
| 341 |
+
progressBar.style.width = `${(results.meta.cursor / file.size) * 100}%`;
|
| 342 |
+
loadingText.textContent = `Processing file (${Math.round(results.meta.cursor / 1024)}KB)`;
|
| 343 |
+
},
|
| 344 |
+
complete: function() {
|
| 345 |
+
filteredData = [...csvData];
|
| 346 |
+
renderComparisonTable();
|
| 347 |
+
hideLoading();
|
| 348 |
+
columnSelection.classList.add('hidden');
|
| 349 |
+
comparisonViewer.classList.remove('hidden');
|
| 350 |
+
},
|
| 351 |
+
error: function(error) {
|
| 352 |
+
console.error('Error parsing file:', error);
|
| 353 |
+
hideLoading();
|
| 354 |
+
alert('Error processing file: ' + error.message);
|
| 355 |
+
}
|
| 356 |
+
});
|
| 357 |
+
});
|
| 358 |
+
|
| 359 |
+
// Render the comparison table with virtual scrolling
|
| 360 |
+
function renderComparisonTable() {
|
| 361 |
+
comparisonContent.innerHTML = '';
|
| 362 |
+
|
| 363 |
+
// Only render a subset of rows for performance
|
| 364 |
+
const rowsToRender = Math.min(100, filteredData.length);
|
| 365 |
+
|
| 366 |
+
for (let i = 0; i < rowsToRender; i++) {
|
| 367 |
+
const row = filteredData[i];
|
| 368 |
+
const rowElement = document.createElement('div');
|
| 369 |
+
rowElement.className = 'grid grid-cols-12 border-b border-gray-200 hover:bg-gray-50';
|
| 370 |
+
rowElement.innerHTML = `
|
| 371 |
+
<div class="col-span-1 p-4 border-r border-gray-200 overflow-auto">
|
| 372 |
+
<div class="text-sm font-medium text-gray-700">${row.file || row.file_name || ''}</div>
|
| 373 |
+
</div>
|
| 374 |
+
<div class="col-span-5 p-4 border-r border-gray-200 overflow-auto">
|
| 375 |
+
<div class="code-block">${formatCode(row[leftColumn], leftColumn, row)}</div>
|
| 376 |
+
</div>
|
| 377 |
+
<div class="col-span-4 p-4 border-r border-gray-200 overflow-auto">
|
| 378 |
+
<div class="code-block">${formatCode(row[rightColumn], rightColumn, row)}</div>
|
| 379 |
+
</div>
|
| 380 |
+
<div class="col-span-2 p-4">
|
| 381 |
+
<textarea class="w-full h-full p-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500"
|
| 382 |
+
placeholder="Enter comments...">${row.expert_comments || ''}</textarea>
|
| 383 |
+
</div>
|
| 384 |
+
`;
|
| 385 |
+
comparisonContent.appendChild(rowElement);
|
| 386 |
+
}
|
| 387 |
+
|
| 388 |
+
// Highlight the code blocks
|
| 389 |
+
document.querySelectorAll('.code-block').forEach(block => {
|
| 390 |
+
hljs.highlightElement(block);
|
| 391 |
+
});
|
| 392 |
+
|
| 393 |
+
// Set up scroll event for virtual scrolling
|
| 394 |
+
comparisonContent.addEventListener('scroll', handleScroll);
|
| 395 |
+
}
|
| 396 |
+
|
| 397 |
+
// Format code with proper indentation and add special markers for specific columns
|
| 398 |
+
function formatCode(code, columnName, row) {
|
| 399 |
+
if (!code) return '';
|
| 400 |
+
|
| 401 |
+
// Replace tabs with spaces for consistent display
|
| 402 |
+
let formattedCode = code.replace(/\t/g, ' ');
|
| 403 |
+
|
| 404 |
+
// Add filename at the top if available
|
| 405 |
+
const filename = row.file || row.file_name;
|
| 406 |
+
if (filename) {
|
| 407 |
+
formattedCode = `// File: ${filename}\n\n${formattedCode}`;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
// Add special markers for specific columns
|
| 411 |
+
if (columnName === 'filtered_source_code' && row.errors_before) {
|
| 412 |
+
formattedCode = `######\n${row.errors_before}\n######\n\n${formattedCode}`;
|
| 413 |
+
} else if (columnName === 'merged_code' && row.final_errors_after_pclint_corrected_code) {
|
| 414 |
+
formattedCode = `######\n${row.final_errors_after_pclint_corrected_code}\n######\n\n${formattedCode}`;
|
| 415 |
+
}
|
| 416 |
+
|
| 417 |
+
return formattedCode;
|
| 418 |
+
}
|
| 419 |
+
|
| 420 |
+
// Handle scroll for virtual scrolling
|
| 421 |
+
function handleScroll() {
|
| 422 |
+
// Implement virtual scrolling here if needed
|
| 423 |
+
// For now, we're just rendering the first 100 rows
|
| 424 |
+
}
|
| 425 |
+
|
| 426 |
+
// Search functionality
|
| 427 |
+
searchInput.addEventListener('input', function() {
|
| 428 |
+
const searchTerm = this.value.toLowerCase();
|
| 429 |
+
if (searchTerm.length < 2) {
|
| 430 |
+
filteredData = [...csvData];
|
| 431 |
+
} else {
|
| 432 |
+
filteredData = csvData.filter(row => {
|
| 433 |
+
return (row[leftColumn] && row[leftColumn].toLowerCase().includes(searchTerm)) ||
|
| 434 |
+
(row[rightColumn] && row[rightColumn].toLowerCase().includes(searchTerm)) ||
|
| 435 |
+
(row.expert_comments && row.expert_comments.toLowerCase().includes(searchTerm));
|
| 436 |
+
});
|
| 437 |
+
}
|
| 438 |
+
renderComparisonTable();
|
| 439 |
+
});
|
| 440 |
+
|
| 441 |
+
// Export annotations
|
| 442 |
+
exportBtn.addEventListener('click', function() {
|
| 443 |
+
showLoading('Preparing export...');
|
| 444 |
+
|
| 445 |
+
// Collect all comments
|
| 446 |
+
const textareas = comparisonContent.querySelectorAll('textarea');
|
| 447 |
+
textareas.forEach((textarea, index) => {
|
| 448 |
+
if (index < csvData.length) {
|
| 449 |
+
csvData[index].expert_comments = textarea.value;
|
| 450 |
+
}
|
| 451 |
+
});
|
| 452 |
+
|
| 453 |
+
// Convert to CSV
|
| 454 |
+
const csv = Papa.unparse(csvData);
|
| 455 |
+
const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
|
| 456 |
+
const url = URL.createObjectURL(blob);
|
| 457 |
+
|
| 458 |
+
// Create download link
|
| 459 |
+
const a = document.createElement('a');
|
| 460 |
+
a.href = url;
|
| 461 |
+
a.download = 'annotated_code_comparison.csv';
|
| 462 |
+
document.body.appendChild(a);
|
| 463 |
+
a.click();
|
| 464 |
+
document.body.removeChild(a);
|
| 465 |
+
URL.revokeObjectURL(url);
|
| 466 |
+
|
| 467 |
+
hideLoading();
|
| 468 |
+
});
|
| 469 |
+
|
| 470 |
+
// Show loading indicator
|
| 471 |
+
function showLoading(text) {
|
| 472 |
+
loadingText.textContent = text;
|
| 473 |
+
loadingIndicator.classList.remove('hidden');
|
| 474 |
+
document.body.style.overflow = 'hidden';
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
// Hide loading indicator
|
| 478 |
+
function hideLoading() {
|
| 479 |
+
loadingIndicator.classList.add('hidden');
|
| 480 |
+
document.body.style.overflow = '';
|
| 481 |
+
}
|
| 482 |
+
});
|
| 483 |
+
</script>
|
| 484 |
+
</body>
|
| 485 |
</html>
|
prompts.txt
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
create a code annotation tool. user uploads a csv and then tool asks which columns to compare left to right. the columns will have C code so embed code with porper indentation, colors and style of C as in VS Code. on the right most add a column "expert_comments" as text input box where user can add text comments about those two columns of the row.
|
| 2 |
+
|
| 3 |
+
the uploaded csv can be >100MB so develop accordingly.
|
| 4 |
+
choose csv file button not working
|
| 5 |
+
allow dragging and dropping files too
|
| 6 |
+
allow dragging and dropping files to upload csv
|
| 7 |
+
drag and drop not working
|
| 8 |
+
fix file upload not uploading now, show processing loader when uploading the file
|
| 9 |
+
STILL NOT WORKING UPLOAD!!!!! FIXXXX
|
| 10 |
+
FIX IT STILL NOT WORKING
|
| 11 |
+
|
| 12 |
+
dont keep any color of the code as grey - remember to keep colors according to legibility on a white background.
|
| 13 |
+
make the columns except expert comments wider for better code readability - fit to full page - expert column
|
| 14 |
+
stretch the cells even more widely - cover full page
|
| 15 |
+
if selected "filtered_source_code" then show content "errors_before" at the start of each of its cells and if selected "merged_code" show "final_errors_after_pclint_corrected_code" at the start of its content --
|
| 16 |
+
seprate out these with special markers ###### before and after them
|
| 17 |
+
append to content of cells of these rows - for filtered_source_code add content of "errors_before" column below its content in nested in "###" comments
|
| 18 |
+
add another column "file_name" to the left most for each row
|
| 19 |
+
fetch the file_name from 'file' of that row from the csv
|