Package opennlp.tools.util.jvm

# 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 Summary

  Constructors
  Constructor
  Description
  `CHMStringDeduplicator()`
  Creates a `CHMStringDeduplicator` with a probability of `0.5`.
  `CHMStringDeduplicator(double prob)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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