-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathannotate.component.ts
More file actions
61 lines (55 loc) · 2.25 KB
/
Copy pathannotate.component.ts
File metadata and controls
61 lines (55 loc) · 2.25 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
58
59
60
61
import { Component, DestroyRef, inject, OnInit } from "@angular/core";
import { AnnotationMenuComponent } from "./annotation-menu/annotation-menu.component";
import { NavigatorComponent } from "./navigator/navigator.component";
import { AnnotationInputComponent, ParseInput } from "./annotation-input/annotation-input.component";
import { SearchComponent } from "./search/search.component";
import { FontAwesomeModule } from "@fortawesome/angular-fontawesome";
import { faTree } from "@fortawesome/free-solid-svg-icons";
import { ParseResponse, ParseService } from "@/services/parse.service";
import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
import { ProblemResponse } from "@/types";
import { ProblemService } from "@/services/problem.service";
import { Tree } from "@/tree";
@Component({
selector: "la-annotate",
standalone: true,
imports: [
AnnotationMenuComponent,
NavigatorComponent,
AnnotationInputComponent,
SearchComponent,
FontAwesomeModule,
],
templateUrl: "./annotate.component.html",
styleUrl: "./annotate.component.scss",
})
export class AnnotateComponent implements OnInit {
public faTree = faTree;
private destroyRef = inject(DestroyRef);
private parseService = inject(ParseService);
private problemService = inject(ProblemService);
public ccgTrees: Tree<string>[] = [];
private problem: ProblemResponse | null = null;
ngOnInit() {
// TODO: This is wrong. It seems silly to keep a local copy of the problem,
// and it's also not connected to the form, so any edits will not affect
// the requests
this.problemService.problem$
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe((problem) => {
this.problem = problem;
});
}
onParse(response: ParseResponse) {
console.log("Parse response:", response);
this.ccgTrees = response!.data.ccg_trees.map((tree: any) => new Tree(tree));
}
startParse() {
let input: ParseInput = {
premises: this.problem?.problem?.premises!,
hypothesis: this.problem?.problem?.hypothesis!,
kbItems: []
};
this.parseService.startParse(input, (r) => this.onParse(r));
}
}