<commit_before>package ed.appserver.templates.djang10;

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

import ed.js.JSFunction;
import ed.js.JSObject;
import ed.js.JSObjectBase;
import ed.js.JSString;
import ed.js.engine.Scope;
import ed.js.func.JSFunctionCalls1;
import ed.js.func.JSFunctionCalls2;

public class FilterExpression extends JSObjectBase {
    private Expression expression;
    private List<FilterSpec> filterSpecs;

    protected FilterExpression() {
        setConstructor(CONSTRUCTOR);
    }
    public FilterExpression(Parser parser, String filterExpression) throws TemplateException {
        this();
        init(parser, filterExpression);
    }
    private void init(Parser parser, String filterExpression) throws TemplateException {
        String[] parts = Parser.smartSplit(filterExpression.trim(), "|");

        this.expression = new Expression(parts[0]);
        this.filterSpecs = new ArrayList<FilterSpec>();
        

        for (int i = 1; i < parts.length; i++) {
            String[] filterParts = parts[i].split(":", 2);
            String filterNamePart = filterParts[0].trim();
            String filterParamPart = null;

            if (filterParts.length > 1)
                filterParamPart = filterParts[1].trim();

            JSFunction filter = parser.getFilters().get(filterNamePart);
            if(filter == null)
                throw new TemplateException("Unknow filter: " + filterNamePart);

            Expression filterParam = (filterParamPart == null) ? null : new Expression(filterParamPart);
            filterSpecs.add(new FilterSpec(filterNamePart, filter, filterParam));
        }

    }

    public boolean is_literal() {
        if(!this.expression.is_literal())
            return false;
        
        for(FilterSpec filterSpec : filterSpecs) {
            if(filterSpec.param != null && !filterSpec.param.is_literal())
                return false;
        }
        return true;
    }
    
    public Object get_literal_value() {
        if(!is_literal())<commit_msg>FilterExpression.java : fix typo in exception message<commit_after>package ed.appserver.templates.djang10;

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

import ed.js.JSFunction;
import ed.js.JSObject;
import ed.js.JSObjectBase;
import ed.js.JSString;
import ed.js.engine.Scope;
import ed.js.func.JSFunctionCalls1;
import ed.js.func.JSFunctionCalls2;

public class FilterExpression extends JSObjectBase {
    private Expression expression;
    private List<FilterSpec> filterSpecs;

    protected FilterExpression() {
        setConstructor(CONSTRUCTOR);
    }
    public FilterExpression(Parser parser, String filterExpression) throws TemplateException {
        this();
        init(parser, filterExpression);
    }
    private void init(Parser parser, String filterExpression) throws TemplateException {
        String[] parts = Parser.smartSplit(filterExpression.trim(), "|");

        this.expression = new Expression(parts[0]);
        this.filterSpecs = new ArrayList<FilterSpec>();
        

        for (int i = 1; i < parts.length; i++) {
            String[] filterParts = parts[i].split(":", 2);
            String filterNamePart = filterParts[0].trim();
            String filterParamPart = null;

            if (filterParts.length > 1)
                filterParamPart = filterParts[1].trim();

            JSFunction filter = parser.getFilters().get(filterNamePart);
            if(filter == null)
                throw new TemplateException("Unknown filter: " + filterNamePart);

            Expression filterParam = (filterParamPart == null) ? null : new Expression(filterParamPart);
            filterSpecs.add(new FilterSpec(filterNamePart, filter, filterParam));
        }

    }

    public boolean is_literal() {
        if(!this.expression.is_literal())
            return false;
        
        for(FilterSpec filterSpec : filterSpecs) {
            if(filterSpec.param != null && !filterSpec.param.is_literal())
                return false;
        }
        return true;
    }
    
    public Object get_literal_value() {
        if(!is_literal())
{'fraction_non_alphanumeric': 0.10434360592089299, 'fraction_numerical': 0.0048531909730647905, 'mean_word_length': 2.720216606498195, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, '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': '4822372', 'n_tokens_mistral': 1108, 'n_tokens_neox': 1079, 'n_words': 252}