TRE (computing)
TRE is an open-source library for pattern matching in text,[2] which works like a regular expression engine with the ability to do approximate string matching.[3] It was developed by Ville Laurikari[1] and is distributed under a 2-clause BSD-like license. The library[4] is written in C and provides functions which allow using regular expressions for searching over input text lines. The main difference from other regular expression engines is that TRE can match text fragments in an approximate way, that is, supposing that text could have some number of typos. FeaturesTRE uses extended regular expression syntax with the addition of "directions" for matching preceding fragment in approximate way. Each of such directions specifies how many typos are allowed for this fragment. Approximate matching[5] is performed in a way similar to Levenshtein distance, which means that there are three types of typos 'recognized':[6]
TRE allows specifying of cost for each of three typos type independently. The project comes with a command-line utility, a reimplementation of agrep. Though approximate matching requires some syntax extension, when this feature is not used, TRE works like most of other regular expression matching engines. This means that
Predictable time and memory consumptionThe library's author states[8] that time spent for matching grows linearly with increasing of input text length, while memory requirement is constant during matching and does not depend on the input, only on the pattern. OtherOther features, common for most regular expression engines could be checked in regex engines comparison tables or in list of TRE features on its web-page. Usage exampleApproximate matching directions are specified in curly brackets and should be distinguishable from repetitive quantifiers (possibly with inserting a space after opening bracket):
Language bindingsApart from C, TRE is usable through bindings for Perl, Python and Haskell.[9] It is the default regular expression engine in R.[10] However, if the project should be cross-platform, each target platform would need a separate interface. DisadvantagesSince other regular expression engines usually do not provide approximate matching ability, there is almost no concurrent implementation with which TRE could be compared. However, there are a few things which programmers may wish to see implemented in future releases:[11]
See alsoReferences
External linksFurther reading
|
Portal di Ensiklopedia Dunia