<commit_before>import { Injectable, Output, EventEmitter } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/timeout';

@Injectable()
export class VocabularyService {
  store: any;
  @Output() list = new EventEmitter();
  @Output() listIndex = new EventEmitter();
  @Output() listValue = new EventEmitter();

  constructor(private http: Http) { }

  loadVocabulary(url: string): Promise<any> {
    if (url === '') {
      this.store = null;
      return Promise.resolve(this.store);
    }
    return this.http.get(url)
      .timeout(600000)
      .toPromise()
      .then((response) => {
        let data: string = response.text();
        this.store = this.parse(data);
        return this.store;
      })
      .catch((err) => {<commit_msg>Fix issue when caching vocabulary<commit_after>import { Injectable, Output, EventEmitter } from '@angular/core';
import { Headers, Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import 'rxjs/add/operator/timeout';

@Injectable()
export class VocabularyService {
  store: any;
  @Output() list = new EventEmitter();
  @Output() listIndex = new EventEmitter();
  @Output() listValue = new EventEmitter();

  constructor(private http: Http) { }

  loadVocabulary(url: string): Promise<any> {
    if (url === '') {
      this.store = null;
      return Promise.resolve(this.store);
    }

    let headers = new Headers({
      'Cache-Control': 'no-cache, no-store',
      'Pragma': 'no-cache',
      'Expires': '0'
    }); 

    return this.http.get(url, { headers: headers })
      .timeout(600000)
      .toPromise()
      .then((response) => {
        let data: string = response.text();
        this.store = this.parse(data);
        return this.store;
      })
      .catch((err) => {
{'fraction_non_alphanumeric': 0.15729109776078645, 'fraction_numerical': 0.0070999453850355, 'mean_word_length': 3.1168539325842697, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1995711', 'n_tokens_mistral': 579, 'n_tokens_neox': 571, 'n_words': 135}