Class MailAddressScan

java.lang.Object
opennlp.tools.util.normalizer.MailAddressScan

@Internal public final class MailAddressScan extends Object
Finds email addresses in text for UrlCharSequenceNormalizer and classifies whole tokens as email addresses. An address is a maximal run of the local-part set [-+_.0-9A-Za-z] with a left neighbor outside that set, an @, and a domain run out of [-.0-9A-Za-z] that does not start with a dot and spans at least two chars.
  • Field Details

    • MAIL_LOCAL

      private static final CodePointSet MAIL_LOCAL
      The mail local-part set, also the left-neighbor exclusion set: [-+_.0-9A-Za-z].
    • MAIL_DOMAIN_START

      private static final CodePointSet MAIL_DOMAIN_START
      The set a domain may start with: [-0-9A-Za-z].
    • MAIL_DOMAIN

      private static final CodePointSet MAIL_DOMAIN
      The set a domain continues with: [-.0-9A-Za-z].
    • AT

      private static final char AT
      See Also:
    • MIN_DOMAIN_LENGTH

      private static final int MIN_DOMAIN_LENGTH
      See Also:
  • Constructor Details

    • MailAddressScan

      private MailAddressScan()
  • Method Details

    • isAddress

      public static boolean isAddress(CharSequence text)
      Checks whether a whole text is one email address.
      Parameters:
      text - The text to classify. Must not be null.
      Returns:
      true if an address starts at index 0 and ends at the end of text, false otherwise, also for the empty text.
      Throws:
      IllegalArgumentException - Thrown if text is null.
    • removeAll

      static CharSequence removeAll(CharSequence text)
      Replaces each email address with one space.
      Parameters:
      text - The text to scan. Must not be null.
      Returns:
      The input itself when no address matched, otherwise the normalized copy.
    • matchEnd

      static int matchEnd(CharSequence text, int start)
      Finds the end of an email address that starts at an index.
      Parameters:
      text - The text to look into. Must not be null.
      start - The index the address must start at, inside the text.
      Returns:
      The exclusive end of the address, or -1 if none starts there.