<commit_before>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import StringConvert from 'grommet/utils/StringConvert';

const TRACE_PARSING = false;
// don't convert timestamps, MAC addresses, or WWNs to attribute:value
// This pattern matches the name: ^[^\d:'"\s]{2}[^:'"\s]+
// We allow for the value to be optionally be quoted. So, we repeat the name
// pattern three times, once for single quoted value, once for double quoted
// value, and lastly with no quotes.
// We don't build this programmatically for better performance.
const ATTRIBUTE_PATTERN = new RegExp([
  `^[^\d:'"\s]{1}[^:'"\s]*:'[^']+'`,
  `^[^\d:'"\s]{1}[^:'"\s]*:"[^"]+"`,
  `^[^\d:'"\s]{1}[^:'"\s]*:[^'"\s]+`].join('|'));
// allow for text to contain quotes
const TEXT_PATTERN = /^[^'"\s]+|^'[^']+'|^"[^"]+"/;

function addTerm (expression, term) {
  if (! expression.left) {
    expression.left = term;
  } else if (! expression.right) {
    expression.right = term;
    if (! expression.op) {
      if (term.name && expression.left && expression.left.name === term.name) {
        setOp(expression, 'OR');
      } else {
        setOp(expression, 'AND');
      }
    }
  } else {
    // We already have a left and a right.
    // If the right is a simple term, convert it to an expression.
    if (! expression.right.left) {
      let expression2 = {};
      addTerm(expression2, expression.right);
      expression.right = expression2;<commit_msg>Fixed attribute pattern<commit_after>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

import StringConvert from 'grommet/utils/StringConvert';

const TRACE_PARSING = false;
// don't convert timestamps, MAC addresses, or WWNs to attribute:value
// This pattern matches the name: ^[^\d:'"\s]{2}[^:'"\s]+
// We allow for the value to be optionally be quoted. So, we repeat the name
// pattern three times, once for single quoted value, once for double quoted
// value, and lastly with no quotes.
// We don't build this programmatically for better performance.
const ATTRIBUTE_PATTERN = new RegExp([
  `^[^\\d:'"\\s]{1}[^:'"\\s]*:'[^']+'`,
  `^[^\\d:'"\\s]{1}[^:'"\\s]*:"[^"]+"`,
  `^[^\\d:'"\\s]{1}[^:'"\\s]*:[^'"\\s]+`].join('|'));
// allow for text to contain quotes
const TEXT_PATTERN = /^[^'"\s]+|^'[^']+'|^"[^"]+"/;

function addTerm (expression, term) {
  if (! expression.left) {
    expression.left = term;
  } else if (! expression.right) {
    expression.right = term;
    if (! expression.op) {
      if (term.name && expression.left && expression.left.name === term.name) {
        setOp(expression, 'OR');
      } else {
        setOp(expression, 'AND');
      }
    }
  } else {
    // We already have a left and a right.
    // If the right is a simple term, convert it to an expression.
    if (! expression.right.left) {
      let expression2 = {};
      addTerm(expression2, expression.right);
      expression.right = expression2;
{'fraction_non_alphanumeric': 0.1928620452985587, 'fraction_numerical': 0.01029512697323267, 'mean_word_length': 3.3057607090103396, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4641857', 'n_tokens_mistral': 970, 'n_tokens_neox': 936, 'n_words': 285}