Spaces:
Runtime error
Runtime error
Upload index.html
Browse files- templates/index.html +103 -0
templates/index.html
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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>NLP Legal Document Processor</title>
|
| 7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
|
| 8 |
+
<style>
|
| 9 |
+
body {
|
| 10 |
+
background: linear-gradient(to bottom, royalblue, black);
|
| 11 |
+
color: white;
|
| 12 |
+
font-family: Arial, sans-serif;
|
| 13 |
+
margin-top: 140px;
|
| 14 |
+
margin-bottom: 310px;
|
| 15 |
+
}
|
| 16 |
+
h1 {
|
| 17 |
+
margin-bottom: 20px;
|
| 18 |
+
}
|
| 19 |
+
.btn-primary, .btn-success {
|
| 20 |
+
width: 100%;
|
| 21 |
+
}
|
| 22 |
+
#loading {
|
| 23 |
+
font-weight: bold;
|
| 24 |
+
}
|
| 25 |
+
</style>
|
| 26 |
+
</head>
|
| 27 |
+
<body>
|
| 28 |
+
<div class="container mt-5">
|
| 29 |
+
<h1 class="text-center">NLP Machine Translation for Legal Docs</h1>
|
| 30 |
+
<form method="POST" action="/" id="nlp-form">
|
| 31 |
+
<div class="mb-3">
|
| 32 |
+
<label for="inputText" class="form-label">Enter Legal Text</label>
|
| 33 |
+
<textarea class="form-control" id="inputText" name="input_text" rows="6" required></textarea>
|
| 34 |
+
</div>
|
| 35 |
+
<div class="mb-3">
|
| 36 |
+
<label for="method" class="form-label">Choose Summarization Method</label>
|
| 37 |
+
<select class="form-select" id="method" name="method">
|
| 38 |
+
<option value="method1">Method 1</option>
|
| 39 |
+
<option value="method2">Method 2</option>
|
| 40 |
+
</select>
|
| 41 |
+
</div>
|
| 42 |
+
<div id="loading" class="text-center text-warning" style="display: none;">Processing... Please wait.. It may take few minutes</div>
|
| 43 |
+
<button type="button" class="btn btn-primary" id="processButton" onclick="processText()">Summarize</button>
|
| 44 |
+
</form>
|
| 45 |
+
|
| 46 |
+
<div id="result" class="mt-5"></div>
|
| 47 |
+
<button type="button" class="btn btn-success mt-3" id="translateButton" style="display: none;" onclick="translateText()">Translate to Hindi</button>
|
| 48 |
+
|
| 49 |
+
</div>
|
| 50 |
+
|
| 51 |
+
<script>
|
| 52 |
+
async function processText() {
|
| 53 |
+
document.getElementById('loading').style.display = 'block';
|
| 54 |
+
document.getElementById('result').innerHTML = '';
|
| 55 |
+
document.getElementById('translateButton').style.display = 'none';
|
| 56 |
+
|
| 57 |
+
const formData = new FormData(document.getElementById('nlp-form'));
|
| 58 |
+
try {
|
| 59 |
+
const response = await fetch('/', { method: 'POST', body: formData });
|
| 60 |
+
const result = await response.json();
|
| 61 |
+
|
| 62 |
+
if (result.error) throw new Error(result.error);
|
| 63 |
+
|
| 64 |
+
document.getElementById('result').innerHTML = `
|
| 65 |
+
<h3>Summarized Text:</h3>
|
| 66 |
+
<p>${result.summarized_text}</p>
|
| 67 |
+
`;
|
| 68 |
+
document.getElementById('translateButton').style.display = 'block';
|
| 69 |
+
} catch (error) {
|
| 70 |
+
document.getElementById('result').innerHTML = `<p class="text-danger">Error: ${error.message}</p>`;
|
| 71 |
+
} finally {
|
| 72 |
+
document.getElementById('loading').style.display = 'none';
|
| 73 |
+
}
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
async function translateText() {
|
| 77 |
+
document.getElementById('loading').style.display = 'block';
|
| 78 |
+
const summarizedText = document.querySelector('#result p').textContent;
|
| 79 |
+
|
| 80 |
+
try {
|
| 81 |
+
const response = await fetch('/translate', {
|
| 82 |
+
method: 'POST',
|
| 83 |
+
headers: { 'Content-Type': 'application/json' },
|
| 84 |
+
body: JSON.stringify({ text: summarizedText })
|
| 85 |
+
});
|
| 86 |
+
const result = await response.json();
|
| 87 |
+
|
| 88 |
+
if (result.error) throw new Error(result.error);
|
| 89 |
+
|
| 90 |
+
document.getElementById('result').innerHTML += `
|
| 91 |
+
<h3>Translated Text (Hindi):</h3>
|
| 92 |
+
<p>${result.translated_text}</p>
|
| 93 |
+
`;
|
| 94 |
+
document.getElementById('translateButton').style.display = 'none';
|
| 95 |
+
} catch (error) {
|
| 96 |
+
document.getElementById('result').innerHTML += `<p class="text-danger">Error: ${error.message}</p>`;
|
| 97 |
+
} finally {
|
| 98 |
+
document.getElementById('loading').style.display = 'none';
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
</script>
|
| 102 |
+
</body>
|
| 103 |
+
</html>
|