<commit_before>import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/first';

@Injectable()
export class SentenceService {

  constructor(private http: Http) { }

  getSentences() {
    return this.http.get('http://localhost:8080/api/v1/libs/')
      .map(response => response.json())
      .map(sentences => this.transformSentences(sentences));
  }

  getSentence(id: string) {
    return this.getSentences().map(sentences => {
      for (let sentence of sentences) {
        if (sentence.id === id) {
          return sentence;
        }
      }
      return null;
    });
  }

  transformSentences(originalSentences) {
    let sentences = [];

    for (let sentence of originalSentences) {
      sentence.words = sentence.text.match(/{{.+?}}/g);
      sentence.words = sentence.words.map(function(word) {
        return word.replace(/[{}]/g, '');
      });
      sentences.push(sentence);
    }

    return sentences;
  }
}<commit_msg>Refactoring.<commit_after>import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/filter';
import 'rxjs/add/operator/first';

@Injectable()
export class SentenceService {

  constructor(private http: Http) { }

  getSentences() {
    return this.http.get('http://localhost:8080/api/v1/libs/')
      .map(response => response.json())
      .map(sentences => this.transformSentences(sentences));
  }

  getSentence(id: string) {
    return this.getSentences().map(sentences => {
      for (let sentence of sentences) {
        if (sentence.id === id) {
          return sentence;
        }
      }
      return null;
    });
  }

  transformSentences(originalSentences) {
    return originalSentences.map(sentence => {
      sentence.words = sentence.text
        .match(/{{.+?}}/g)
        .map(word => word.replace(/[{}]/g, ''));

      return sentence;
    });
  }
}
{'fraction_non_alphanumeric': 0.16119402985074627, 'fraction_numerical': 0.004975124378109453, 'mean_word_length': 2.904854368932039, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '2250707', 'n_tokens_mistral': 650, 'n_tokens_neox': 622, 'n_words': 115}