[537] | 1 | ###########################################################################
|
---|
| 2 | #
|
---|
| 3 | # mgbuildproc.pm --
|
---|
| 4 | # A component of the Greenstone digital library software
|
---|
| 5 | # from the New Zealand Digital Library Project at the
|
---|
| 6 | # University of Waikato, New Zealand.
|
---|
| 7 | #
|
---|
| 8 | # Copyright (C) 1999 New Zealand Digital Library Project
|
---|
| 9 | #
|
---|
| 10 | # This program is free software; you can redistribute it and/or modify
|
---|
| 11 | # it under the terms of the GNU General Public License as published by
|
---|
| 12 | # the Free Software Foundation; either version 2 of the License, or
|
---|
| 13 | # (at your option) any later version.
|
---|
| 14 | #
|
---|
| 15 | # This program is distributed in the hope that it will be useful,
|
---|
| 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 18 | # GNU General Public License for more details.
|
---|
| 19 | #
|
---|
| 20 | # You should have received a copy of the GNU General Public License
|
---|
| 21 | # along with this program; if not, write to the Free Software
|
---|
| 22 | # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 23 | #
|
---|
| 24 | ###########################################################################
|
---|
| 25 |
|
---|
[17] | 26 | # This document processor outputs a document
|
---|
| 27 | # for mg to process
|
---|
[4] | 28 |
|
---|
| 29 |
|
---|
| 30 | package mgbuildproc;
|
---|
| 31 |
|
---|
[215] | 32 | use classify;
|
---|
| 33 | use doc;
|
---|
[4] | 34 | use docproc;
|
---|
| 35 | use util;
|
---|
| 36 |
|
---|
| 37 | BEGIN {
|
---|
| 38 | @ISA = ('docproc');
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | sub new {
|
---|
[1424] | 43 | my ($class, $collection, $source_dir, $build_dir,
|
---|
| 44 | $verbosity, $outhandle) = @_;
|
---|
[4] | 45 | my $self = new docproc ();
|
---|
| 46 |
|
---|
[1424] | 47 | # outhandle is where all the debugging info goes
|
---|
| 48 | # output_handle is where the output of the plugins is piped
|
---|
| 49 | # to (i.e. mg, gdbm etc.)
|
---|
| 50 | $outhandle = STDERR unless defined $outhandle;
|
---|
| 51 |
|
---|
[4] | 52 | $self->{'collection'} = $collection;
|
---|
| 53 | $self->{'source_dir'} = $source_dir;
|
---|
| 54 | $self->{'build_dir'} = $build_dir;
|
---|
| 55 | $self->{'verbosity'} = $verbosity;
|
---|
[215] | 56 | $self->{'classifiers'} = [];
|
---|
[4] | 57 | $self->{'mode'} = "text";
|
---|
[810] | 58 | $self->{'assocdir'} = $build_dir;
|
---|
[780] | 59 | $self->{'dontgdbm'} = {};
|
---|
[4] | 60 | $self->{'index'} = "section:text";
|
---|
[69] | 61 | $self->{'indexexparr'} = [];
|
---|
[4] | 62 | $self->{'output_handle'} = "STDOUT";
|
---|
| 63 | $self->{'num_docs'} = 0;
|
---|
| 64 | $self->{'num_sections'} = 0;
|
---|
| 65 | $self->{'num_bytes'} = 0;
|
---|
[1251] | 66 | $self->{'num_processed_bytes'} = 0;
|
---|
[2336] | 67 | $self->{'store_text'} = 1;
|
---|
[1424] | 68 | $self->{'outhandle'} = $outhandle;
|
---|
[2505] | 69 |
|
---|
| 70 | #used by browse interface
|
---|
| 71 | $self->{'doclist'} = [];
|
---|
| 72 |
|
---|
[292] | 73 | $self->{'indexing_text'} = 0;
|
---|
| 74 |
|
---|
[4] | 75 | return bless $self, $class;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | sub reset {
|
---|
| 79 | my $self = shift (@_);
|
---|
| 80 |
|
---|
| 81 | $self->{'num_docs'} = 0;
|
---|
| 82 | $self->{'num_sections'} = 0;
|
---|
[1251] | 83 | $self->{'num_processed_bytes'} = 0;
|
---|
[4] | 84 | $self->{'num_bytes'} = 0;
|
---|
| 85 | }
|
---|
| 86 |
|
---|
| 87 | sub get_num_docs {
|
---|
| 88 | my $self = shift (@_);
|
---|
| 89 |
|
---|
| 90 | return $self->{'num_docs'};
|
---|
| 91 | }
|
---|
| 92 |
|
---|
| 93 | sub get_num_sections {
|
---|
| 94 | my $self = shift (@_);
|
---|
| 95 |
|
---|
| 96 | return $self->{'num_sections'};
|
---|
| 97 | }
|
---|
| 98 |
|
---|
[1251] | 99 | # num_bytes is the actual number of bytes in the collection
|
---|
| 100 | # this is normally the same as what's processed during text compression
|
---|
[4] | 101 | sub get_num_bytes {
|
---|
| 102 | my $self = shift (@_);
|
---|
| 103 |
|
---|
| 104 | return $self->{'num_bytes'};
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[1251] | 107 | # num_processed_bytes is the number of bytes actually passed
|
---|
| 108 | # to mg for the current index
|
---|
| 109 | sub get_num_processed_bytes {
|
---|
| 110 | my $self = shift (@_);
|
---|
| 111 |
|
---|
| 112 | return $self->{'num_processed_bytes'};
|
---|
| 113 | }
|
---|
| 114 |
|
---|
[4] | 115 | sub set_output_handle {
|
---|
| 116 | my $self = shift (@_);
|
---|
| 117 | my ($handle) = @_;
|
---|
| 118 |
|
---|
| 119 | $self->{'output_handle'} = $handle;
|
---|
| 120 | }
|
---|
| 121 |
|
---|
| 122 | sub set_mode {
|
---|
| 123 | my $self = shift (@_);
|
---|
| 124 | my ($mode) = @_;
|
---|
| 125 |
|
---|
| 126 | $self->{'mode'} = $mode;
|
---|
| 127 | }
|
---|
| 128 |
|
---|
[810] | 129 | sub set_assocdir {
|
---|
| 130 | my $self = shift (@_);
|
---|
| 131 | my ($assocdir) = @_;
|
---|
| 132 |
|
---|
| 133 | $self->{'assocdir'} = $assocdir;
|
---|
| 134 | }
|
---|
| 135 |
|
---|
[780] | 136 | sub set_dontgdbm {
|
---|
| 137 | my $self = shift (@_);
|
---|
| 138 | my ($dontgdbm) = @_;
|
---|
| 139 |
|
---|
| 140 | $self->{'dontgdbm'} = $dontgdbm;
|
---|
| 141 | }
|
---|
| 142 |
|
---|
[4] | 143 | sub set_index {
|
---|
| 144 | my $self = shift (@_);
|
---|
[69] | 145 | my ($index, $indexexparr) = @_;
|
---|
[4] | 146 |
|
---|
| 147 | $self->{'index'} = $index;
|
---|
[69] | 148 | $self->{'indexexparr'} = $indexexparr if defined $indexexparr;
|
---|
[4] | 149 | }
|
---|
| 150 |
|
---|
[1251] | 151 | sub get_index {
|
---|
| 152 | my $self = shift (@_);
|
---|
| 153 |
|
---|
| 154 | return $self->{'index'};
|
---|
| 155 | }
|
---|
| 156 |
|
---|
[215] | 157 | sub set_classifiers {
|
---|
| 158 | my $self = shift (@_);
|
---|
| 159 | my ($classifiers) = @_;
|
---|
| 160 |
|
---|
| 161 | $self->{'classifiers'} = $classifiers;
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[292] | 164 | sub set_indexing_text {
|
---|
| 165 | my $self = shift (@_);
|
---|
| 166 | my ($indexing_text) = @_;
|
---|
| 167 |
|
---|
| 168 | $self->{'indexing_text'} = $indexing_text;
|
---|
| 169 | }
|
---|
| 170 |
|
---|
[1251] | 171 | sub get_indexing_text {
|
---|
| 172 | my $self = shift (@_);
|
---|
| 173 |
|
---|
| 174 | return $self->{'indexing_text'};
|
---|
| 175 | }
|
---|
| 176 |
|
---|
[2336] | 177 | sub set_store_text {
|
---|
| 178 | my $self = shift (@_);
|
---|
| 179 | my ($store_text) = @_;
|
---|
| 180 |
|
---|
| 181 | $self->{'store_text'} = $store_text;
|
---|
| 182 | }
|
---|
| 183 |
|
---|
[2505] | 184 | sub get_doc_list {
|
---|
| 185 | my $self = shift(@_);
|
---|
| 186 |
|
---|
| 187 | return @{$self->{'doclist'}};
|
---|
| 188 | }
|
---|
[2336] | 189 |
|
---|
[2505] | 190 |
|
---|
[4] | 191 | sub process {
|
---|
| 192 | my $self = shift (@_);
|
---|
| 193 | my $method = $self->{'mode'};
|
---|
| 194 |
|
---|
[139] | 195 | $self->$method(@_);
|
---|
[4] | 196 | }
|
---|
| 197 |
|
---|
[677] | 198 | # use 'Paged' if document has no more than 2 levels
|
---|
| 199 | # and each section at second level has a number for
|
---|
| 200 | # Title metadata
|
---|
| 201 | sub get_document_type {
|
---|
| 202 | my $self = shift (@_);
|
---|
| 203 | my ($doc_obj) = @_;
|
---|
| 204 |
|
---|
| 205 | my $thistype = "VList";
|
---|
| 206 | my $childtype = "VList";
|
---|
| 207 | my $title;
|
---|
| 208 | my @tmp = ();
|
---|
| 209 |
|
---|
| 210 | my $section = $doc_obj->get_top_section ();
|
---|
| 211 | my $first = 1;
|
---|
| 212 | while (defined $section) {
|
---|
| 213 | @tmp = split /\./, $section;
|
---|
| 214 | if (scalar(@tmp) > 1) {
|
---|
| 215 | return ($thistype, $childtype);
|
---|
| 216 | }
|
---|
| 217 | if (!$first) {
|
---|
| 218 | $title = $doc_obj->get_metadata_element ($section, "Title");
|
---|
[706] | 219 | if (!defined $title || $title !~ /^\d+$/) {
|
---|
[677] | 220 | return ($thistype, $childtype);
|
---|
| 221 | }
|
---|
| 222 | }
|
---|
| 223 | $first = 0;
|
---|
| 224 | $section = $doc_obj->get_next_section($section);
|
---|
| 225 | }
|
---|
| 226 | if ($doc_obj->get_text_length ($doc_obj->get_top_section())) {
|
---|
| 227 | $thistype = "Paged";
|
---|
| 228 | } else {
|
---|
| 229 | $thistype = "Invisible";
|
---|
| 230 | }
|
---|
| 231 | $childtype = "Paged";
|
---|
| 232 | return ($thistype, $childtype);
|
---|
| 233 | }
|
---|
| 234 |
|
---|
[810] | 235 | sub assoc_files {
|
---|
| 236 | my $self = shift (@_);
|
---|
[900] | 237 | my ($doc_obj, $archivedir) = @_;
|
---|
| 238 | my ($afile);
|
---|
[810] | 239 |
|
---|
[900] | 240 | foreach my $assoc_file (@{$doc_obj->get_assoc_files()}) {
|
---|
| 241 | # if assoc file contains directory structure of
|
---|
| 242 | # its own use it, otherwise use HASH... directory
|
---|
| 243 | if ($assoc_file->[1] =~ /[\/\\]/) {
|
---|
| 244 | $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
|
---|
| 245 | } else {
|
---|
| 246 | $afile = &util::filename_cat($self->{'assocdir'}, $archivedir, $assoc_file->[1]);
|
---|
| 247 | }
|
---|
[810] | 248 | &util::hard_link ($assoc_file->[0], $afile);
|
---|
| 249 | }
|
---|
| 250 | }
|
---|
| 251 |
|
---|
[315] | 252 | sub infodb {
|
---|
[215] | 253 | my $self = shift (@_);
|
---|
| 254 | my ($doc_obj, $filename) = @_;
|
---|
| 255 | my $handle = $self->{'output_handle'};
|
---|
| 256 | # $handle = "main::STDOUT";
|
---|
| 257 |
|
---|
| 258 | my $doctype = $doc_obj->get_doc_type();
|
---|
| 259 |
|
---|
| 260 | # only output this document if it is one to be indexed
|
---|
| 261 | return if ($doctype ne "indexed_doc");
|
---|
| 262 |
|
---|
[900] | 263 | my ($archivedir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
|
---|
| 264 | $archivedir = "" unless defined $archivedir;
|
---|
| 265 | $archivedir =~ s/\\/\//g;
|
---|
| 266 | $archivedir =~ s/^\/+//;
|
---|
| 267 | $archivedir =~ s/\/+$//;
|
---|
| 268 |
|
---|
| 269 | $self->assoc_files ($doc_obj, $archivedir);
|
---|
| 270 |
|
---|
[215] | 271 | # this is another document
|
---|
| 272 | $self->{'num_docs'} += 1 unless ($doctype eq "classification");
|
---|
| 273 |
|
---|
[677] | 274 | # is this a paged or a hierarchical document
|
---|
| 275 | my ($thistype, $childtype) = $self->get_document_type ($doc_obj);
|
---|
| 276 |
|
---|
[215] | 277 | my $section = $doc_obj->get_top_section ();
|
---|
| 278 | my $doc_OID = $doc_obj->get_OID();
|
---|
[677] | 279 | my $first = 1;
|
---|
[810] | 280 | my $url = "";
|
---|
[215] | 281 | while (defined $section) {
|
---|
| 282 | # update a few statistics
|
---|
| 283 | $self->{'num_bytes'} += $doc_obj->get_text_length ($section);
|
---|
| 284 | $self->{'num_sections'} += 1 unless ($doctype eq "classification");
|
---|
| 285 |
|
---|
| 286 | # output the section name
|
---|
| 287 | if ($section eq "") { print $handle "[$doc_OID]\n"; }
|
---|
| 288 | else { print $handle "[$doc_OID.$section]\n"; }
|
---|
| 289 |
|
---|
[1044] | 290 | # output the fact that this document is a document (unless doctype
|
---|
| 291 | # has been set to something else from within a plugin
|
---|
| 292 | my $dtype = $doc_obj->get_metadata_element ($section, "doctype");
|
---|
| 293 | if (!defined $dtype || $dtype !~ /\w/) {
|
---|
| 294 | print $handle "<doctype>doc\n";
|
---|
| 295 | }
|
---|
[215] | 296 |
|
---|
| 297 | # output whether this node contains text
|
---|
| 298 | if ($doc_obj->get_text_length($section) > 0) {
|
---|
| 299 | print $handle "<hastxt>1\n";
|
---|
| 300 | } else {
|
---|
| 301 | print $handle "<hastxt>0\n";
|
---|
| 302 | }
|
---|
| 303 |
|
---|
| 304 | # output all the section metadata
|
---|
| 305 | my $metadata = $doc_obj->get_all_metadata ($section);
|
---|
[900] | 306 | foreach my $pair (@$metadata) {
|
---|
[215] | 307 | my ($field, $value) = (@$pair);
|
---|
| 308 |
|
---|
| 309 | if ($field ne "Identifier" && $field !~ /^gsdl/ &&
|
---|
[810] | 310 | defined $value && $value ne "") {
|
---|
| 311 |
|
---|
[215] | 312 | # escape problematic stuff
|
---|
| 313 | $value =~ s/\\/\\\\/g;
|
---|
| 314 | $value =~ s/\n/\\n/g;
|
---|
| 315 | $value =~ s/\r/\\r/g;
|
---|
[810] | 316 |
|
---|
| 317 | # special case for URL metadata
|
---|
| 318 | if ($field =~ /^URL$/i) {
|
---|
| 319 | $url .= "[$value]\n";
|
---|
| 320 | if ($section eq "") {$url .= "<section>$doc_OID\n";}
|
---|
| 321 | else {$url .= "<section>$doc_OID.$section\n";}
|
---|
| 322 | $url .= '-' x 70 . "\n";
|
---|
| 323 | }
|
---|
| 324 |
|
---|
| 325 | if (!defined $self->{'dontgdbm'}->{$field}) {
|
---|
| 326 | print $handle "<$field>$value\n";
|
---|
| 327 | }
|
---|
[215] | 328 | }
|
---|
| 329 | }
|
---|
[810] | 330 |
|
---|
[255] | 331 | # output archivedir if at top level
|
---|
| 332 | if ($section eq $doc_obj->get_top_section()) {
|
---|
| 333 | print $handle "<archivedir>$archivedir\n";
|
---|
| 334 | }
|
---|
[810] | 335 |
|
---|
[677] | 336 | # output document display type
|
---|
| 337 | if ($first) {
|
---|
| 338 | print $handle "<thistype>$thistype\n";
|
---|
| 339 | }
|
---|
| 340 |
|
---|
[215] | 341 | # output a list of children
|
---|
[222] | 342 | my $children = $doc_obj->get_children ($section);
|
---|
[215] | 343 | if (scalar(@$children) > 0) {
|
---|
[677] | 344 | print $handle "<childtype>$childtype\n";
|
---|
[215] | 345 | print $handle "<contains>";
|
---|
| 346 | my $firstchild = 1;
|
---|
[900] | 347 | foreach my $child (@$children) {
|
---|
[215] | 348 | print $handle ";" unless $firstchild;
|
---|
| 349 | $firstchild = 0;
|
---|
[252] | 350 | if ($child =~ /^.*?\.(\d+)$/) {
|
---|
| 351 | print $handle "\".$1";
|
---|
| 352 | } else {
|
---|
| 353 | print $handle "\".$child";
|
---|
| 354 | }
|
---|
[222] | 355 | # if ($child eq "") { print $handle "$doc_OID"; }
|
---|
| 356 | # elsif ($section eq "") { print $handle "$doc_OID.$child"; }
|
---|
| 357 | # else { print $handle "$doc_OID.$section.$child"; }
|
---|
[215] | 358 | }
|
---|
| 359 | print $handle "\n";
|
---|
| 360 | }
|
---|
| 361 |
|
---|
| 362 | # output the matching document number
|
---|
| 363 | print $handle "<docnum>$self->{'num_sections'}\n";
|
---|
| 364 |
|
---|
| 365 | print $handle '-' x 70, "\n";
|
---|
| 366 |
|
---|
| 367 |
|
---|
| 368 | # output a database entry for the document number
|
---|
| 369 | print $handle "[$self->{'num_sections'}]\n";
|
---|
| 370 | if ($section eq "") { print $handle "<section>$doc_OID\n"; }
|
---|
| 371 | else { print $handle "<section>$doc_OID.$section\n"; }
|
---|
| 372 | print $handle '-' x 70, "\n";
|
---|
[810] | 373 |
|
---|
| 374 | # output entry for url
|
---|
| 375 | if ($url ne "") {
|
---|
| 376 | print $handle $url;
|
---|
| 377 | }
|
---|
[215] | 378 |
|
---|
[677] | 379 | $first = 0;
|
---|
[215] | 380 | $section = $doc_obj->get_next_section($section);
|
---|
| 381 | }
|
---|
| 382 |
|
---|
[2505] | 383 | #add this document to the browse structure
|
---|
| 384 | push(@{$self->{'doclist'}},$doc_obj->get_OID())
|
---|
| 385 | unless ($doctype eq "classification");
|
---|
| 386 |
|
---|
[215] | 387 | # classify this document
|
---|
| 388 | &classify::classify_doc ($self->{'classifiers'}, $doc_obj);
|
---|
| 389 |
|
---|
| 390 | }
|
---|
| 391 |
|
---|
[289] | 392 | sub find_paragraphs {
|
---|
| 393 | $_[1] =~ s/(<p\b)/\cC$1/gi;
|
---|
| 394 | }
|
---|
| 395 |
|
---|
[292] | 396 | sub filter_text {
|
---|
| 397 | # $self->filter_text ($field, $new_text);
|
---|
| 398 | # don't want to do anything for this version, however,
|
---|
| 399 | # in a particular collection you might want to override
|
---|
| 400 | # this method to post-process certain fields depending on
|
---|
| 401 | # the field, or whether we are outputting it for indexing
|
---|
| 402 | }
|
---|
| 403 |
|
---|
[4] | 404 | sub text {
|
---|
| 405 | my $self = shift (@_);
|
---|
| 406 | my ($doc_obj) = @_;
|
---|
| 407 | my $handle = $self->{'output_handle'};
|
---|
[69] | 408 | my $indexed_doc = 1;
|
---|
[4] | 409 |
|
---|
| 410 | # only output this document if it is one to be indexed
|
---|
| 411 | return if ($doc_obj->get_doc_type() ne "indexed_doc");
|
---|
| 412 |
|
---|
[69] | 413 | # see if this document belongs to this subcollection
|
---|
[900] | 414 | foreach my $indexexp (@{$self->{'indexexparr'}}) {
|
---|
[69] | 415 | $indexed_doc = 0;
|
---|
| 416 | my ($field, $exp, $options) = split /\//, $indexexp;
|
---|
| 417 | if (defined ($field) && defined ($exp)) {
|
---|
| 418 | my ($bool) = $field =~ /^(.)/;
|
---|
| 419 | $field =~ s/^.// if $bool eq '!';
|
---|
[544] | 420 | if ($field =~ /^filename$/i) {
|
---|
[69] | 421 | $field = $doc_obj->get_source_filename();
|
---|
| 422 | } else {
|
---|
| 423 | $field = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $field);
|
---|
| 424 | }
|
---|
| 425 | next unless defined $field;
|
---|
| 426 | if ($bool eq '!') {
|
---|
| 427 | if ($options =~ /^i$/i) {
|
---|
| 428 | if ($field !~ /$exp/i) {$indexed_doc = 1; last;}
|
---|
| 429 | } else {
|
---|
| 430 | if ($field !~ /$exp/) {$indexed_doc = 1; last;}
|
---|
| 431 | }
|
---|
| 432 | } else {
|
---|
| 433 | if ($options =~ /^i$/i) {
|
---|
| 434 | if ($field =~ /$exp/i) {$indexed_doc = 1; last;}
|
---|
| 435 | } else {
|
---|
| 436 | if ($field =~ /$exp/) {$indexed_doc = 1; last;}
|
---|
| 437 | }
|
---|
| 438 | }
|
---|
| 439 | }
|
---|
| 440 | }
|
---|
| 441 |
|
---|
[4] | 442 | # this is another document
|
---|
| 443 | $self->{'num_docs'} += 1;
|
---|
| 444 |
|
---|
| 445 | # get the parameters for the output
|
---|
| 446 | my ($level, $fields) = split (/:/, $self->{'index'});
|
---|
| 447 | $fields =~ s/\ball\b/Title,Creator,text/;
|
---|
| 448 | $fields =~ s/\btopall\b/topTitle,topCreator,toptext/;
|
---|
| 449 |
|
---|
| 450 | my $doc_section = 0; # just for this document
|
---|
| 451 | my $text = "";
|
---|
| 452 | my $text_extra = "";
|
---|
| 453 |
|
---|
| 454 | # get the text for this document
|
---|
| 455 | my $section = $doc_obj->get_top_section();
|
---|
| 456 | while (defined $section) {
|
---|
| 457 | # update a few statistics
|
---|
| 458 | $doc_section++;
|
---|
| 459 | $self->{'num_sections'} += 1;
|
---|
[69] | 460 |
|
---|
| 461 | if ($indexed_doc) {
|
---|
| 462 | $self->{'num_bytes'} += $doc_obj->get_text_length ($section);
|
---|
[900] | 463 | foreach my $field (split (/,/, $fields)) {
|
---|
[69] | 464 | # only deal with this field if it doesn't start with top or
|
---|
| 465 | # this is the first section
|
---|
| 466 | my $real_field = $field;
|
---|
| 467 | if (!($real_field =~ s/^top//) || ($doc_section == 1)) {
|
---|
| 468 | my $new_text = "";
|
---|
| 469 | if ($real_field eq "text") {
|
---|
[2336] | 470 | $new_text = $doc_obj->get_text ($section) if $self->{'store_text'};
|
---|
[1251] | 471 | $self->{'num_processed_bytes'} += length ($new_text);
|
---|
[69] | 472 | $new_text =~ s/[\cB\cC]//g;
|
---|
[289] | 473 | $self->find_paragraphs($new_text);
|
---|
[69] | 474 |
|
---|
| 475 | } else {
|
---|
[1072] | 476 | my $first = 1;
|
---|
| 477 | foreach $meta (@{$doc_obj->get_metadata ($section, $real_field)}) {
|
---|
| 478 | $meta =~ s/[\cB\cC]//g;
|
---|
[1251] | 479 | $self->{'num_processed_bytes'} += length ($meta);
|
---|
[1072] | 480 | $new_text .= "\cC" unless $first;
|
---|
[2336] | 481 | $new_text .= $meta if $self->{'store_text'};
|
---|
[1072] | 482 | $first = 0;
|
---|
| 483 | }
|
---|
[69] | 484 | }
|
---|
[4] | 485 |
|
---|
[292] | 486 | # filter the text
|
---|
| 487 | $self->filter_text ($field, $new_text);
|
---|
| 488 |
|
---|
[69] | 489 | $text .= "$new_text\cC";
|
---|
[4] | 490 | }
|
---|
| 491 | }
|
---|
| 492 | }
|
---|
| 493 |
|
---|
| 494 | if ($level eq "document") { $text_extra .= "\cB"; }
|
---|
| 495 | else { $text .= "\cB"; }
|
---|
| 496 |
|
---|
| 497 | $section = $doc_obj->get_next_section($section);
|
---|
| 498 | }
|
---|
| 499 |
|
---|
| 500 | print $handle "$text$text_extra";
|
---|
| 501 | }
|
---|
| 502 |
|
---|
| 503 | 1;
|
---|
| 504 |
|
---|