Package opennlp.tools.util.normalizer
Class MailAddressScan
java.lang.Object
opennlp.tools.util.normalizer.MailAddressScan
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 Summary
FieldsModifier and TypeFieldDescriptionprivate static final charprivate static final CodePointSetThe set a domain continues with:[-.0-9A-Za-z].private static final CodePointSetThe set a domain may start with:[-0-9A-Za-z].private static final CodePointSetThe mail local-part set, also the left-neighbor exclusion set:[-+_.0-9A-Za-z].private static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisAddress(CharSequence text) Checks whether a whole text is one email address.(package private) static intmatchEnd(CharSequence text, int start) Finds the end of an email address that starts at an index.(package private) static CharSequenceremoveAll(CharSequence text) Replaces each email address with one space.
-
Field Details
-
MAIL_LOCAL
The mail local-part set, also the left-neighbor exclusion set:[-+_.0-9A-Za-z]. -
MAIL_DOMAIN_START
The set a domain may start with:[-0-9A-Za-z]. -
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
Checks whether a whole text is one email address.- Parameters:
text- The text to classify. Must not benull.- Returns:
trueif an address starts at index0and ends at the end oftext,falseotherwise, also for the empty text.- Throws:
IllegalArgumentException- Thrown iftextisnull.
-
removeAll
Replaces each email address with one space.- Parameters:
text- The text to scan. Must not benull.- Returns:
- The input itself when no address matched, otherwise the normalized copy.
-
matchEnd
Finds the end of an email address that starts at an index.- Parameters:
text- The text to look into. Must not benull.start- The index the address must start at, inside the text.- Returns:
- The exclusive end of the address, or
-1if none starts there.
-