<commit_before>import parseEncode from './encode';
import parseTransform from './transform';
import {ref, transform} from '../util';
import {error} from 'vega-util';

// TODO: facet, pre/post-transforms, reactive geometry
export default function parseMark(mark, scope) {
  var op, markRef, boundRef, key, params, enc, children;

  // add data join to map tuples to visual items
  op = scope.add(transform('DataJoin', {
    key:   mark.key ? scope.fieldRef(mark.key) : undefined,
    pulse: mark.from.$ref ? mark.from
            : ref(scope.getData(mark.from.data).output)
  }));

  // collect visual items, sort as requested
  op = scope.add(transform('Collect', {
    sort:  mark.sort ? scope.compareRef(mark.sort) : undefined,
    pulse: ref(op)
  }));

  // connect visual items to scenegraph
  markRef = ref(op = scope.add(transform('Mark', {
    markdef:   markDefinition(mark),
    scenepath: scope.scenepathNext(),
    pulse:     ref(op)
  })));

  // add visual encoders (if defined)
  if (mark.encode) {
    enc = {};
    params = {encoders: {$encode: enc}};
    for (key in mark.encode) {
      enc[key] = parseEncode(mark.encode[key], mark.type, params, scope);
    }
    params.pulse = markRef;
    op = scope.add(transform('Encode', params));
  }

  // post-encoding transforms
  if (mark.transform) {
    mark.transform.forEach(function(_) {
      var tx = parseTransform(_, scope);
      if (tx.metadata.generates) {
        error('Mark transforms should not generate new data.');
      }
      tx.params.pulse = ref(op);
      scope.add(op = tx);
    });
  }

  // recurse if group mark
  if (mark.type === 'group') {<commit_msg>Update comments for mark parser.<commit_after>import parseEncode from './encode';
import parseTransform from './transform';
import {ref, transform} from '../util';
import {error} from 'vega-util';

// TODO: facet, reactive geometry
export default function parseMark(mark, scope) {
  var op, markRef, boundRef, key, params, enc, children;

  // add data join to map tuples to visual items
  op = scope.add(transform('DataJoin', {
    key:   mark.key ? scope.fieldRef(mark.key) : undefined,
    pulse: mark.from.$ref ? mark.from
            : ref(scope.getData(mark.from.data).output)
  }));

  // collect visual items, sort as requested
  op = scope.add(transform('Collect', {
    sort:  mark.sort ? scope.compareRef(mark.sort) : undefined,
    pulse: ref(op)
  }));

  // connect visual items to scenegraph
  markRef = ref(op = scope.add(transform('Mark', {
    markdef:   markDefinition(mark),
    scenepath: scope.scenepathNext(),
    pulse:     ref(op)
  })));

  // add visual encoders (if defined)
  if (mark.encode) {
    enc = {};
    params = {encoders: {$encode: enc}};
    for (key in mark.encode) {
      enc[key] = parseEncode(mark.encode[key], mark.type, params, scope);
    }
    params.pulse = markRef;
    op = scope.add(transform('Encode', params));
  }

  // post-encoding transforms (if defined)
  if (mark.transform) {
    mark.transform.forEach(function(_) {
      var tx = parseTransform(_, scope);
      if (tx.metadata.generates) {
        error('Mark transforms should not generate new data.');
      }
      tx.params.pulse = ref(op);
      scope.add(op = tx);
    });
  }

  // recurse if group mark
  if (mark.type === 'group') {
{'fraction_non_alphanumeric': 0.15077202543142598, 'fraction_numerical': 0.0, 'mean_word_length': 3.034188034188034, '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': '4139591', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1039, 'n_words': 279}