ArticleslgStudy

computer science

TRE (computing)

TRE (computing) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand TRE (computing) rather than just read about it. In short: TRE is an open-source library for pattern matching in text, which works like a regular expression engine with the ability to do approximate string matching. It was developed by Ville Laurikari and is distributed under a 2-clause BSD-like license.

Key takeaways

  • TRE (computing) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect TRE (computing) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of TRE (computing) from memory before moving on to harder problems.

Reference excerpt

TRE is an open-source library for pattern matching in text, which works like a regular expression engine with the ability to do approximate string matching. It was developed by Ville Laurikari and is distributed under a 2-clause BSD-like license. The library 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.

Features TRE 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 is performed in a way similar to Levenshtein distance, which means that there are three types of typos 'recognized':

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

it implements ordinary regular expressions written for strict matching; programmers familiar with POSIX-style regular expressions need not do much study to be able to use TRE.

Predictable time and memory consumption The library's author states 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.

Other Other 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 example Approximate matching directions are specified in curly brackets and should be distinguishable from repetitive quantifiers (possibly with inserting a space after opening bracket):

(regular){~1}\s+(expression){~2} would match variants of phrase "regular expression" in which "regular" have no more than one typo and "expression" no more than two; as in ordinary regular expressions "\s+" means one or more space characters — i.e. would pass test; (expression){ 5i + 3d + 2s < 11} would match word "expression" if total cost of typos is less than 11, while insertion cost is set to 5, deletion to 3 and substitution of character to 2 - i.e. ekspresson gives cost of 10.

Language bindings Apart from C, TRE is usable through bindings for Perl, Python and Haskell. It is the default regular expression engine in R. However, if the project should be cross-platform, each target platform would need a separate interface.

Disadvantages Since 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:

a replacement mechanism for substituting matched text fragments (like in sed string processor and many modern implementations of regular expressions, including built into Perl or Java); opportunity to use another approximate matching algorithm (than Levenshtein's) for better typo value assessment (for example Soundex), or at least this algorithm to be improved to allow typos of the "swap" type (see Damerau–Levenshtein distance).

See also Levenshtein automaton Comparison of regular expression engines Agrep

References

External links TRE - The free and portable approximate regular expression matching library

Further reading Navarro, Gonzalo (March 2001), "A guided tour to approximate string matching", ACM Computing Surveys, 33 (1): 31–88, CiteSeerX 10.1.1.452.6317, doi:10.1145/375360.375365, S2CID 207551224 {{citation}}: Cite uses deprecated parameter |citeseerx= (help)

Worked examples

Example 1 — a first encounter with TRE (computing)

Start with the simplest possible case. Write down what TRE (computing) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to TRE (computing) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about TRE (computing) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of TRE (computing)

In research
TRE (computing) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses TRE (computing) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
TRE (computing) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Computer libraries, Regular expressions, Software using the BSD license, so understanding it makes those chapters shorter.
In everyday life
Look for TRE (computing) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “TRE (computing)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study TRE (computing) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what TRE (computing) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain TRE (computing) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is TRE (computing) in simple terms?

TRE is an open-source library for pattern matching in text, which works like a regular expression engine with the ability to do approximate string matching. It was developed by Ville Laurikari and is distributed under a 2-clause BSD-like license.

Why does TRE (computing) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study TRE (computing)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on TRE (computing).

Tags

  • Computer libraries
  • Regular expressions
  • Software using the BSD license

Keep exploring