diff options
| author | alex <[email protected]> | 2026-07-27 23:55:14 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-27 23:55:14 +0200 |
| commit | 3038483c570af7b923dda39e857b9cab8f89e5dd (patch) | |
| tree | 62df1d164f8364d02d5bb811f4ac95b20a77654e /main.go | |
| download | search-engine-3038483c570af7b923dda39e857b9cab8f89e5dd.tar.xz search-engine-3038483c570af7b923dda39e857b9cab8f89e5dd.zip | |
init commit, basic tokenizing and indexing logic without any ranking of results on a simple wikipedia dump
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 47 |
1 files changed, 47 insertions, 0 deletions
@@ -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) + } + +} |
