view app/normalization.service.ts @ 41:5353b2dffb0f

added local configuration file app/app-config.ts.
author casties
date Mon, 15 Feb 2016 17:05:07 +0100
parents f7a7014abf5c
children dc4f0541f04d
line wrap: on
line source

import {Injectable} from 'angular2/core';
import {Http, Headers} from 'angular2/http';

import 'rxjs/Rx'; // import all RxJS operators

import {OPENMIND_BASE_URL} from './app-config';

@Injectable()
export class NormalizationService {

    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 = OPENMIND_BASE_URL+'jsonInterface?method=normalize_string&type=arabic_translit&text=';
        url += encodeURIComponent(text);
        var resp = this._http.get(url, opts)
        // filter result as JSON
        .map(res => res.json());
        // return Observable
        return resp;        
    }

}