-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotation-parse-results.component.ts
More file actions
57 lines (51 loc) · 1.91 KB
/
Copy pathannotation-parse-results.component.ts
File metadata and controls
57 lines (51 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { Component, DestroyRef, inject } from "@angular/core";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ParseService } from "@/services/parse.service";
import { ParseTreeTableComponent } from "./parse-tree-table/parse-tree-table.component";
import { NgbAccordionModule } from "@ng-bootstrap/ng-bootstrap";
import { map } from "rxjs";
import { CommonModule } from "@angular/common";
import { CCGNode, CCGParse } from "@/types";
import { NoDataComponent } from "@/shared/no-data/no-data.component";
export interface TreeWithType {
type: string;
tree: CCGNode;
}
interface UnfoldedParseResult {
sentence: string;
ccgTrees: TreeWithType[];
}
function unfoldParseResult(parse: CCGParse): UnfoldedParseResult {
const { ccg_tree, ccg_term, corr_term, llf } = parse.ccg_trees;
// TODO: Reintroduce the other trees once they are serialized properly.
return {
...parse,
ccgTrees: [
{ type: "CCG Tree", tree: ccg_tree },
{ type: "CCG Term", tree: ccg_term },
{ type: "Corrected CCG Term", tree: corr_term },
{ type: "Lambda Logical Form", tree: llf }
]
};
}
@Component({
selector: "la-annotation-parse-results",
standalone: true,
imports: [
ParseTreeTableComponent,
NgbAccordionModule,
CommonModule,
NoDataComponent,
],
templateUrl: "./annotation-parse-results.component.html",
styleUrl: "./annotation-parse-results.component.scss",
})
export class AnnotationParseResultsComponent {
private destroyRef = inject(DestroyRef);
private parseService = inject(ParseService);
public parseResults$ = this.parseService.parse$
.pipe(
map(response => response?.data?.ccg_parses.map(parse => unfoldParseResult(parse)) ?? null),
takeUntilDestroyed(this.destroyRef)
);
}