List of usage examples for org.apache.lucene.util CharsRef CharsRef
public CharsRef(char[] chars, int offset, int length)
From source file:elhuyar.bilakit.Stemmer.java
License:Apache License
private CharsRef newStem(char buffer[], int length, IntsRef forms, int formID) { final String exception; if (dictionary.hasStemExceptions) { int exceptionID = forms.ints[forms.offset + formID + 1]; if (exceptionID > 0) { exception = dictionary.getStemException(exceptionID); } else {/* w ww.j av a 2 s . c o m*/ exception = null; } } else { exception = null; } if (dictionary.needsOutputCleaning) { scratchSegment.setLength(0); if (exception != null) { scratchSegment.append(exception); } else { scratchSegment.append(buffer, 0, length); } try { Dictionary.applyMappings(dictionary.oconv, scratchSegment); } catch (IOException bogus) { throw new RuntimeException(bogus); } char cleaned[] = new char[scratchSegment.length()]; scratchSegment.getChars(0, cleaned.length, cleaned, 0); return new CharsRef(cleaned, 0, cleaned.length); } else { if (exception != null) { return new CharsRef(exception); } else { return new CharsRef(buffer, 0, length); } } }
From source file:stemmer.Stemmer.java
License:Apache License
private CharsRef newStem(char buffer[], int length) { if (dictionary.needsOutputCleaning) { scratchSegment.setLength(0);/* w w w .j a va2 s .com*/ scratchSegment.append(buffer, 0, length); try { Dictionary.applyMappings(dictionary.oconv, scratchSegment); } catch (IOException bogus) { throw new RuntimeException(bogus); } char cleaned[] = new char[scratchSegment.length()]; scratchSegment.getChars(0, cleaned.length, cleaned, 0); return new CharsRef(cleaned, 0, cleaned.length); } else { return new CharsRef(buffer, 0, length); } }