[LON-CAPA-cvs] cvs: loncom /interface loncommon.pm lonsearchcat.pm
www
lon-capa-cvs@mail.lon-capa.org
Mon, 17 Jul 2006 19:47:23 -0000
www Mon Jul 17 15:47:23 2006 EDT
Modified files:
/loncom/interface loncommon.pm lonsearchcat.pm
Log:
Bug #4924: related word actually worked, just didn't display.
Also, with new thesaurus, it is important to limit the output
Index: loncom/interface/loncommon.pm
diff -u loncom/interface/loncommon.pm:1.428 loncom/interface/loncommon.pm:1.429
--- loncom/interface/loncommon.pm:1.428 Fri Jul 14 13:23:49 2006
+++ loncom/interface/loncommon.pm Mon Jul 17 15:47:20 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# a pile of common routines
#
-# $Id: loncommon.pm,v 1.428 2006/07/14 17:23:49 albertel Exp $
+# $Id: loncommon.pm,v 1.429 2006/07/17 19:47:20 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1918,12 +1918,20 @@
return ();
}
my @Words=();
+ my $count=0;
if (exists($thesaurus_db{$keyword})) {
# The first element is the number of times
# the word appears. We do not need it now.
- (undef,@Words) = (split(/:/,$thesaurus_db{$keyword}));
- for (my $i=0;$i<=$#Words;$i++) {
- ($Words[$i],undef)= split(/\,/,$Words[$i]);
+ my (undef,@RelatedWords) = (split(/:/,$thesaurus_db{$keyword}));
+ my (undef,$mostfrequentcount)=split(/\,/,$RelatedWords[0]);
+ my $threshold=$mostfrequentcount/10;
+ foreach my $possibleword (@RelatedWords) {
+ my ($word,$wordcount)=split(/\,/,$possibleword);
+ if ($wordcount>$threshold) {
+ push(@Words,$word);
+ $count++;
+ if ($count>10) { last; }
+ }
}
}
untie %thesaurus_db;
Index: loncom/interface/lonsearchcat.pm
diff -u loncom/interface/lonsearchcat.pm:1.272 loncom/interface/lonsearchcat.pm:1.273
--- loncom/interface/lonsearchcat.pm:1.272 Thu Jun 29 15:25:40 2006
+++ loncom/interface/lonsearchcat.pm Mon Jul 17 15:47:20 2006
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Search Catalog
#
-# $Id: lonsearchcat.pm,v 1.272 2006/06/29 19:25:40 www Exp $
+# $Id: lonsearchcat.pm,v 1.273 2006/07/17 19:47:20 www Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1540,12 +1540,12 @@
$domain_hash{$_}++;
}
if ($domain_hash{'any'}) {
- $pretty_domains_string = "In all LON-CAPA domains.";
+ $pretty_domains_string = &mt("in all LON-CAPA domains.");
} else {
if (@allowed_domains > 1) {
- $pretty_domains_string = "In LON-CAPA domains:";
+ $pretty_domains_string = &mt("in LON-CAPA domains:");
} else {
- $pretty_domains_string = "In LON-CAPA domain ";
+ $pretty_domains_string = &mt("in LON-CAPA domain ");
}
foreach (sort @allowed_domains) {
$pretty_domains_string .= "<b>".$_."</b> ";
@@ -1614,6 +1614,9 @@
#}
my $final_query = 'SELECT * FROM metadata WHERE '.join(" AND ",@Queries);
#
+ if ($env{'form.related'}) {
+ $pretty_search_string.=' '.&mt('(including related words)');
+ }
if (defined($pretty_domains_string) && $pretty_domains_string ne '') {
$pretty_search_string .= ' '.$pretty_domains_string;
}
@@ -2133,7 +2136,7 @@
<p>
There are $total_results matches to your query. $revise
</p><p>
-Search:$pretty_query_string
+Search: $pretty_query_string
</p>
</form>
END