[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.13,1.14 Context.pm,1.3,1.4
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/C4 Biblio.pm,1.13,1.14 Context.pm,1.3,1.4 |
Date: |
Thu, 03 Oct 2002 04:28:20 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv15495
Modified Files:
Biblio.pm Context.pm
Log Message:
Extending Context.pm to add stopword management and using it in MARC-API.
First benchmarks show a medium speed improvement, which is nice as this part
is heavily called.
Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -r1.13 -r1.14
*** Biblio.pm 2 Oct 2002 16:26:44 -0000 1.13
--- Biblio.pm 3 Oct 2002 11:28:18 -0000 1.14
***************
*** 2,5 ****
--- 2,9 ----
# $Id$
# $Log$
+ # Revision 1.14 2002/10/03 11:28:18 tipaul
+ # Extending Context.pm to add stopword management and using it in MARC-API.
+ # First benchmarks show a medium speed improvement, which is nice as this
part is heavily called.
+ #
# Revision 1.13 2002/10/02 16:26:44 tipaul
# road to 1.3.1
***************
*** 799,809 ****
my @words = split / /,$sentence;
# build stopword list
! my $sth2 =$dbh->prepare("select word from stopwords");
! $sth2->execute;
! my $stopwords;
! my $stopword;
! while(($stopword) = $sth2->fetchrow_array) {
! $stopwords->{$stopword} = $stopword;
! }
my $sth=$dbh->prepare("insert into marc_word (bibid, tag, tagorder,
subfieldid, subfieldorder, word, sndx_word)
values (?,?,?,?,?,?,soundex(?))");
--- 803,814 ----
my @words = split / /,$sentence;
# build stopword list
! # my $sth2 =$dbh->prepare("select word from stopwords");
! # $sth2->execute;
! # my $stopwords;
! # my $stopword;
! # while(($stopword) = $sth2->fetchrow_array) {
! # $stopwords->{$stopword} = $stopword;
! # }
! my $stopwords= C4::Context->stopwords;
my $sth=$dbh->prepare("insert into marc_word (bibid, tag, tagorder,
subfieldid, subfieldorder, word, sndx_word)
values (?,?,?,?,?,?,soundex(?))");
Index: Context.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Context.pm,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Context.pm 2 Oct 2002 23:38:47 -0000 1.3
--- Context.pm 3 Oct 2002 11:28:18 -0000 1.4
***************
*** 183,186 ****
--- 183,187 ----
$self->{"dbh"} = undef; # Database handle
+ $self->{"stopwords"} = undef; # stopwords list
bless $self, $class;
***************
*** 421,424 ****
--- 422,473 ----
# FIXME - If it is determined that restore_context should
# return something, then this function should, too.
+ }
+
+ =item stopwords
+
+ $dbh = C4::Context->stopwords;
+
+ Returns a hash with stopwords.
+
+ This hash is cached for future use: if you call
+ C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real
DB access
+
+ =cut
+ #'
+ sub stopwords
+ {
+ my $retval = {};
+
+ # If the hash already exists, return it.
+ return $context->{"stopwords"} if defined($context->{"stopwords"});
+
+ # No hash. Create one.
+ $context->{"stopwords"} = &_new_stopwords();
+
+ return $context->{"stopwords"};
+ }
+
+ # _new_stopwords
+ # Internal helper function (not a method!). This creates a new
+ # hash with stopwords
+ sub _new_stopwords
+ {
+ my $dbh = &dbh;
+ my $stopwordlist;
+ my $sth = $dbh->prepare("select word from stopwords");
+ $sth->execute;
+ while (my $stopword = $sth->fetchrow_array) {
+ my $retval = {};
+ $stopwordlist->{$stopword} = uc($stopword);
+ }
+ return $stopwordlist;
+ # my $db_driver = $context->{"config"}{"db_scheme"} || "mysql";
+ # my $db_name = $context->{"config"}{"database"};
+ # my $db_host = $context->{"config"}{"hostname"};
+ # my $db_user = $context->{"config"}{"user"};
+ # my $db_passwd = $context->{"config"}{"pass"};
+
+ # return DBI->connect("DBI:$db_driver:$db_name:$db_host",
+ # $db_user, $db_passwd);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 Biblio.pm,1.13,1.14 Context.pm,1.3,1.4,
Paul POULAIN <=
- Prev by Date:
[Koha-cvs] CVS: koha/marc fill_usmarc.pl,1.4,1.5 updatedb2marc.pl,1.1,1.2
- Next by Date:
[Koha-cvs] CVS: koha/C4 Context.pm,1.4,1.5
- Previous by thread:
[Koha-cvs] CVS: koha/marc fill_usmarc.pl,1.4,1.5 updatedb2marc.pl,1.1,1.2
- Next by thread:
[Koha-cvs] CVS: koha/C4 Context.pm,1.4,1.5
- Index(es):