--- loncom/interface/loncommon.pm 2006/07/14 17:23:49 1.428 +++ loncom/interface/loncommon.pm 2006/07/17 19:47:20 1.429 @@ -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 @@ sub get_related_words { 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;