summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'main.go')
-rw-r--r--main.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/main.go b/main.go
new file mode 100644
index 0000000..459da39
--- /dev/null
+++ b/main.go
@@ -0,0 +1,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)
+ }
+
+}