<commit_before>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.addthis.hydra.data.query.op;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.addthis.basis.util.LessStrings;

import com.addthis.bundle.core.Bundle;
import com.addthis.bundle.util.ValueUtil;
import com.addthis.bundle.value.ValueFactory;
import com.addthis.bundle.value.ValueObject;
import com.addthis.hydra.data.query.AbstractRowOp;

import io.netty.channel.ChannelProgressivePromise;


/**
 * <p>This query operation <span class="hydra-summary">performs postfix (RPN)
 * calculator string operations</span>.
 * <p/>
 * <p>This filter uses a calculation stack to perform string operations. The stack is initially empty
 * and values can be pushed or popped from the top of the stack. String operations can be performed
 * on the element(s) at the top of the stack.
 * <pre style="font-family:courier;font-size:15px">
 * num=OP,OP,OP,...
 * <p/>
 * OP         := LOAD_OP | CALC_OP
 * LOAD_OP    :=  LOAD_COL | LOAD_VAL
 * LOAD_COL   := ("c" | "col" ) INT
 * LOAD_VAL   := ("v" | "val" ) STRING
 * CALC_OP    := [see table for operations]
 * INT        := DIGIT+
 * DIGIT      := ["0" - "9"]</pre>
 * <p/>
 * <p>The following operations below are available. Each operation proceeds in three steps:
 * (1) Zero or more values are popped off the stack, (2) an operation is performed on these values,
 * and (3) zero or more values are pushed onto the stack. For convenience the following table
 * labels the first element popped off the stack as "a" (the topmost element), the second
 * element as "b", etc. The variables "X","Y","Z", etc. represent numbers in the command sequence.
 * <p/>
 * <table width="80%" class="num">
 * <tr>
 * <th width="15%">name</th>
 * <th width="10%">pop count</th>
 * <th width="65%">operation</th>
 * <th width="10%">push count</th>
 * </tr>
 * <tr>
 * <td>"cat" or "+"</td>
 * <td>2</td>
 * <td>concatenate two strings</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"range" or ":"</td>
 * <td>3</td>
 * <td>take the range of string c from offset a to offset b</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"split" or "/"</td>
 * <td>3</td>
 * <td>split string c using separator b and push element number a from the result</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"set" or "="</td>
 * <td>2</td>
 * <td>set column a to string b</td>
 * <td>0</td>
 * </tr>
 * <tr>
 * <td>"eq" or "=="</td>
 * <td>2</td>
 * <td>if string equality is false then end the calculation</td>
 * <td>0</td>
 * </tr><commit_msg>Fixed range docstring to correspond to code<commit_after>/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.addthis.hydra.data.query.op;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.addthis.basis.util.LessStrings;

import com.addthis.bundle.core.Bundle;
import com.addthis.bundle.util.ValueUtil;
import com.addthis.bundle.value.ValueFactory;
import com.addthis.bundle.value.ValueObject;
import com.addthis.hydra.data.query.AbstractRowOp;

import io.netty.channel.ChannelProgressivePromise;


/**
 * <p>This query operation <span class="hydra-summary">performs postfix (RPN)
 * calculator string operations</span>.
 * <p/>
 * <p>This filter uses a calculation stack to perform string operations. The stack is initially empty
 * and values can be pushed or popped from the top of the stack. String operations can be performed
 * on the element(s) at the top of the stack.
 * <pre style="font-family:courier;font-size:15px">
 * num=OP,OP,OP,...
 * <p/>
 * OP         := LOAD_OP | CALC_OP
 * LOAD_OP    :=  LOAD_COL | LOAD_VAL
 * LOAD_COL   := ("c" | "col" ) INT
 * LOAD_VAL   := ("v" | "val" ) STRING
 * CALC_OP    := [see table for operations]
 * INT        := DIGIT+
 * DIGIT      := ["0" - "9"]</pre>
 * <p/>
 * <p>The following operations below are available. Each operation proceeds in three steps:
 * (1) Zero or more values are popped off the stack, (2) an operation is performed on these values,
 * and (3) zero or more values are pushed onto the stack. For convenience the following table
 * labels the first element popped off the stack as "a" (the topmost element), the second
 * element as "b", etc. The variables "X","Y","Z", etc. represent numbers in the command sequence.
 * <p/>
 * <table width="80%" class="num">
 * <tr>
 * <th width="15%">name</th>
 * <th width="10%">pop count</th>
 * <th width="65%">operation</th>
 * <th width="10%">push count</th>
 * </tr>
 * <tr>
 * <td>"cat" or "+"</td>
 * <td>2</td>
 * <td>concatenate two strings</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"range" or ":"</td>
 * <td>3</td>
 * <td>take the range of string c from offset b to offset a</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"split" or "/"</td>
 * <td>3</td>
 * <td>split string c using separator b and push element number a from the result</td>
 * <td>1</td>
 * </tr>
 * <tr>
 * <td>"set" or "="</td>
 * <td>2</td>
 * <td>set column a to string b</td>
 * <td>0</td>
 * </tr>
 * <tr>
 * <td>"eq" or "=="</td>
 * <td>2</td>
 * <td>if string equality is false then end the calculation</td>
 * <td>0</td>
 * </tr>
{'fraction_non_alphanumeric': 0.1569521328557473, 'fraction_numerical': 0.010094431781178768, 'mean_word_length': 3.6643887623386484, 'pattern_counts': {'":': 2, '<': 147, '<?xml version=': 0, '>': 147, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1117113', 'n_tokens_mistral': 2081, 'n_tokens_neox': 2034, 'n_words': 711}