@@ -17,9 +17,13 @@ import {
1717} from "./knowledge-base-form/knowledge-base-form.component" ;
1818import { AnnotateService } from "../../services/annotate.service" ;
1919import { toSignal } from "@angular/core/rxjs-interop" ;
20- import { ProblemResponse } from "../../types" ;
20+ import { Judgement , ProblemResponse } from "../../types" ;
2121import { FontAwesomeModule } from "@fortawesome/angular-fontawesome" ;
2222import { faCheck } from "@fortawesome/free-solid-svg-icons" ;
23+ import {
24+ ProblemDetails ,
25+ ProblemDetailsComponent ,
26+ } from "./problem-details/problem-details.component" ;
2327
2428type KnowledgeBaseItemsForm = FormGroup < {
2529 entity1 : FormControl < string > ;
@@ -42,6 +46,7 @@ export type AnnotationInputForm = FormGroup<{
4246 KnowledgeBaseFormComponent ,
4347 ReactiveFormsModule ,
4448 FontAwesomeModule ,
49+ ProblemDetailsComponent ,
4550 ] ,
4651 templateUrl : "./annotation-input.component.html" ,
4752 styleUrl : "./annotation-input.component.scss" ,
@@ -50,11 +55,13 @@ export class AnnotationInputComponent {
5055 private problemResponse = toSignal ( this . annotateService . problem$ ) ;
5156
5257 public form = computed < AnnotationInputForm | null > ( ( ) => {
53- const problem = this . problemResponse ( ) ;
54- if ( ! problem ) {
58+ const response = this . problemResponse ( ) ;
59+ if ( ! response ) {
5560 return null ;
5661 }
57- const { premises, conclusion } = this . getPremisesAndConclusion ( problem ) ;
62+
63+ const { premises, conclusion } =
64+ this . getPremisesAndConclusion ( response ) ;
5865 return new FormGroup ( {
5966 premises : new FormArray (
6067 premises . map (
@@ -73,6 +80,63 @@ export class AnnotationInputComponent {
7380 } ) ;
7481 } ) ;
7582
83+ public problemDetails = computed < ProblemDetails | null > ( ( ) => {
84+ const response = this . problemResponse ( ) ;
85+ if ( ! response || ! response . problem ) {
86+ return null ;
87+ }
88+ const judgement = this . getJudgement ( response ) ;
89+ if ( response . type === "sick" ) {
90+ return {
91+ problemId : response . problem . pairId . toString ( ) ,
92+ dataset : response . type ,
93+ judgement,
94+ section : null ,
95+ subsection : null ,
96+ comment : null ,
97+ } ;
98+ }
99+ // FraCaS
100+ return {
101+ problemId : response . problem . fracasId . toString ( ) ,
102+ dataset : response . type ,
103+ judgement,
104+ section : response . problem . sectionName ,
105+ subsection : response . problem . subsectionName ,
106+ comment : response . problem . note || null ,
107+ } ;
108+ } ) ;
109+
110+ private getJudgement ( problem : ProblemResponse ) : Judgement {
111+ if ( ! problem . problem ) {
112+ return Judgement . UNKNOWN ;
113+ }
114+ if ( problem . type === "sick" ) {
115+ switch ( problem . problem . entailmentLabel ) {
116+ case "ENTAILMENT" :
117+ return Judgement . ENTAILMENT ;
118+ case "CONTRADICTION" :
119+ return Judgement . CONTRADICTION ;
120+ case "NEUTRAL" :
121+ return Judgement . NEUTRAL ;
122+ default :
123+ return Judgement . UNKNOWN ;
124+ }
125+ }
126+ // FraCaS
127+ switch ( problem . problem . fracasAnswer ) {
128+ case "yes" :
129+ return Judgement . ENTAILMENT ;
130+ case "no" :
131+ return Judgement . CONTRADICTION ;
132+ case "unknown" :
133+ return Judgement . NEUTRAL ;
134+ // Also includes case "undefined"
135+ default :
136+ return Judgement . UNKNOWN ;
137+ }
138+ }
139+
76140 public faCheck = faCheck ;
77141
78142 constructor ( private annotateService : AnnotateService ) { }
0 commit comments