Skip to content

Commit c9af09b

Browse files
committed
add doc metadata + highlight answer
1 parent bfc8e39 commit c9af09b

File tree

3 files changed

+32
-6
lines changed

3 files changed

+32
-6
lines changed

package-lock.json

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"axios": "^0.18.0",
1212
"bootstrap-vue": "^2.0.0-rc.20",
1313
"core-js": "^2.6.5",
14-
"vue": "^2.6.10"
14+
"vue": "^2.6.10",
15+
"vue-highlight-words": "^1.0.0"
1516
},
1617
"devDependencies": {
1718
"@vue/cli-plugin-babel": "^3.7.0",

src/components/cdqaUI.vue

+17-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
</div>
1111

1212
<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>
1414
<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"/>
1717
</b-popover>
1818
</div>
1919

@@ -23,15 +23,21 @@
2323

2424
<script>
2525
import axios from 'axios';
26+
import Highlighter from 'vue-highlight-words'
2627
2728
export default {
2829
name: 'cdqaUI',
30+
components: {
31+
Highlighter
32+
},
2933
data() {
3034
return {
3135
query: '',
3236
show: false,
3337
status: 'started',
34-
prediction: ''
38+
answer: '',
39+
title: '',
40+
paragraph: '',
3541
}
3642
},
3743
methods: {
@@ -41,7 +47,9 @@ export default {
4147
let self = this;
4248
axios.get("http://localhost:5000/api", { params: {query: self.query} })
4349
.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;
4553
self.status = "done"
4654
})
4755
.catch(function (error) {
@@ -54,4 +62,8 @@ export default {
5462

5563
<!-- Add "scoped" attribute to limit CSS to this component only -->
5664
<style scoped>
65+
.highlight {
66+
background-color: yellow;
67+
font-weight: bold;
68+
}
5769
</style>

0 commit comments

Comments
 (0)