changeset 23:f7a7014abf5c

normalization service implementation.
author casties
date Tue, 26 Jan 2016 16:28:51 +0100
parents 9343e43a17d1
children f6f4177d0a81
files app/normalization.service.ts
diffstat 1 files changed, 30 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/normalization.service.ts	Tue Jan 26 16:28:51 2016 +0100
@@ -0,0 +1,30 @@
+import {Injectable} from 'angular2/core';
+import {Http, Headers} from 'angular2/http';
+
+import 'rxjs/Rx'; // import all RxJS operators
+
+@Injectable()
+export class NormalizationService {
+
+    public openMindBaseUrl = 'https://ismi-dev.mpiwg-berlin.mpg.de/om4-ismi/';
+    //public openMindBaseUrl = 'http://localhost:18080/ismi-richfaces/';
+
+    constructor(private _http: Http) {}
+
+    fetchArabicTranslitNormalizedString(text: string) {
+        console.debug("fetching arabic translit normalized string: ", text);
+        var headers = new Headers();
+        headers.append('Accept', 'application/json');
+        // put headers in options
+        var opts = {'headers': headers};
+        // make get request asynchronously
+        var url = this.openMindBaseUrl+'jsonInterface?method=normalize_string&type=arabic_translit&text=';
+        url += text;
+        var resp = this._http.get(url, opts)
+        // filter result as JSON
+        .map(res => res.json());
+        // return Observable
+        return resp;        
+    }
+
+}
\ No newline at end of file