Java Code Examples for com.googlecode.concurrenttrees.suffix.SuffixTree#put()
The following examples show how to use
com.googlecode.concurrenttrees.suffix.SuffixTree#put() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SuffixTreeUsage.java From concurrent-trees with Apache License 2.0 | 5 votes |
public static void main(String[] args) { System.out.println("Suffixes for 'TEST': " + Iterables.toString(CharSequences.generateSuffixes("TEST"))); System.out.println("Suffixes for 'TOAST': " + Iterables.toString(CharSequences.generateSuffixes("TOAST"))); System.out.println("Suffixes for 'TEAM': " + Iterables.toString(CharSequences.generateSuffixes("TEAM"))); SuffixTree<Integer> tree = new ConcurrentSuffixTree<Integer>(new DefaultCharArrayNodeFactory()); tree.put("TEST", 1); tree.put("TOAST", 2); tree.put("TEAM", 3); System.out.println(); System.out.println("Tree structure:"); // PrettyPrintable is a non-public API for testing, prints semi-graphical representations of trees... PrettyPrinter.prettyPrint((PrettyPrintable) tree, System.out); System.out.println(); System.out.println("Value for 'TEST' (exact match): " + tree.getValueForExactKey("TEST")); System.out.println("Value for 'TOAST' (exact match): " + tree.getValueForExactKey("TOAST")); System.out.println(); System.out.println("Keys ending with 'ST': " + Iterables.toString(tree.getKeysEndingWith("ST"))); System.out.println("Keys ending with 'M': " + Iterables.toString(tree.getKeysEndingWith("M"))); System.out.println("Values for keys ending with 'ST': " + Iterables.toString(tree.getValuesForKeysEndingWith("ST"))); System.out.println("Key-Value pairs for keys ending with 'ST': " + Iterables.toString(tree.getKeyValuePairsForKeysEndingWith("ST"))); System.out.println(); System.out.println("Keys containing 'TE': " + Iterables.toString(tree.getKeysContaining("TE"))); System.out.println("Keys containing 'A': " + Iterables.toString(tree.getKeysContaining("A"))); System.out.println("Values for keys containing 'A': " + Iterables.toString(tree.getValuesForKeysContaining("A"))); System.out.println("Key-Value pairs for keys containing 'A': " + Iterables.toString(tree.getKeyValuePairsForKeysContaining("A"))); }
Example 2
Source File: TypeUtils.java From baleen with Apache License 2.0 | 4 votes |
/** * For a given type name, look through the type system and return the matching class. If two types * of the same name (but different packages) exist, then null will be returned and the package * will need to be included in the typeName. * * @param typeName The name of the type, optionally including the package * @param typeSystem The type system to search * @return The class associated with that type */ @SuppressWarnings("unchecked") public static Class<AnnotationBase> getType(String typeName, TypeSystem typeSystem) { SuffixTree<Class<AnnotationBase>> types = new ConcurrentSuffixTree<>(new DefaultByteArrayNodeFactory()); Iterator<Type> itTypes = typeSystem.getTypeIterator(); while (itTypes.hasNext()) { Type t = itTypes.next(); Class<AnnotationBase> c; try { String clazz = t.getName(); if (clazz.startsWith("uima.")) { continue; } else if (clazz.endsWith("[]")) { clazz = clazz.substring(0, clazz.length() - 2); } Class<?> unchecked = Class.forName(clazz); if (AnnotationBase.class.isAssignableFrom(unchecked)) { c = (Class<AnnotationBase>) unchecked; types.put(t.getName(), c); } else { LOGGER.debug("Skipping class {} that doesn't inherit from AnnotationBase", clazz); } } catch (ClassNotFoundException e) { LOGGER.warn("Unable to load class {} from type system", t.getName(), e); } } Class<AnnotationBase> ret = getClassFromType("." + typeName, types); if (ret == null) { ret = getClassFromType(typeName, types); } if (ret == null) { LOGGER.warn("No uniquely matching class found for type {}", typeName); } return ret; }