comparison app/normalization.service.ts @ 23:f7a7014abf5c

normalization service implementation.
author casties
date Tue, 26 Jan 2016 16:28:51 +0100
parents
children 5353b2dffb0f
comparison
equal deleted inserted replaced
22:9343e43a17d1 23:f7a7014abf5c
1 import {Injectable} from 'angular2/core';
2 import {Http, Headers} from 'angular2/http';
3
4 import 'rxjs/Rx'; // import all RxJS operators
5
6 @Injectable()
7 export class NormalizationService {
8
9 public openMindBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/';
10 //public openMindBaseUrl = 'http://localhost:18080/ismi-richfaces/';
11
12 constructor(private _http: Http) {}
13
14 fetchArabicTranslitNormalizedString(text: string) {
15 console.debug("fetching arabic translit normalized string: ", text);
16 var headers = new Headers();
17 headers.append('Accept', 'application/json');
18 // put headers in options
19 var opts = {'headers': headers};
20 // make get request asynchronously
21 var url = this.openMindBaseUrl+'jsonInterface?method=normalize_string&type=arabic_translit&text=';
22 url += text;
23 var resp = this._http.get(url, opts)
24 // filter result as JSON
25 .map(res => res.json());
26 // return Observable
27 return resp;
28 }
29
30 }