source: gs3-extensions/audioDB/trunk/src/perllib/audioDBBuildproc.pm@ 24341

Last change on this file since 24341 was 24341, checked in by davidb, 13 years ago

Files to support building an audioDB index that is orthogonol to the usual text-based index

File size: 3.2 KB
RevLine 
[24341]1##########################################################################
2#
3# audioDBBuildproc.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
26# This document processor outputs a document for indexing (should be
27# implemented by subclass) and storing in the database
28
29package audioDBBuildproc;
30
31use strict;
32no strict 'refs'; # allow filehandles to be variables and viceversa
33
34use util;
35
36use extrabuildproc;
37
38
39BEGIN {
40 @audioDBBuildproc::ISA = ('extrabuildproc');
41}
42
43sub new()
44 {
45 my $class = shift @_;
46
47 my $self = new extrabuildproc (@_);
48
49 return bless $self, $class;
50}
51
52
53sub textedit {
54 my $self = shift (@_);
55 my ($doc_obj,$file,$mode) = @_;
56
57 # Code written on the assumption that that audioDB does a replace
58 # operation when presented with a docid that already extis.
59 # => don't need to do anything special to distinguish between
60 # a mode of "add" and "update"
61
62 my $outhandle = $self->{'outhandle'};
63
64
65 my $source_dir = $self->{'source_dir'}; # typically the archives dir
66 my $build_dir = $self->{'build_dir'};
67
68 # full path to adb database
69 my $adb_filename
70 = &util::filename_cat($build_dir, "audioDB", "lsh-features.adb");
71
72 # get doc id
73 my $doc_oid = $doc_obj->get_OID();
74
75 # map to assoc dir
76 my $top_section = $doc_obj->get_top_section();
77 my $assoc_file
78 = $doc_obj->get_metadata_element ($top_section,"assocfilepath");
79 my $assoc_filename = &util::filename_cat($source_dir,$assoc_file);
80
81 my $chr12_filename = &util::filename_cat($assoc_filename,"doc.chr12");
82 my $powerlog_filename = &util::filename_cat($assoc_filename,"doc.power");
83
84 print $outhandle " Inserting features for $doc_oid\n";
85
86 my $cmd = "audioDB -d \"$adb_filename\" -I -k \"$doc_oid\" -f \"$chr12_filename\" -w \"$powerlog_filename\"";
87
88 my $status = system($cmd);
89 if ($status != 0) {
90 print STDERR "Error: failed to run:\n $cmd\n$!\n";
91 }
92}
93
94sub text {
95 my $self = shift (@_);
96 my ($doc_obj,$file) = @_;
97
98 $self->textedit($doc_obj,$file,"add");
99}
100
101sub textreindex
102{
103 my $self = shift @_;
104 my ($doc_obj,$file) = @_;
105
106 $self->textedit($doc_obj,$file,"update");
107}
108
109sub textdelete
110{
111 my $self = shift @_;
112
113 my ($doc_obj,$file) = @_;
114
115 print STDERR "Warning: audioDB command-line does not currently support delete operation\n";
116
117 # $self->textedit($doc_obj,$file,"delete");
118}
119
1201;
Note: See TracBrowser for help on using the repository browser.