Class CHMStringDeduplicator

java.lang.Object
opennlp.tools.util.jvm.CHMStringDeduplicator
All Implemented Interfaces:
StringInterner

@Internal @ThreadSafe public class CHMStringDeduplicator extends Object implements StringInterner
A StringInterner implementation by Aleksey Shipilëv with relaxed canonical requirements. It is a probabilistic deduplication implementation with a default probability of 0.5. Users may implement a custom class with a different probability value.

Origin: https://shipilev.net/talks/joker-Oct2014-string-catechism.pdf

  • Constructor Details

    • CHMStringDeduplicator

      public CHMStringDeduplicator()
      Creates a CHMStringDeduplicator with a probability of 0.5.
    • CHMStringDeduplicator

      public CHMStringDeduplicator(double prob)
      Parameters:
      prob - represents the probability, that a given String will be interned
  • Method Details

    • intern

      public String intern(String sample)
      Interns and returns a reference to the representative instance for any collection of string instances that are equal to each other.
      Specified by:
      intern in interface StringInterner
      Parameters:
      sample - string instance to be interned
      Returns:
      reference to the interned string instance