Class UrlCharSequenceNormalizer

java.lang.Object
opennlp.tools.util.normalizer.UrlCharSequenceNormalizer
All Implemented Interfaces:
Serializable, opennlp.tools.util.normalizer.CharSequenceNormalizer

public class UrlCharSequenceNormalizer extends Object implements opennlp.tools.util.normalizer.CharSequenceNormalizer
A CharSequenceNormalizer implementation that normalizes text in terms of URls and email addresses. Every encounter will be replaced by a whitespace.

Normalization runs in two passes:

  1. URLs: a lowercase http:// or https:// scheme followed by at least one character out of the body set [-_.?&~;+=/#0-9A-Za-z] becomes one space; the match ends at the first character outside that set, so a colon (port), a percent escape, an at sign (userinfo), or a non-ASCII label cuts it short.
  2. Email addresses: a maximal run of the local-part set [-+_.0-9A-Za-z] whose left neighbor is outside that set, an @, and a domain run out of [-.0-9A-Za-z] that must not start with a dot and must span at least two chars, become one space.
See Also:
  • Constructor Details

    • UrlCharSequenceNormalizer

      public UrlCharSequenceNormalizer()
  • Method Details

    • getInstance

      public static UrlCharSequenceNormalizer getInstance()
      Returns the shared, stateless instance.
      Returns:
      the shared, stateless instance
    • normalize

      public CharSequence normalize(CharSequence text)
      Specified by:
      normalize in interface opennlp.tools.util.normalizer.CharSequenceNormalizer