-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
35 lines (33 loc) · 1.45 KB
/
main.go
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
package main
import (
"path/filepath"
"fmt"
"time"
"bufio"
"os"
"strings"
)
func main() {
fmt.Println("█░█ █▀▀█ █▀▀█ █▀▀▀ █░░ █▀▀ █▀▀ █▀▀ █▀▀█ █▀▀█ █▀▀ █░░█ █▀▀ █▀▀▄ █▀▀▀ ░▀░ █▀▀▄ █▀▀")
fmt.Println("█▀▄ █░░█ █░░█ █░▀█ █░░ █▀▀ ▀▀█ █▀▀ █▄▄█ █▄▄▀ █░░ █▀▀█ █▀▀ █░░█ █░▀█ ▀█▀ █░░█ █▀▀")
fmt.Println("▀░▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀▀▀ ▀░░▀ ▀░▀▀ ▀▀▀ ▀░░▀ ▀▀▀ ▀░░▀ ▀▀▀▀ ▀▀▀ ▀░░▀ ▀▀▀")
fmt.Println("Hello! Koogle is going to index files from the resource folder in a second!")
time.Sleep(1000 * time.Millisecond)
createInvertedIndex(filepath.Abs("resources"))
fmt.Println("Files were indexed successfully! Indexes are stored in 'index' folder.")
time.Sleep(1000 * time.Millisecond)
fmt.Println("Now you can type your query or exit (type 'Koogle exit').")
scanner := bufio.NewScanner(os.Stdin)
for {
fmt.Print("Type your query: ")
scanner.Scan()
userQuery := scanner.Text()
if userQuery == "Koogle exit" {
os.Exit(0)
}
userQuery = strings.TrimSpace(userQuery)
userQuery = strings.ToLower(userQuery)
queryResults := search(userQuery)
fmt.Println(queryResults)
}
}