to it, subject to the condition that the sequence appears on every page. If we managed to build a sequence that's at least three tokens long7**, and this sequence appears exactly once**
on each page, it becomes part of the page template. Templates **play an important role in**
helping identify correct data examples on pages.

input:
P = set of N **Web pages**
output:
T **= page template**
begin p **= shortest(**P)
T **= null**
s **= null**
for t = firsttoken(p**) to lasttoken(**p)
s
′ = concat(**s, t**)
if ( s
′ **appears on every page in** P )
s = s
′
continue else n =PN
page=1 count(s**, page)**
if ( n = N AND length(s) ≥ 3 )
add-to-template(**T, s**)
end if s **= null**
end if end for end Table 7: Pseudocode of the template finding algorithm

## 3.2.2 Automatic Labeling Algorithm

Figure 7 is a schematic outline of the reinduction algorithm, which consists of automatic data labeling and wrapper induction. Because the latter aspect is described in detail in other work (Muslea et al., 2001), we focus the discussion below on the automatic data labeling algorithm.

First, DataProG **learns the starting and ending patterns that describe the set of training examples. These training examples have been collected during wrapper's normal operation, while it was correctly extracting data from the Web source. The patterns are used**
to identify possible examples of the data field on the new pages. In addition to patterns, we also calculate the mean (and its variance) of the number-of-tokens in the training examples. Each new page is then scanned to identify all text segments that begin with one of the starting patterns and end with one of the ending patterns. Text segments that con-