Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/applications/qa/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ async function ask(
title: entry.document.title,
url: entry.document.url,
confidenceScore: entry.answer.confidence_score,
question_type_prediction: entry.answer.question_type_prediction,
boolean_answer_prediction: entry.answer.boolean_answer_prediction,
display_each_boolean_answer: true
});
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/applications/reading/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ async function read(
startCharOffset: answer.start_char_offset,
endCharOffset: answer.end_char_offset,
confidenceScore: answer.confidence_score,
question_type_prediction: answer.question_type_prediction,
boolean_answer_prediction: answer.boolean_answer_prediction,
display_each_boolean_answer: false
});
});
}
Expand Down Expand Up @@ -124,7 +127,7 @@ function Reading({ application, showSettings }) {
{application.description}
</div>
<div className="application__content">
<h4>What would you like to know?</h4>
<h4>What would you like to know? (boolean or factoid question)</h4>
<div className="reading__input">
<TextArea
labelText="Context"
Expand Down
82 changes: 74 additions & 8 deletions src/components/answers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,59 @@ async function postFeedback(
}
}

/* allows us to control the highlighting of yes/no in both reading and qa
note that no_answer will be highlighted like no if it occurs */
function YesNoAnswer({boolean_answer_prediction}) {
return (
<React.Fragment>
{boolean_answer_prediction.toLowerCase()=="yes" ?
<b className="answers--item__context--yesanswer">
{boolean_answer_prediction}
</b>
:
<b className="answers--item__context--noanswer">
{boolean_answer_prediction}
</b>
}
</React.Fragment>
)
}

function AnswersSummary({answersWithFeedback}) {
return (
<React.Fragment>
<div className="answers--details">
<h6>
{answersWithFeedback[0].question_type_prediction==null &&
<p>Found {answersWithFeedback.length} answers matching your question..</p>
}
{answersWithFeedback[0].question_type_prediction!=null &&
<div>
<p> Your question is a <b className="answers--item__context--highlight">
{answersWithFeedback[0].question_type_prediction}
</b> question
</p>
{answersWithFeedback[0].question_type_prediction!='boolean' &&
<p>Found {answersWithFeedback.length} answers matching your question..</p>
}
{answersWithFeedback[0].question_type_prediction=='boolean' &&
<div>
<p>Found {answersWithFeedback.length} evidence spans answering your question..</p>
<p>The best answer is {" "}
{(<YesNoAnswer boolean_answer_prediction={answersWithFeedback[0].boolean_answer_prediction}>
</YesNoAnswer>
)} .
</p>
</div>
}
</div>
}
</h6>
</div>
</React.Fragment>
)
}

function Answers({ question, answers, loading, source }) {
const [answersWithFeedback, setAnswersWithFeedback] = useState([]);

Expand All @@ -275,11 +328,10 @@ function Answers({ question, answers, loading, source }) {
<React.Fragment>
{!loading && !_.isEmpty(answersWithFeedback) ? (
<React.Fragment>
<div className="answers--details">
<h6>
Found {answersWithFeedback.length} answers matching your question.
</h6>
</div>
{/* found 3 answers, your question is boolean etc */}
{(<AnswersSummary answersWithFeedback={answersWithFeedback}>
</AnswersSummary>
)}
<div className="answers--items">
{answersWithFeedback.map((answerWithFeedback, index) => {
return (
Expand All @@ -288,7 +340,21 @@ function Answers({ question, answers, loading, source }) {
key={"answer--item-" + index}
className="answers--item"
>
<h6>Answer</h6>
<h6>
{answersWithFeedback[0].question_type_prediction=="boolean" &&
<div>
<p>Evidence span: {answerWithFeedback.display_each_boolean_answer &&
<div>{(<YesNoAnswer boolean_answer_prediction={answerWithFeedback.boolean_answer_prediction}>
</YesNoAnswer>
)}
</div>
}</p>
</div>
}
{answersWithFeedback[0].question_type_prediction!="boolean" && <div><p>Answer</p></div>}
</h6>


<div className="answers--item__content">
<div className="answers--item__content--left">
<span>{answerWithFeedback.text}</span>
Expand Down Expand Up @@ -322,11 +388,11 @@ function Answers({ question, answers, loading, source }) {
<div className="answers--item__content--right">
{!_.isNil(answerWithFeedback.confidenceScore) ? (
<div className="answers--item__confidence">
Score (out of 100):
Score:
<span>
{Math.round(
answerWithFeedback.confidenceScore * 100
)}
)} / 100
</span>
</div>
) : null}
Expand Down
10 changes: 10 additions & 0 deletions src/components/answers/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,16 @@
background-color: $blue-20;
}

&--yesanswer {
font-weight: 600;
background-color: $green-20;
}

&--noanswer {
font-weight: 600;
background-color: $yellow-20;
}

.cds--accordion__item {
border-top: none;
margin-top: 10px;
Expand Down