Skip to content

Commit 12b3cab

Browse files
Restyle input form card
1 parent 70deb64 commit 12b3cab

2 files changed

Lines changed: 92 additions & 11 deletions

File tree

frontend/src/app/annotate/annotation-input/annotation-input.component.html

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,29 @@ <h2 i18n>Parser input</h2>
66
</p>
77

88
@if (form(); as inputForm) {
9-
<div class="d-flex flex-row gap-5">
10-
<la-premises-form class="w-50" [form]="inputForm" />
11-
<la-knowledge-base-form class="w-50" [form]="inputForm" />
9+
<div class="card">
10+
<div class="card-body">
11+
@if (problemDetails(); as details) {
12+
<la-problem-details [problemDetails]="details" />
13+
}
14+
<div class="d-flex flex-row gap-5">
15+
<la-premises-form class="w-50" [form]="inputForm" />
16+
<la-knowledge-base-form class="w-50" [form]="inputForm" />
17+
</div>
18+
</div>
19+
<div class="mb-3 d-flex justify-content-center">
20+
<button
21+
type="submit"
22+
class="btn btn-success"
23+
[disabled]="inputForm?.invalid"
24+
>
25+
<fa-icon
26+
[icon]="faCheck"
27+
class="fa-sm"
28+
aria-hidden="true"
29+
></fa-icon>
30+
<span class="ms-2" i18n>Submit</span>
31+
</button>
32+
</div>
1233
</div>
13-
<button type="submit" class="btn btn-success" [disabled]="inputForm?.invalid">
14-
<fa-icon [icon]="faCheck" class="fa-sm" aria-hidden="true"></fa-icon>
15-
<span class="ms-2" i18n>Submit</span>
16-
</button>
1734
}

frontend/src/app/annotate/annotation-input/annotation-input.component.ts

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ import {
1717
} from "./knowledge-base-form/knowledge-base-form.component";
1818
import { AnnotateService } from "../../services/annotate.service";
1919
import { toSignal } from "@angular/core/rxjs-interop";
20-
import { ProblemResponse } from "../../types";
20+
import { Judgement, ProblemResponse } from "../../types";
2121
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
2222
import { faCheck } from "@fortawesome/free-solid-svg-icons";
23+
import {
24+
ProblemDetails,
25+
ProblemDetailsComponent,
26+
} from "./problem-details/problem-details.component";
2327

2428
type 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

Comments
 (0)