/** * Consume an argument delimiter (a comma) from the token stream. * Only consumes if more arguments should exist (no ending parens or end of string). * * @return whether a delimiter was consumed * @throws ParseException */ protected boolean consumeArgumentDelimiter() throws ParseException { /* if a list of args is ending, don't expect the comma */ if (hasMoreArguments()) { sp.expect(","); return true; } return false; }
@Override public ValueSource parse(FunctionQParser fp) throws SyntaxError { String field=fp.parseArg(); // eg. cl_hi String featureString = fp.parseArg(); // System.out.println(featureString); byte[] hist= Base64.decodeBase64(featureString); // eg. FQY5DhMYDg0ODg0PEBEPDg4ODg8QEgsgEBAQEBAgEBAQEBA= double maxDistance = Double.MAX_VALUE; if (fp.hasMoreArguments()) { // if there is a third argument, it's the max value to return if there is none. Note the query cache is not updated upon parameter change. maxDistance = Double.parseDouble(fp.parseArg()); } return new LireValueSource(field, hist, maxDistance); } }
public ValueSource parse(FunctionQParser fp) throws ParseException { Query q = fp.parseNestedQuery(); float defVal = 0.0f; if (fp.hasMoreArguments()) { defVal = fp.parseFloat(); } return new QueryValueSource(q, defVal); }
private static ParamInfo parseTerm(FunctionQParser fp) throws SyntaxError { ParamInfo paramInfo = new ParamInfo(); paramInfo.field = fp.parseArg(); String textVal = fp.parseArg(); if(textVal == null || textVal.trim().length() == 0){ return paramInfo; } if(fp.hasMoreArguments()){ String similarity = fp.parseArg().toLowerCase().trim(); if( !similarity.equals(SimilarityType.DOC_LEN) && !similarity.equals(SimilarityType.PARAM_LEN) && !similarity.equals(SimilarityType.DICE) && !similarity.equals(SimilarityType.JACCARD)){ log.error(String.format("Invalid similarity class: %s. Defaulting to %s", similarity, SimilarityType.DOC_LEN)); similarity = SimilarityType.DOC_LEN; } paramInfo.similarity = similarity; } // need to do analysis on the term Analyzer analyzer = fp.getReq().getSchema().getIndexAnalyzer(); paramInfo.analyzer = analyzer; try { List<String> terms = TermExtractionHelper.getTermsFromString(analyzer, paramInfo.field, textVal); paramInfo.terms = new HashSet<String>(terms); } catch (IOException e) { SolrException.log(log, "Exception during debug", e); return null; } return paramInfo; }
public ValueSource parse(FunctionQParser fqp) throws SyntaxError{ ValueSource value1 = fqp.parseValueSource(); ValueSource value2 = fqp.parseValueSource(); String delimiter = null; if (fqp.hasMoreArguments()){ delimiter = fqp.parseArg(); } return new ConcatenateFunction(value1, value2, delimiter); } }
if(fp.hasMoreArguments()){ fieldInfo.useDocLength = fp.parseArg().toLowerCase().equals("true");
public ValueSource parse(FunctionQParser fp) throws ParseException { ValueSource source = fp.parseValueSource(); float min = fp.parseFloat(); float max = fp.parseFloat(); float target = fp.parseFloat(); Float def = fp.hasMoreArguments() ? fp.parseFloat() : null; return new RangeMapFloatFunction(source,min,max,target,def); }