<commit_before>// utility for field

var consts = require('./consts');

var field = module.exports = {};

field.shorthand = function(f) {
  return (f.aggr ? f.aggr + '_' : '') +
    (f.fn ? f.fn + '_' : '') +
    (f.bin ? 'bin_' : '') +
    (f.name || '') + '-' +
    (consts.dataTypeNames[f.type] || f.type);
};

field.shorthands = function(fields, delim){
  delim = delim || ',';
  return fields.map(field.shorthand).join(delim);
};

var typeOrder = {
  O: 0,
  G: 1,
  T: 2,
  Q: 3
};

field.order = {};

field.order.typeThenName = function(field) {
  return typeOrder[field.type] + '_' + field.name;
};

field.order.original = function() {
  return 0; // no swap will occur
};

field.order.name = function(field) {
  return field.name;
};

field.order.typeThenCardinality = function(field, stats){
  return stats[field.name].cardinality;
};

field.isOrdinalScale = function(field, isType) {
  isType = isType || function(field, type) { return field.type === dataTypeNames[type]; };
  var fn;
  return  isType(field, O) || field.bin ||
    ( isType(field, T) && field.fn && time.isOrdinalFn(field.fn) );
};
<commit_msg>fix bug<commit_after>// utility for field

var consts = require('./consts');

var field = module.exports = {};

field.shorthand = function(f) {
  return (f.aggr ? f.aggr + '_' : '') +
    (f.fn ? f.fn + '_' : '') +
    (f.bin ? 'bin_' : '') +
    (f.name || '') + '-' +
    (consts.dataTypeNames[f.type] || f.type);
};

field.shorthands = function(fields, delim){
  delim = delim || ',';
  return fields.map(field.shorthand).join(delim);
};

var typeOrder = {
  O: 0,
  G: 1,
  T: 2,
  Q: 3
};

field.order = {};

field.order.typeThenName = function(field) {
  return typeOrder[field.type] + '_' + field.name;
};

field.order.original = function() {
  return 0; // no swap will occur
};

field.order.name = function(field) {
  return field.name;
};

field.order.typeThenCardinality = function(field, stats){
  return stats[field.name].cardinality;
};

field.isOrdinalScale = function(field, isType /*optional*/) {
  isType = isType || function(field, type) {
    return field.type === consts.dataTypeNames[type];
  };

  var fn;
  return  isType(field, O) || field.bin ||
    ( isType(field, T) && field.fn && time.isOrdinalFn(field.fn) );
};

{'fraction_non_alphanumeric': 0.19735099337748344, 'fraction_numerical': 0.004415011037527594, 'mean_word_length': 3.382978723404255, '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': '2300425', 'n_tokens_mistral': 863, 'n_tokens_neox': 845, 'n_words': 166}