-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhandler.go
More file actions
62 lines (53 loc) · 1.31 KB
/
Copy pathhandler.go
File metadata and controls
62 lines (53 loc) · 1.31 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
package main
import (
"github.com/gin-gonic/gin"
"net/http"
"sort"
)
func Index(c *gin.Context) {
c.HTML(200, "index.html", nil)
}
func ClassicAbstractionHandler(c *gin.Context) {
id := c.Param("title")
document := docsMap[id]
document.WordWeightsStruct = calcDocWeights(document)
document.Sentences = calcSentsWeight(document)
sort.Slice(document.Sentences, func(i, j int) bool {
return document.Sentences[i].Weight > document.Sentences[j].Weight
})
docsMap[id] = document
resultSentences := document.Sentences[:10]
var text string
for _, str := range resultSentences {
text += str.Sentence.Text + " "
}
c.HTML(http.StatusOK, "result_classic.html", gin.H {
"Id": id,
"Title" : document.Title,
"Link": document.Link,
"Text" : text,
})
}
func KeyAbstraction(c *gin.Context) {
id := c.Param("title")
document := docsMap[id]
keywords := getKeyWords(document.Words)
keywords = fixList(keywords)
document.KeyWords = keywords
docsMap[id] = document
c.HTML(http.StatusOK, "result_keywords.html", gin.H{
"Id": id,
"Title" : document.Title,
"Link": document.Link,
"KeyWords": keywords,
})
}
func File(c *gin.Context) {
id := c.Param("title")
document := docsMap[id]
c.HTML(http.StatusOK, "file.html", gin.H{
"Title" : document.Title,
"Link": document.Link,
"Text": document.ShortText,
})
}