Spaces:
Running
Running
Update pages/transformers/mask_word.html
Browse files
pages/transformers/mask_word.html
CHANGED
@@ -1,44 +1,44 @@
|
|
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>Mask Word Transformer</title>
|
7 |
-
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
8 |
-
</head>
|
9 |
-
<body class="container mt-5">
|
10 |
-
<h2 class="mb-4">Mask Word Transformer</h2>
|
11 |
-
<form id="maskForm">
|
12 |
-
<div class="form-group">
|
13 |
-
<label for="inputText">Enter Text:</label>
|
14 |
-
<input type="text" id="inputText" class="form-control" placeholder="Type your text here" required>
|
15 |
-
</div>
|
16 |
-
<button type="submit" class="btn btn-primary">Mask Words</button>
|
17 |
-
</form>
|
18 |
-
<h4 class="mt-4">Transformed Text:</h4>
|
19 |
-
<p id="outputText" class="border p-3"></p>
|
20 |
-
|
21 |
-
<script>
|
22 |
-
document.getElementById('maskForm').addEventListener('submit', async function(event) {
|
23 |
-
event.preventDefault();
|
24 |
-
const inputText = document.getElementById('inputText').value;
|
25 |
-
|
26 |
-
const response = await fetch('https://api-inference.huggingface.co/models/google-bert/bert-base-uncased', {
|
27 |
-
method: 'POST',
|
28 |
-
headers: {
|
29 |
-
'Content-Type': 'application/json',
|
30 |
-
'Authorization': 'Bearer {
|
31 |
-
},
|
32 |
-
body: JSON.stringify({ inputs: inputText })
|
33 |
-
});
|
34 |
-
|
35 |
-
const data = await response.json();
|
36 |
-
if (Array.isArray(data) && data.length > 0) {
|
37 |
-
document.getElementById('outputText').innerText = data[0].sequence;
|
38 |
-
} else {
|
39 |
-
document.getElementById('outputText').innerText = 'No result found';
|
40 |
-
}
|
41 |
-
});
|
42 |
-
</script>
|
43 |
-
</body>
|
44 |
-
</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>Mask Word Transformer</title>
|
7 |
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
8 |
+
</head>
|
9 |
+
<body class="container mt-5">
|
10 |
+
<h2 class="mb-4">Mask Word Transformer</h2>
|
11 |
+
<form id="maskForm">
|
12 |
+
<div class="form-group">
|
13 |
+
<label for="inputText">Enter Text:</label>
|
14 |
+
<input type="text" id="inputText" class="form-control" placeholder="Type your text here" required>
|
15 |
+
</div>
|
16 |
+
<button type="submit" class="btn btn-primary">Mask Words</button>
|
17 |
+
</form>
|
18 |
+
<h4 class="mt-4">Transformed Text:</h4>
|
19 |
+
<p id="outputText" class="border p-3"></p>
|
20 |
+
|
21 |
+
<script>
|
22 |
+
document.getElementById('maskForm').addEventListener('submit', async function(event) {
|
23 |
+
event.preventDefault();
|
24 |
+
const inputText = document.getElementById('inputText').value;
|
25 |
+
onst HF_Token = atob("aGZfdExPdlJTc2dpR1d2dndaalZ1aWx4S3FXWFJmdVRDYUVNUGY=")
|
26 |
+
const response = await fetch('https://api-inference.huggingface.co/models/google-bert/bert-base-uncased', {
|
27 |
+
method: 'POST',
|
28 |
+
headers: {
|
29 |
+
'Content-Type': 'application/json',
|
30 |
+
'Authorization': 'Bearer ${HF_Token}'
|
31 |
+
},
|
32 |
+
body: JSON.stringify({ inputs: inputText })
|
33 |
+
});
|
34 |
+
|
35 |
+
const data = await response.json();
|
36 |
+
if (Array.isArray(data) && data.length > 0) {
|
37 |
+
document.getElementById('outputText').innerText = data[0].sequence;
|
38 |
+
} else {
|
39 |
+
document.getElementById('outputText').innerText = 'No result found';
|
40 |
+
}
|
41 |
+
});
|
42 |
+
</script>
|
43 |
+
</body>
|
44 |
+
</html>
|