/** Appends the index prefix if necessary and delegates to the subclass */ protected final void appendBodyString(StringBuilder buffer) { appendIndexString(buffer); buffer.append(stringValue()); }
/** Returns a non-null replacement term if there is a match, null otherwise */ private String termMatches(TermItem queryTerm,boolean stemming){ String queryTermString=queryTerm.stringValue(); // The terms are the same boolean matches=queryTermString.equals(term); if (matches) return term; if (stemming) if (termMatchesWithStemming(queryTermString)) return term; return null; }
private StringBuilder getStringContents(Item item) { if (item instanceof TermItem) { return new StringBuilder( ((TermItem) item).stringValue()); } else if (item instanceof SegmentItem) { return new StringBuilder( ((SegmentItem) item).getRawWord()); } else { throw new RuntimeException("Parser bug. Unexpected item type, send stack trace in a bug ticket to the Vespa team."); } }
@Override public void disclose(Discloser discloser) { super.disclose(discloser); discloser.addProperty("origin", origin); discloser.setValue(stringValue()); }
private String matchTerms(int numberOfTerms,RuleEvaluation e) { StringBuilder b=new StringBuilder(); for (int i=0; i<numberOfTerms; i++) { e.addMatch(e.currentItem(),e.currentItem().getItem().getIndexedString()); b.append(e.currentItem().getItem().stringValue()); if (i<(numberOfTerms-1)) b.append(" "); e.next(); } return b.toString(); }
/** Returns null if this word does not match the automaton, a single-item list if it does */ private List<Phrase> matchSingleItem(TermItem termItem) { String matchWord=toLowerCase(termItem.stringValue()); String replaceWord=null; FSA.State state = phraseFSA.getState(); if (!matches(state,matchWord)) { if (!ignorePluralForm) return null; matchWord=switchForm(matchWord); if (!matches(state,matchWord)) return null; replaceWord=matchWord; } List<Phrase> itemList=new java.util.ArrayList<>(1); itemList.add(new Phrase(termItem,replaceWord,state.dataString())); return itemList; }
if (!termItem.getIndexName().equals(index)) break; String lowercased = toLowerCase(termItem.stringValue()); boolean matched=state.tryDeltaWord(lowercased); if (!matched && ignorePluralForm) {
private boolean rewriteToNGramMatching(Item item, int indexInParent, IndexFacts.Session indexFacts, Query query) { boolean rewritten = false; if (item instanceof SegmentItem) { // handle CJK segmented terms which should be grams instead SegmentItem segments = (SegmentItem)item; Index index = indexFacts.getIndex(segments.getIndexName()); if (index.isNGram()) { Item grams = splitToGrams(segments, toLowerCase(segments.getRawWord()), index.getGramSize(), query); replaceItemByGrams(item, grams, indexInParent); rewritten = true; } } else if (item instanceof CompositeItem) { CompositeItem composite = (CompositeItem)item; for (int i=0; i<composite.getItemCount(); i++) rewritten = rewriteToNGramMatching(composite.getItem(i), i, indexFacts, query) || rewritten; } else if (item instanceof TermItem) { TermItem term = (TermItem)item; Index index = indexFacts.getIndex(term.getIndexName()); if (index.isNGram()) { Item grams = splitToGrams(term,term.stringValue(), index.getGramSize(), query); replaceItemByGrams(item, grams, indexInParent); rewritten = true; } } return rewritten; }
if (starAfterFirst) { if (starBeforeFirst) { return new SubstringItem(firstTerm.stringValue(), true); } else { return new PrefixItem(firstTerm.stringValue(), true); return new SuffixItem(firstTerm.stringValue(), true);