blob: 459da393a161dd5dba20f5af88c7e4cc17b47665 (
plain)
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
|
package main
import (
"fmt"
"searchEngine/analyzer"
"searchEngine/index"
"searchEngine/ingest"
"searchEngine/search"
"sync"
)
func main() {
myIndex := index.New()
jobQueue := make(chan ingest.Page, 100)
var wg sync.WaitGroup
for range 4 {
wg.Go(func() {
for page := range jobQueue {
tokens := analyzer.ProcessText(page.Text)
myIndex.Add(page.Id, page.Title, tokens)
}
})
}
err := ingest.IngestWikiDump("C:/Users/bambi15/Documents/wikipedia/simplewiki-2026-07-01-p1p1273731/simplewiki-2026-07-01-p1p1273731.xml", jobQueue)
if err != nil {
panic(err)
}
close(jobQueue)
wg.Wait()
fmt.Println("Indexing complete! Running a test search...")
results := search.Search(myIndex, "computer science")
fmt.Printf("Found %d articles matching your query:\n", len(results))
for i, title := range results {
if i >= 10 {
fmt.Println("... and more.")
break
}
fmt.Printf("- %s\n", title)
}
}
|