Abstract
Regular expressions have served as the dominant workhorse of practical information extraction for several years. However, there has been little work on reducing the manual effort involved in building high-quality, complex regular expressions for information extraction tasks. In this paper, we propose ReLIE, a novel transformation-based algorithm for learning such complex regular expressions. We evaluate the performance of our algorithm on multiple datasets and compare it against the CRF algorithm. We show that ReLIE, in addition to being an order of magnitude faster, outperforms CRF under conditions of limited training data and cross-domain data. Finally, we show how the accuracy of CRF can be improved by using features extracted by ReLIE.
Introduction
Information Extraction (IE) relies heavily on regular expressions (regexes) to identify structured data—such as phone numbers, URLs, or software names—within unstructured text. Despite their ubiquity, crafting high-performance regexes remains a manual, error-prone "dark art." A simple pattern often suffers from low precision by capturing irrelevant strings or low recall by missing valid variations.
While machine learning approaches like Conditional Random Fields (CRFs) have gained popularity, they typically require large labeled datasets and struggle with domain shifts. Furthermore, CRFs often operate at the token level, potentially overlooking fine-grained character-level patterns. To address these challenges, we introduce ReLIE (Regular Expression Learning for Information Extraction), a transformation-based algorithm that automates the refinement of complex regexes from simple user-provided seeds.
Methodology
ReLIE adopts a refinement-based approach rather than building regexes from scratch. The process begins with a human-provided seed regex, which serves as a high-recall starting point. The algorithm then explores a search space of candidate regexes that are stricter versions of this seed.
Atomic Transformations
ReLIE navigates the search space using three primary transformation types:
- Character Class Restrictions: Broad classes (e.g.,
\w) are replaced with narrower ones (e.g.,[a-z]) based on a predefined hierarchy. - Quantifier Restrictions: General quantifiers like
+(one or more) are constrained to specific ranges, such as{3,5}. - Negative Dictionaries: The algorithm automatically identifies strings frequently matched by the seed but never present in the ground truth (e.g., "Copyright" in a software name task) and incorporates negative lookaheads to exclude them.
The algorithm employs a greedy hill-climbing search, selecting transformations that maximize the F-measure on training data while utilizing a validation set to mitigate overfitting.
Experimental Evaluation
We evaluated ReLIE across four extraction tasks: Software Names, Course Numbers, Phone Numbers, and URLs. These tasks were performed on three real-world datasets:
- EWeb: 50,000 corporate intranet pages.
- AWeb: 50,000 pages from a university web collection.
- Email: 10,000 emails from the Enron corpus.
Results and Discussion
ReLIE demonstrates significant advantages over CRFs in terms of data efficiency, robustness, and computational speed.
Data Efficiency and Performance
A key strength of ReLIE is its performance with limited training data. When trained on only 10% of the available data, ReLIE outperformed CRFs in three out of four tasks. By leveraging character-level structures, ReLIE can distinguish between similar patterns (e.g., identifying a course number vs. a general alphanumeric string) more effectively than token-based models.
Domain Robustness and Speed
In cross-domain evaluations (e.g., training on web data and testing on emails), ReLIE's structural patterns proved more universal than the vocabulary-dependent features of CRFs. While CRF performance often dropped sharply in new domains, ReLIE remained stable. Additionally, ReLIE is an order of magnitude faster; in one instance, training took approximately 511 seconds compared to over 7,500 seconds for the CRF.
Furthermore, the learned regexes can serve as powerful features for CRFs, leading to a hybrid approach that surpasses the performance of either method alone.
Conclusion
ReLIE offers a robust and efficient solution for automating regex development in IE tasks. Its primary limitation is the "subset assumption," which prevents the algorithm from expanding a seed regex that already has low recall. Future research will explore relaxing this constraint to allow for generalization transformations and deeper integration into hybrid machine learning pipelines.
Summary updated