<commit_before>import { Observable } from 'rxjs/Observable';

import { BaseBackendService } from './base-backend.service';
import { Tag } from '../models/tag.model';
import { BackendResource } from '../decorators/backend-resource.decorator';
import { AsyncJobService } from './async-job.service';


@BackendResource({
  entity: 'Tag',
  entityModel: Tag
})
export class TagService extends BaseBackendService<Tag> {
  constructor(private asyncJob: AsyncJobService) {
    super();
  }

  public create(params?: {}): Observable<any> {
    return super.create(params)
      .switchMap(tagJob => this.asyncJob.queryJob(tagJob.jobid));
  }

  public remove(params?: {}): Observable<any> {
    return super.remove(params)
      .switchMap(tagJob => this.asyncJob.queryJob(tagJob.jobid))
      .catch(() => Observable.of(null));
  }

  public getList(params?: {}): Observable<Array<Tag>> {
    return this.sendCommand('list', params)
      .map(response => {
        const entity = this.entity.toLowerCase();
        const result = response[entity];
        if (!result) {
          return [];
        }
        return result.map(m => this.prepareModel(m)) as Array<Tag>;
      });
  }

  public getTag(entity: any, key: string): Observable<Tag> {
    return this.getList({ resourceIds: entity.id, key }).map(tags => tags.length ? tags[0] : undefined);<commit_msg>fix api request in tags<commit_after>import { Observable } from 'rxjs/Observable';

import { BaseBackendService } from './base-backend.service';
import { Tag } from '../models/tag.model';
import { BackendResource } from '../decorators/backend-resource.decorator';
import { AsyncJobService } from './async-job.service';


@BackendResource({
  entity: 'Tag',
  entityModel: Tag
})
export class TagService extends BaseBackendService<Tag> {
  constructor(private asyncJob: AsyncJobService) {
    super();
  }

  public create(params?: {}): Observable<any> {
    return super.create(params)
      .switchMap(tagJob => this.asyncJob.queryJob(tagJob.jobid));
  }

  public remove(params?: {}): Observable<any> {
    return super.remove(params)
      .switchMap(tagJob => this.asyncJob.queryJob(tagJob.jobid))
      .catch(() => Observable.of(null));
  }

  public getList(params?: {}): Observable<Array<Tag>> {
    return this.sendCommand('list', params)
      .map(response => {
        const entity = this.entity.toLowerCase();
        const result = response[entity];
        if (!result) {
          return [];
        }
        return result.map(m => this.prepareModel(m)) as Array<Tag>;
      });
  }

  public getTag(entity: any, key: string): Observable<Tag> {
    return this.getList({ resourceId: entity.id, key }).map(tags => tags.length ? tags[0] : undefined);
{'fraction_non_alphanumeric': 0.1565600882028666, 'fraction_numerical': 0.000735023888276369, 'mean_word_length': 3.5747899159663867, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 29, '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': '2634520', 'n_tokens_mistral': 807, 'n_tokens_neox': 806, 'n_words': 175}