-
Notifications
You must be signed in to change notification settings - Fork 0
/
venues.go
78 lines (67 loc) · 1.66 KB
/
venues.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package entities
import (
"errors"
"fmt"
)
var _ = fmt.Println // remove after test
func makeVenueTypeSet() map[string]struct{} {
a := map[string]struct{}{}
a["Journal"] = struct{}{}
a["Magazine"] = struct{}{}
a["Newsletter"] = struct{}{}
return a
}
var VenueTypeSet = makeVenueTypeSet()
type Venue struct {
Key *Key
VenueType string
Name string
Publisher *Organization
}
func NewVenue(t string, n string) (*Venue,error) {
p := new(Venue)
p.Key = makeKey("Venue")
_,ok := VenueTypeSet[t]
if !ok {
err := errors.New("Unknown venue type: " + t)
return nil, err
}
p.VenueType = t
p.Name = n
return p, nil
}
func NewJournal(n string) (*Venue, error) {return NewVenue("Journal", n)}
func NewMagazine(n string) (*Venue, error) {return NewVenue("Magazine", n)}
func NewNewsletter(n string) (*Venue, error) {return NewVenue("Newsletter", n)}
func (a *Venue) Triples () [][3]string {
var t [][3]string
t = append(t, makeTriple(Triple{(*a).Key,"hasType","Venue",nil}))
t = append(t, makeTriple(Triple{(*a).Key,"hasVenueType",(*a).VenueType,nil}))
t = append(t, makeTriple(Triple{(*a).Key,"hasName",(*a).Name,nil}))
if (*a).Publisher != nil {t = append(t, makeTriple(Triple{(*a).Key,"hasPublisher","",(*a.Publisher).Key}))}
return t
}
func FindVenueKey (kf *Key) int {
for i,a := range Venues {
if kf.s == a.Key.s {
return i
}
}
return -1
}
func AddVenueFact(a []string) {
key := new(Key)
key.s = a[0]
i := FindVenueKey(key)
switch a[1] {
case "VenueType":
Venues[i].VenueType = a[2]
case "Name":
Venues[i].Name = a[2]
case "Publisher":
key.s = a[2]
j := FindOrganizationKey(key)
Venues[i].Publisher = Organizations[j]
}
}
var Venues []*Venue