/** * Create set with enough capacity to hold startSize terms * * @param startSize * the initial capacity * @param ignoreCase * <code>false</code> if and only if the set should be case sensitive * otherwise <code>true</code>. */ public CharArraySet(int startSize, boolean ignoreCase) { this(new CharArrayMap<>(startSize, ignoreCase)); }
/** * Assign an {@link Analyzer} to be used with that key. That analyzer is used * to process tokens outputed from the {@link TupleTokenizer}. * @param datatype the Datatype * @param a the associated {@link Analyzer} */ public void registerDatatype(final char[] datatype, final Analyzer a) { if (!regLitAnalyzers.containsKey(datatype)) { regLitAnalyzers.put(datatype, a); } }
/** * Remove all registered Datatype {@link Analyzer}s. */ public void clearDatatypes() { regLitAnalyzers.clear(); }
private int getSlot(char[] text, int off, int len) { int code = getHashCode(text, off, len); int pos = code & (keys.length-1); char[] text2 = keys[pos]; if (text2 != null && !equals(text, off, len, text2)) { final int inc = ((code>>8)+code)|1; do { code += inc; pos = code & (keys.length-1); text2 = keys[pos]; } while (text2 != null && !equals(text, off, len, text2)); } return pos; }
CharArrayMap<DictEntry> d = new CharArrayMap<>(1000, false); for (int i = 0; i < exceptionWords.length; i++) { if (!d.containsKey(exceptionWords[i])) { entry = new DictEntry(exceptionWords[i], true); d.put(exceptionWords[i], entry); } else { throw new RuntimeException("Warning: Entry [" + exceptionWords[i] if (!d.containsKey(directConflations[i][0])) { entry = new DictEntry(directConflations[i][1], false); d.put(directConflations[i][0], entry); } else { throw new RuntimeException("Warning: Entry [" + directConflations[i][0] if (!d.containsKey(countryNationality[i][0])) { entry = new DictEntry(countryNationality[i][1], false); d.put(countryNationality[i][0], entry); } else { throw new RuntimeException("Warning: Entry [" + countryNationality[i][0] if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new RuntimeException("Warning: Entry [" + array[i] if (!d.containsKey(array[i])) { d.put(array[i], defaultEntry); } else { throw new RuntimeException("Warning: Entry [" + array[i]
/** Add this CharSequence into the set */ public boolean add(CharSequence text) { return map.put(text, PLACEHOLDER) == null; }
@Override public String toString() { final StringBuilder sb = new StringBuilder("{"); for (Map.Entry<Object,V> entry : entrySet()) { if (sb.length()>1) sb.append(", "); sb.append(entry); } return sb.append('}').toString(); }
/** true if the <code>CharSequence</code> is in the set */ public boolean contains(CharSequence cs) { return map.containsKey(cs); }
if (!dtsAnalyzer.containsKey(dt)) { throw new IOException("Unregistered datatype [" + new String(dt) + "]. Use the #register method."); final Analyzer analyzer = dtsAnalyzer.get(dt); if (reusableCharArray == null) { reusableCharArray = new ReusableCharArrayReader(termAtt.buffer(), 0, termAtt.length());
public static <V> CharArrayMap<V> copy(final Map<?,? extends V> map) { if(map == EMPTY_MAP) return emptyMap(); if(map instanceof CharArrayMap) { CharArrayMap<V> m = (CharArrayMap<V>) map; final V[] values = (V[]) new Object[m.values.length]; System.arraycopy(m.values, 0, values, 0, values.length); m = new CharArrayMap<>(m); m.keys = keys; m.values = values; return new CharArrayMap<V>(map, false);
public DutchAnalyzer(CharArraySet stopwords, CharArraySet stemExclusionTable, CharArrayMap<String> stemOverrideDict) { this.stoptable = CharArraySet.unmodifiableSet(CharArraySet.copy(stopwords)); this.excltable = CharArraySet.unmodifiableSet(CharArraySet.copy(stemExclusionTable)); if (stemOverrideDict.isEmpty()) { this.stemdict = null; } else { // we don't need to ignore case here since we lowercase in this analyzer anyway StemmerOverrideFilter.Builder builder = new StemmerOverrideFilter.Builder(false); CharArrayMap<String>.EntryIterator iter = stemOverrideDict.entrySet().iterator(); CharsRefBuilder spare = new CharsRefBuilder(); while (iter.hasNext()) { char[] nextKey = iter.nextKey(); spare.copyChars(nextKey, 0, nextKey.length); builder.add(spare.get(), iter.currentValue()); } try { this.stemdict = builder.build(); } catch (IOException ex) { throw new RuntimeException("can not build stem dict", ex); } } }
/** * Returns an unmodifiable {@link CharArrayMap}. This allows to provide * unmodifiable views of internal map for "read-only" use. * * @param map * a map for which the unmodifiable map is returned. * @return an new unmodifiable {@link CharArrayMap}. * @throws NullPointerException * if the given map is <code>null</code>. */ public static <V> CharArrayMap<V> unmodifiableMap(CharArrayMap<V> map) { if (map == null) throw new NullPointerException("Given map is null"); if (map == emptyMap() || map.isEmpty()) return emptyMap(); if (map instanceof UnmodifiableCharArrayMap) return map; return new UnmodifiableCharArrayMap<V>(map); }
@Override public final EntrySet entrySet() { if (entrySet == null) { entrySet = createEntrySet(); } return entrySet; }
/** * Returns a copy of the given set as a {@link CharArraySet}. If the given set * is a {@link CharArraySet} the ignoreCase property will be preserved. * * @param set * a set to copy * @return a copy of the given set as a {@link CharArraySet}. If the given set * is a {@link CharArraySet} the ignoreCase property as well as the * matchVersion will be of the given set will be preserved. */ public static CharArraySet copy(final Set<?> set) { if(set == EMPTY_SET) return EMPTY_SET; if(set instanceof CharArraySet) { final CharArraySet source = (CharArraySet) set; return new CharArraySet(CharArrayMap.copy(source.map)); } return new CharArraySet(set, false); }
/** Add this String into the set */ public boolean add(String text) { return map.put(text, PLACEHOLDER) == null; }
@Override public String toString() { final StringBuilder sb = new StringBuilder("{"); for (Map.Entry<Object,V> entry : entrySet()) { if (sb.length()>1) sb.append(", "); sb.append(entry); } return sb.append('}').toString(); }
/** true if the <code>len</code> chars of <code>text</code> starting at <code>off</code> * are in the set */ public boolean contains(char[] text, int off, int len) { return map.containsKey(text, off, len); }
if (!dtsAnalyzer.containsKey(dt)) { throw new IOException("Unregistered datatype [" + new String(dt) + "]. Use the #register method."); final Analyzer analyzer = dtsAnalyzer.get(dt); if (reusableCharArray == null) { reusableCharArray = new ReusableCharArrayReader(termAtt.buffer(), 0, termAtt.length());
public static <V> CharArrayMap<V> copy(final Map<?,? extends V> map) { if(map == EMPTY_MAP) return emptyMap(); if(map instanceof CharArrayMap) { CharArrayMap<V> m = (CharArrayMap<V>) map; final V[] values = (V[]) new Object[m.values.length]; System.arraycopy(m.values, 0, values, 0, values.length); m = new CharArrayMap<V>(m); m.keys = keys; m.values = values; return m; return new CharArrayMap<V>(map, false);