File tree 3 files changed +32
-6
lines changed
3 files changed +32
-6
lines changed Original file line number Diff line number Diff line change 11
11
"axios" : " ^0.18.0" ,
12
12
"bootstrap-vue" : " ^2.0.0-rc.20" ,
13
13
"core-js" : " ^2.6.5" ,
14
- "vue" : " ^2.6.10"
14
+ "vue" : " ^2.6.10" ,
15
+ "vue-highlight-words" : " ^1.0.0"
15
16
},
16
17
"devDependencies" : {
17
18
"@vue/cli-plugin-babel" : " ^3.7.0" ,
Original file line number Diff line number Diff line change 10
10
</div >
11
11
12
12
<div v-else-if =" status == 'done'" >
13
- <b-button variant =" primary" id =" popover-button-sync" >{{ prediction }}</b-button >
13
+ <b-button variant =" primary" id =" popover-button-sync" >{{ answer }}</b-button >
14
14
<b-popover :placement =" 'bottom'" :show.sync =" show" target =" popover-button-sync" >
15
- <template slot="title">Document Title < a href = " / " >(Link)</ a > </template >
16
- The paragraph of the retrieved article with < strong >< span class = " text-primary " >the answer highlighted</ span ></ strong > with some HTML.
15
+ <template slot="title">{{ title }} </template >
16
+ < Highlighter highlightClassName = " highlight " :searchWords = " [ answer] " :autoEscape = " true " :textToHighlight = " paragraph " />
17
17
</b-popover >
18
18
</div >
19
19
23
23
24
24
<script >
25
25
import axios from ' axios' ;
26
+ import Highlighter from ' vue-highlight-words'
26
27
27
28
export default {
28
29
name: ' cdqaUI' ,
30
+ components: {
31
+ Highlighter
32
+ },
29
33
data () {
30
34
return {
31
35
query: ' ' ,
32
36
show: false ,
33
37
status: ' started' ,
34
- prediction: ' '
38
+ answer: ' ' ,
39
+ title: ' ' ,
40
+ paragraph: ' ' ,
35
41
}
36
42
},
37
43
methods: {
@@ -41,7 +47,9 @@ export default {
41
47
let self = this ;
42
48
axios .get (" http://localhost:5000/api" , { params: {query: self .query } })
43
49
.then (function (response ) {
44
- self .prediction = response .data .prediction ;
50
+ self .answer = response .data .answer ;
51
+ self .title = response .data .title ;
52
+ self .paragraph = response .data .paragraph ;
45
53
self .status = " done"
46
54
})
47
55
.catch (function (error ) {
@@ -54,4 +62,8 @@ export default {
54
62
55
63
<!-- Add "scoped" attribute to limit CSS to this component only -->
56
64
<style scoped>
65
+ .highlight {
66
+ background-color: yellow;
67
+ font-weight: bold;
68
+ }
57
69
</style>
You can’t perform that action at this time.
0 commit comments