<commit_before>import {
  Directive,
  ElementRef,
  EventEmitter,
  HostListener,
  OnInit,
  Output,
  Renderer
} from '@angular/core';

import { PickedFile } from './picked-file';
import { PickedFileImpl } from './picked-file-impl';

@Directive({
  selector: '[ngFilePicker]'
})
export class FilePickerDirective implements OnInit {
  @Output()
  public filePick = new EventEmitter<PickedFile>();
  
  private input: any;

  constructor(private el: ElementRef, private renderer: Renderer) {
  }

  ngOnInit() {
    this.input = this.renderer.createElement(this.el.nativeElement.parentNode, 'input');
    this.renderer.setElementAttribute(this.input, 'type', 'file');
    this.renderer.setElementStyle(this.input, 'display', 'none');

    this.renderer.listen(this.input, 'change', (event: any) => {
      if (event.target.files.length < 1) {
        return;
      }
      
      this.readFile(event.target.files[0]);
    });
  }

  @HostListener('click')
  browse() {
    this.renderer.invokeElementMethod(this.input, 'click');
  }

  private readFile(file: File) {
    const reader = new FileReader();

    reader.onload = (loaded: ProgressEvent) => {
      const fileReader = loaded.target as FileReader;
      const pickedFile = new PickedFileImpl(file.lastModifiedDate, file.name, file.size, file.type, fileReader.result);
      
      this.filePick.emit(pickedFile);
    };<commit_msg>Add support for the accept attribute<commit_after>import {
  Directive,
  ElementRef,
  EventEmitter,
  Input,
  HostListener,
  OnInit,
  Output,
  Renderer
} from '@angular/core';

import { PickedFile } from './picked-file';
import { PickedFileImpl } from './picked-file-impl';

@Directive({
  selector: '[ngFilePicker]'
})
export class FilePickerDirective implements OnInit {
  @Input()
  public accept = '';

  @Output()
  public filePick = new EventEmitter<PickedFile>();
  
  private input: any;

  constructor(private el: ElementRef, private renderer: Renderer) {
  }

  ngOnInit() {
    this.input = this.renderer.createElement(this.el.nativeElement.parentNode, 'input');
    this.renderer.setElementAttribute(this.input, 'type', 'file');
    this.renderer.setElementAttribute(this.input, 'accept', this.accept);
    this.renderer.setElementStyle(this.input, 'display', 'none');

    this.renderer.listen(this.input, 'change', (event: any) => {
      if (event.target.files.length < 1) {
        return;
      }
      
      this.readFile(event.target.files[0]);
    });
  }

  @HostListener('click')
  browse() {
    this.renderer.invokeElementMethod(this.input, 'click');
  }

  private readFile(file: File) {
    const reader = new FileReader();

    reader.onload = (loaded: ProgressEvent) => {
      const fileReader = loaded.target as FileReader;
      const pickedFile = new PickedFileImpl(file.lastModifiedDate, file.name, file.size, file.type, fileReader.result);
      
      this.filePick.emit(pickedFile);
    };
{'fraction_non_alphanumeric': 0.13919288645690833, 'fraction_numerical': 0.0013679890560875513, 'mean_word_length': 3.642857142857143, 'pattern_counts': {'":': 0, '<': 7, '<?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': '789437', 'n_tokens_mistral': 929, 'n_tokens_neox': 922, 'n_words': 186}