Hi all
I came across a problem where when parsing search results. Each search
result is given a tag cloud, and I run through a loop to determine
scoring of elements for a tag cloud. the scoring is presented in a
hash map that lines up with the name on the tags in the cloud.
here is the code I am running:
case Constants.KNOWLEDGE_MODEL:
var kmLength:int = item.name.length + item.value.length;
var textHeight:int = (kmLength/40 + 1) * 16;
metadataHeight += textHeight;
// building tagCloud.
tagCloud.percentWidth = 100
tagCloud.styleName = "tagCloud";
var last:int = items.length - 1;
var words:Array = item.value.split("; ");
for(var idx:int = 0; idx < words.length; idx++)
{
word = words[idx];
tagScore = matches[word];
if ( tagMax < tagScore)
{
tagMax = tagScore;
}
else {}
}
for(idx = 0; idx < words.length; idx++)
{
word = words[idx];
tagScore = matches[word];
var tagLabel:LinkButton = new LinkButton();
tagLabel.label = word;
tagLabel.toolTip = Constants.RELEVANCE + ": " +
tagScore.toFixed(2)
+ "%"
var tagDiff:Number = tagMax / 2;
if (tagScore == tagMin)
tagLabel.styleName = "tagCloudSmall";
else if (tagScore > tagMin && tagScore < tagDiff)
tagLabel.styleName = "tagCloudMedium";
else if (tagScore < tagMax && tagScore > tagDiff)
tagLabel.styleName = "tagCloudLarge";
else if (tagScore == tagMax)
tagLabel.styleName = "tagCloudLarger";
else
tagLabel.styleName = "tagCloudMedium";
tagCloud.addChild( tagLabel );
}
// Add tagCloud to the metadataList VBox
metadataList.addChild( tagCloud );
Now the problem is there can be unlimited tags for the cloud. I am
seeing a range of 8 - 20 on the results I can view. Now multiple this
by many search results. The results are chunked in groups of 10, so
its possible this loop get run over 200 times.
Any help would be much appreciated
thanks
Jeff