-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublications.go
147 lines (131 loc) · 4.68 KB
/
publications.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package entities
// TODO build out publication struct
import (
"errors"
"fmt"
)
var _ = fmt.Println // remove after test
func makePublicationTypeSet() map[string]struct{} {
a := map[string]struct{}{}
a["Abstract"] = struct{}{}
a["Article"] = struct{}{}
a["Editorial"] = struct{}{}
a["Book"] = struct{}{}
a["Booklet"] = struct{}{}
a["InBook"] = struct{}{}
a["InCollection"] = struct{}{}
a["Manual"] = struct{}{}
a["MasterThesis"] = struct{}{}
a["PhDThesis"] = struct{}{}
a["Proceedings"] = struct{}{}
a["TechReport"] = struct{}{}
a["Unpublished"] = struct{}{}
a["Dataset"] = struct{}{}
a["Presentation"] = struct{}{}
return a
}
var PublicationTypeSet = makePublicationTypeSet()
type Publication struct {
Key *Key
PublicationType string
Title string
Abstract string
PublicationDate *Date
Venue *Venue
DOI *URL
FullTextURL *URL
Authors []*Person
Keywords []*Concept
}
func NewPublication(ty string, ti string) (*Publication,error) {
p := new(Publication)
p.Key = makeKey("Publication")
_,ok := PublicationTypeSet[ty]
if !ok {
err := errors.New("Unknown publication type: "+ty)
return nil,err
}
p.PublicationType = ty
p.Title = ti
return p, nil
}
func NewAbstract(n string) (*Publication,error) {return NewPublication("Abstract", n)}
func NewArticle(n string) (*Publication,error) {return NewPublication("Article", n)}
func NewEditorial(n string) (*Publication,error) {return NewPublication("Editorial", n)}
func NewBook(n string) (*Publication,error) {return NewPublication("Book", n)}
func NewBooklet(n string) (*Publication,error) {return NewPublication("Booklet", n)}
func NewInBook(n string) (*Publication,error) {return NewPublication("InBook", n)}
func NewInCollection(n string) (*Publication,error) {return NewPublication("InCollection", n)}
func NewManual(n string) (*Publication,error) {return NewPublication("Manual", n)}
func NewMasterThesis(n string) (*Publication,error) {return NewPublication("MasterThesis", n)}
func NewPhDThesis(n string) (*Publication,error) {return NewPublication("PhDThesis", n)}
func NewProceedings(n string) (*Publication,error) {return NewPublication("Proceedings", n)}
func NewTechReport(n string) (*Publication,error) {return NewPublication("TechReport", n)}
func NewUnpublished(n string) (*Publication,error) {return NewPublication("Unpublished", n)}
func NewDataset(n string) (*Publication,error) {return NewPublication("Dataset", n)}
func NewPresentation(n string) (*Publication,error) {return NewPublication("Presentation", n)}
func (a *Publication) Triples () [][3]string {
var t [][3]string
t = append(t, makeTriple(Triple{(*a).Key,"hasType","Publication",nil}))
t = append(t, makeTriple(Triple{(*a).Key,"hasPublicationType",(*a).PublicationType,nil}))
if (*a).Title != "" {t = append(t, makeTriple(Triple{(*a).Key,"hasTitle",(*a).Title,nil}))}
if (*a).Abstract != "" {t = append(t, makeTriple(Triple{(*a).Key,"hasAbstract",(*a).Abstract,nil}))}
if (*a).PublicationDate != nil {t = append(t, makeTriple(Triple{(*a).Key,"hasPublicationDate","",(*a.PublicationDate).Key}))}
if (*a).Venue != nil {t = append(t, makeTriple(Triple{(*a).Key,"hasVenue","",(*a.Venue).Key}))}
if (*a).DOI != nil {t = append(t, makeTriple(Triple{(*a).Key,"hasDOI","",(*a.DOI).Key}))}
if (*a).FullTextURL != nil {t = append(t, makeTriple(Triple{(*a).Key,"hasFullTextURL","",(*a.FullTextURL).Key}))}
for _,cptr := range (*a).Authors {
t = append(t, makeTriple(Triple{(*a).Key,"hasAuthor","",cptr.Key}))
}
for _,cptr := range (*a).Keywords {
t = append(t, makeTriple(Triple{(*a).Key,"hasKeyword","",cptr.Key}))
}
return t
}
func FindPublicationKey (kf *Key) int {
for i,a := range Publications {
if kf.s == a.Key.s {
return i
}
}
return -1
}
func AddPublicationFact(a []string) {
key := new(Key)
key.s = a[0]
i := FindPublicationKey(key)
switch a[1] {
case "PublicationType":
Publications[i].PublicationType = a[2]
case "Title":
Publications[i].Title = a[2]
case "Abstract":
Publications[i].Abstract = a[2]
case "PublicationDate":
key.s = a[2]
j := FindDateKey(key)
Publications[i].PublicationDate = Dates[j]
case "Venue":
key.s = a[2]
j := FindVenueKey(key)
Publications[i].Venue = Venues[j]
case "DOI":
key.s = a[2]
j := FindURLKey(key)
Publications[i].DOI = URLs[j]
case "FullTextURL":
key.s = a[2]
j := FindURLKey(key)
Publications[i].FullTextURL = URLs[j]
case "Author":
key.s = a[2]
j := FindPersonKey(key)
Publications[i].Authors = append(Publications[i].Authors,People[j])
case "Keyword":
key.s = a[2]
j := FindConceptKey(key)
fmt.Println(j,key,a)
Publications[i].Keywords = append(Publications[i].Keywords,Concepts[j])
}
}
var Publications []*Publication