<commit_before>import {isString} from 'vega-util';

export default function(name, fields) {
  if (!isString(name)) {
    var object = 'item.mark.group', field;
    if (name.parent != null) {
      field = name.parent;
      object += '.datum';
    } else if (name.group != null) {
      field = name.group;
    }
    fields[field] = 1;
    return object + '[\'' + field + '\']';
  } else {
    fields[name] = 1;
    return 'datum[\'' + name + '\']';
  }
}
<commit_msg>Support field encode with nested properties.<commit_after>import {isString, splitAccessPath, stringValue} from 'vega-util';

export default function(name, fields) {
  var object = 'datum';

  if (!isString(name)) {
    object = 'item.mark.group';
    if (name.parent != null) {
      name = name.parent;
      object += '.datum';
    } else if (name.group != null) {
      name = name.group;
    }
  }

  fields[name] = 1;
  return object + '['
    + splitAccessPath(name).map(stringValue).join('][')
    + ']';
}

{'fraction_non_alphanumeric': 0.18024439918533605, 'fraction_numerical': 0.003054989816700611, 'mean_word_length': 2.7662835249042144, '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': '5100441', 'n_tokens_mistral': 339, 'n_tokens_neox': 336, 'n_words': 78}