<commit_before>var filterCount = 0;
var filterMap = require('./filter-map.json');
var d3 = require('d3-selection');

function FilterComponent(filter, name) {
  if (!(this instanceof FilterComponent)) {
    return new FilterComponent(filter, name);
  }

  // Append to the D3 filter node
  // TODO - maybe check the name lookup..
  this.filter = filter;
  this.id = 'filter-component-' + filterCount++;
  this.filterComponent = filter.filter.append(filterMap[name]);

  // set in to SourceGraphic by default
  this.attr('result', this.id).in('SourceGraphic');

}

module.exports = FilterComponent;

FilterComponent.prototype.toString = function() {
  return this.id;
};


FilterComponent.prototype.in = function (filter1, filter2) {
  if(filter1) {
    var inAttr = 'in';
    // if(this.attr('in') && !filter2) {
    //   inAttr = 'in2';
    // }

    if (typeof filter1 === 'string') {
      return this.attr(inAttr, filter1);
    } else if (filter1 instanceof FilterComponent) {
      return this.attr(inAttr, filter1.toString());
    }
  }

  if(filter2) {
    if (typeof filter2 === 'string') {
      return this.attr('in2', filter2);
    } else if (filter2 instanceof FilterComponent) {
      return this.attr('in2', filter2.toString());
    }
  }
}

FilterComponent.prototype.to = function (name) {
  return new filterComponent(filter, name).in(this);
};


FilterComponent.prototype.attr = function () {
  if(arguments.length === 1) {
      return this.filterComponent.attr.apply(this.filterComponent, arguments);
  }
  this.filterComponent.attr.apply(this.filterComponent, arguments);
  return this;
};<commit_msg>add append method to component<commit_after>var filterCount = 0;
var filterMap = require('./filter-map.json');
var d3 = require('d3-selection');

function FilterComponent(filter, name) {
  if (!(this instanceof FilterComponent)) {
    return new FilterComponent(filter, name);
  }

  // Append to the D3 filter node
  // TODO - maybe check the name lookup..
  this.filter = filter;
  this.id = 'filter-component-' + filterCount++;
  this.filterComponent = filter.filter.append(filterMap[name]);

  // set in to SourceGraphic by default
  this.attr('result', this.id).in('SourceGraphic');

}

module.exports = FilterComponent;

FilterComponent.prototype.toString = function() {
  return this.id;
};


FilterComponent.prototype.in = function (filter1, filter2) {
  if(filter1) {
    var inAttr = 'in';
    // if(this.attr('in') && !filter2) {
    //   inAttr = 'in2';
    // }

    if (typeof filter1 === 'string') {
      return this.attr(inAttr, filter1);
    } else if (filter1 instanceof FilterComponent) {
      return this.attr(inAttr, filter1.toString());
    }
  }

  if(filter2) {
    if (typeof filter2 === 'string') {
      return this.attr('in2', filter2);
    } else if (filter2 instanceof FilterComponent) {
      return this.attr('in2', filter2.toString());
    }
  }
}

FilterComponent.prototype.to = function (name) {
  return new filterComponent(filter, name).in(this);
};


FilterComponent.prototype.attr = function () {
  if(arguments.length === 1) {
      return this.filterComponent.attr.apply(this.filterComponent, arguments);
  }
  this.filterComponent.attr.apply(this.filterComponent, arguments);
  return this;
};

FilterComponent.prototype.append = function () {
  return this.filterComponent.append.apply(this.filterComponent, arguments);
};
{'fraction_non_alphanumeric': 0.1470327723649247, 'fraction_numerical': 0.012400354295837024, 'mean_word_length': 3.673103448275862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1842225', 'n_tokens_mistral': 1044, 'n_tokens_neox': 1027, 'n_words': 237}