Class PrefixAccumulator<E>

java.lang.Object
org.aksw.jenax.arq.analytics.PrefixAccumulator<E>
All Implemented Interfaces:
Serializable, org.aksw.commons.collector.domain.Accumulator<String,E,Set<String>>

public class PrefixAccumulator<E> extends Object implements org.aksw.commons.collector.domain.Accumulator<String,E,Set<String>>, Serializable
Class for accumulating a set of prefixes with a specified target size from a set of strings
Author:
raven
See Also:
  • Field Details

    • prefixes

      protected org.apache.commons.collections4.trie.PatriciaTrie<Long> prefixes
    • targetSize

      protected int targetSize
    • pattern

      public static final Pattern pattern
  • Constructor Details

    • PrefixAccumulator

      public PrefixAccumulator(int targetSize)
  • Method Details

    • getValue

      public Set<String> getValue()
      Specified by:
      getValue in interface org.aksw.commons.collector.domain.Accumulator<String,E,Set<String>>
    • defaultGrouper

      public static String defaultGrouper(String prefix)
    • flatMapMapValues

      public static <T> Set<T> flatMapMapValues(Map<?,? extends Collection<T>> map)
    • commonPrefix

      public static String commonPrefix(String sa, String sb, boolean skipLast)
      Returns the common prefix of the given strings
      Returns:
    • longestPrefixLookup

      public static String longestPrefixLookup(String lookup, boolean inclusive, SortedMap<String,?> prefixes)
      For a given lookup string find a string in a sorted map that is the longest prefix of the lookup string. There is a suggestion for longest common prefix match could be performed efficiently: https://github.com/rkapsi/patricia-trie/issues/5
      Parameters:
      lookup -
      inclusive -
      prefixes -
      Returns:
    • longestCommonPrefix

      public static String longestCommonPrefix(org.apache.commons.collections4.trie.PatriciaTrie<?> trie)
      It sucks that lcp is not part of the public trie api ...
      Parameters:
      trie -
      Returns:
    • removeSuperseded

      public void removeSuperseded(String prefix)
    • accumulate

      public void accumulate(String prefix, E env)
      Specified by:
      accumulate in interface org.aksw.commons.collector.domain.Accumulator<String,E,Set<String>>
    • main

      public static void main(String[] args)