diff options
| author | alex <[email protected]> | 2026-07-28 17:37:06 +0200 |
|---|---|---|
| committer | alex <[email protected]> | 2026-07-28 17:37:06 +0200 |
| commit | c91c3afd8700138f8eb8a25a4ae422c2c9e46cea (patch) | |
| tree | fd9b5ea4f3b821581b2ceb4e7fa8afc1a84c0eeb /main.go | |
| parent | 5858d34b8ab573e18a4f6ddc5ee962b24ea269dc (diff) | |
| download | search-engine-c91c3afd8700138f8eb8a25a4ae422c2c9e46cea.tar.xz search-engine-c91c3afd8700138f8eb8a25a4ae422c2c9e46cea.zip | |
refactored entire code base to be in the package core so i can later implement interfaces to interact with the engine
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 31 |
1 files changed, 7 insertions, 24 deletions
@@ -1,39 +1,23 @@ -package main +package main import ( "fmt" - "searchEngine/analyzer" - "searchEngine/index" - "searchEngine/ingest" - "searchEngine/search" - "sync" + "searchEngine/core" ) func main() { - myIndex := index.New() - jobQueue := make(chan ingest.Page, 100) + engine := core.NewEngine() - 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) + dumpPath := "C:/Users/bambi15/Documents/wikipedia/simplewiki-2026-07-01-p1p1273731/simplewiki-2026-07-01-p1p1273731.xml" + fmt.Println("Ingesting and indexing wiki dump...") + err := engine.IndexDump(dumpPath, 4) if err != nil { panic(err) } - close(jobQueue) - wg.Wait() fmt.Println("Indexing complete! Running a test search...") - results := search.Search(myIndex, "league of legends") + results := engine.Search("league of legends") fmt.Printf("Found %d articles matching your query:\n", len(results)) for i, title := range results { @@ -43,5 +27,4 @@ func main() { } fmt.Printf("- %s\n", title) } - } |
