-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglobal.go
More file actions
63 lines (54 loc) · 1.24 KB
/
global.go
File metadata and controls
63 lines (54 loc) · 1.24 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"database/sql"
"fmt"
"sync"
"time"
)
const vectorSize int = 300 // The dementions of the vector
const windowSize int = 8 // How many words to consider left and right
const trainingdata string = "./trainingdata"
const language string = "English" // Langaue written in english with capital first letter
const downloadNewBooks bool = true
const epochs int = 10
const trainingRate float64 = 0.01
const loops int = 750
var runTimer bool = true
var doneDB bool = false
var doneMain bool = false
var DBCon *sql.DB
type Word2Vec struct {
Vocab []string
Vectors map[string][]float64
UpdatedVectors map[string][]float64
M sync.Mutex
WordFrequency map[string]int
}
var w2v = Word2Vec{
Vocab: []string{},
Vectors: make(map[string][]float64),
UpdatedVectors: make(map[string][]float64),
M: sync.Mutex{},
WordFrequency: make(map[string]int),
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func displayTimer() {
startTime := time.Now()
for runTimer {
fmt.Printf("\rTime Elapsed: %v ", time.Since(startTime))
time.Sleep(1 * time.Second)
}
fmt.Print("\n")
runTimer = true
}