-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
107 lines (86 loc) · 4.2 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<html>
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type"/>
</head>
<body>
<script type="module">
// import { initialize, SegmentBuilder, SearchIndex } from './dist/es/index.js';
import { runBenchmark } from './example/benchmark.js';
async function run() {
await runBenchmark();
// await initialize();
// const segmentBuilder = new SegmentBuilder({
// title: { text: true, stored: true },
// body: { text: true }
// });
// console.log(segmentBuilder)
// // for (let i = 0; i < 1000; i++) {
// // segmentBuilder.addDocument({
// // title: "Lord Of The Rings",
// // body: "And some things that should not have been forgotten were lost. History became legend. Legend became myth. And for two and a half thousand years, the ring passed out of all knowledge.",
// // });
// // }
// let segment = segmentBuilder.finalize();
// console.log(segment.export().length);
// segmentBuilder.addDocument({
// title: "The Old Man and the Sea",
// body: `He was an old man who fished alone in a skiff in the Gulf Stream and
// he had gone eighty-four days now without taking a fish.`,
// });
// segmentBuilder.addDocument({
// title: "Of Mice and Men",
// body: `A few miles south of Soledad, the Salinas River drops in close to the hillside
// bank and runs deep and green. The water is warm too, for it has slipped twinkling
// over the yellow sands in the sunlight before reaching the narrow pool. On one
// side of the river the golden foothill slopes curve up to the strong and rocky
// Gabilan Mountains, but on the valley side the water is lined with trees—willows
// fresh and green with every spring, carrying in their lower leaf junctures the
// debris of the winter’s flooding; and sycamores with mottled, white, recumbent
// limbs and branches that arch over the pool`,
// });
// segmentBuilder.addDocument({
// title: "Frankenstein",
// // title: "The Modern Prometheus", TODO: on ne supporte plus ce cas là
// body: `You will rejoice to hear that no disaster has accompanied the commencement of an
// enterprise which you have regarded with such evil forebodings. I arrived here
// yesterday, and my first task is to assure my dear sister of my welfare and
// increasing confidence in the success of my undertaking.`,
// });
// segmentBuilder.addDocument({
// title: "Le seigneur des anneaux",
// body: "C'est une étrange fatalité que nous devions éprouver tant de peurs et de doutes, pour une si petite chose.",
// });
// const segmentBuilder2 = new SegmentBuilder(schema, 50_000_000);
// segmentBuilder2.addDocument({
// title: "Lord of the Rings",
// body: `Home is behind, the world ahead,
// and there are many paths to tread
// through shadows to the edge of night,
// until the stars are all alight`,
// });
// let segment2 = segmentBuilder2.finalize();
// let merger = new Merger();
// merger.addSegment(segment);
// merger.addSegment(segment2);
// let mergedSegment = merger.merge();
// const searchIndex = new SearchIndex();
// searchIndex.registerSegment(segment);
// searchIndex.directorySummary();
// let results = searchIndex.search('the', {fields: ['title'], limit: 10});
// console.log(results)
// const searchIndex = new SearchIndex();
// console.error("EMPTY")
// searchIndex.directorySummary();
// searchIndex.registerSegment(segment);
// console.error("FIRST")
// searchIndex.directorySummary();
// searchIndex.registerSegment(segment2);
// console.error("SECOND")
// searchIndex.directorySummary();
// let results = searchIndex.search('the', {fields: ['title'], limit: 10});
// console.log(results)
}
run();
</script>
</body>
</html>