<commit_before><?php

final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {

  const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';

  public function getPriority() {
    return 200.0;
  }

  public function apply($text) {
    // Grammar here is:
    //
    //         rule = '@{' maybe_type name maybe_title '}'
    //   maybe_type = null | type ':' | type '@' book ':'
    //         name = name | name '@' context
    //  maybe_title = null | '|' title
    //
    // So these are all valid:
    //
    //   @{name}
    //   @{type : name}
    //   @{name | title}
    //   @{type @ book : name @ context | title}

    return preg_replace_callback(
      '/(?:^|\B)@{'.
        '(?:(?P<type>[^:]+?):)?'.
        '(?P<name>[^}|]+?)'.
        '(?:[|](?P<title>[^}]+))?'.
      '}/',
      array($this, 'markupSymbol'),
      $text);
  }

  public function markupSymbol($matches) {
    if ($this->isTextFlat($matches[0])) {
      return $matches[0];
    }

    $type = (string)idx($matches, 'type');
    $name = (string)$matches['name'];
    $title = (string)idx($matches, 'title');

    // Collapse sequences of whitespace into a single space.
    $type = preg_replace('/\s+/', ' ', trim($type));<commit_msg>Fix bad method call name.<commit_after><?php

final class DivinerRemarkupRuleSymbol extends PhutilRemarkupRule {

  const KEY_RULE_ATOM_REF = 'rule.diviner.atomref';

  public function getPriority() {
    return 200.0;
  }

  public function apply($text) {
    // Grammar here is:
    //
    //         rule = '@{' maybe_type name maybe_title '}'
    //   maybe_type = null | type ':' | type '@' book ':'
    //         name = name | name '@' context
    //  maybe_title = null | '|' title
    //
    // So these are all valid:
    //
    //   @{name}
    //   @{type : name}
    //   @{name | title}
    //   @{type @ book : name @ context | title}

    return preg_replace_callback(
      '/(?:^|\B)@{'.
        '(?:(?P<type>[^:]+?):)?'.
        '(?P<name>[^}|]+?)'.
        '(?:[|](?P<title>[^}]+))?'.
      '}/',
      array($this, 'markupSymbol'),
      $text);
  }

  public function markupSymbol($matches) {
    if ($this->isFlatText($matches[0])) {
      return $matches[0];
    }

    $type = (string)idx($matches, 'type');
    $name = (string)$matches['name'];
    $title = (string)idx($matches, 'title');

    // Collapse sequences of whitespace into a single space.
    $type = preg_replace('/\s+/', ' ', trim($type));
{'fraction_non_alphanumeric': 0.21037581699346405, 'fraction_numerical': 0.004901960784313725, 'mean_word_length': 2.3005390835579513, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3107696', 'n_tokens_mistral': 865, 'n_tokens_neox': 830, 'n_words': 175}