Java Reference
In-Depth Information
Using regular expressions for NER
Regular expressions can be used to identify entities in a document. We will investigate two
general approaches:
• The first one uses regular expressions as supported by Java. These can be useful in
situations where the entities are relatively simple and consistent in their form.
• The second approach uses classes designed to specifically use regular expressions.
To demonstrate this, we will use LingPipe's RegExChunker class.
When working with regular expressions, it is advantageous to avoid reinventing the wheel.
There are many sources for predefined and tested expressions. One such library can be
found at http://regexlib.com/Default.aspx . We will use several of the regular expressions in
this library for our examples.
To test how well these approaches work, we will use the following text for most of our ex-
amples:
private static String regularExpressionText
= "He left his email address (rgb@colorworks.com) and
his "
+ "phone number,800-555-1234. We believe his current
address "
+ "is 100 Washington Place, Seattle, CO 12345-1234. I "
+ "understand you can also call at 123-555-1234 between "
+ "8:00 AM and 4:30 most days. His URL is
http://example.com "
+ "and he was born on February 25, 1954 or 2/25/1954.";
Search WWH ::




Custom Search