-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
62 lines (62 loc) · 2.5 KB
/
index.html
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
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8" />
<title>LiteFS fts5 signal_tokenizer Demo</title>
<meta name="viewport" content="width=device-width, initial-scale=1, interactive-widget=resizes-content" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/picocss/1.5.10/pico.classless.min.css" />
</head>
<body>
<p>
Dataset: <a href="https://huggingface.co/datasets/fujiki/llm-japanese-dataset_wikipedia">https://huggingface.co/datasets/fujiki/llm-japanese-dataset_wikipedia</a><br/>
Source: <a href="https://dumps.wikimedia.org/">https://dumps.wikimedia.org/</a> <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a>
</p>
<input id="search" type="search">
<ul id="results"></ul>
<script>
let controller;
let prevQuery;
const resultsElem = document.getElementById("results");
const searchInput = document.getElementById("search");
searchInput.addEventListener("input", function(event) {
if (event.target.value === prevQuery) return;
const q = prevQuery = event.target.value;
if (controller) controller.abort();
if (q.length <= 0) {
resultsElem.innerHTML = "";
return;
}
controller = new AbortController();
fetch("/search?" + new URLSearchParams({q: q}).toString(), { signal: controller.signal })
.then(function(response) {
if (response.ok) {
return response.json();
} else {
throw new Error("error");
}
})
.then(function(documents) {
resultsElem.innerHTML = "";
if (documents.length === 0) {
const li = document.createElement("li");
const i = document.createElement("i")
i.textContent = 'No results';
li.appendChild(i);
resultsElem.appendChild(li);
}
documents.forEach(function(result) {
const li = document.createElement("li");
const a = document.createElement("a");
a.href = "https://ja.wikipedia.org/wiki/" + encodeURIComponent(result.title);
a.textContent = result.title;
li.appendChild(a);
const p = document.createElement("p")
p.textContent = result.content;
li.appendChild(p);
resultsElem.appendChild(li);
});
}).catch(function() {});
});
</script>
</body>
</html>