[748a59]: / nih-ct-protocol-ui / src / app / app.component.ts

Download this file

75 lines (41 with data), 1.2 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
62
63
64
65
66
67
68
69
70
71
72
73
74
import { Component } from '@angular/core';
import {SearchItemsComponent} from './search-items/search-items.component';
import {PredictService} from './predict.service';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'AI-Mediated Protocol Writer';
result=null;
text="";
suggestion='';
score =0
constructor(private predictService: PredictService){}
onSubmit(){
this.suggestion="sfsfs";
this.score=9;
this.predictService.predict("sfsf",this.text)
.subscribe(res => {
this.result = res;
if(res.hits.total>0)
{
this.suggestion="";
res.hits.hits.forEach(h=>{
h._source.value.split(" ").forEach(w=>{
if(this.text.indexOf(w)>-1)
{
this.suggestion=this.suggestion+ " "+w;
}
else{
this.suggestion=this.suggestion+" <mark>"+w+"</mark>";
}
});
this.suggestion = this.suggestion +" SCORE: " + ((h._score - 0) / (1 - 0)) + "</br>" + "</br>";
});
}
});
//Fuzzy Search to higlight keywords in input
}
}