所以我创建了一个包含X个标签的标签云。像这样的http://upload.wikimedia.org/wikipedia/commons/a/a7/Web_2.0_Map.svg关键字使用得越频繁,它的字体大小就越大。对于我的标签云,我有X数量的标签,我需要根据字体大小进行分组。我有一个叫做FacetBucket的结构,它包含标签及其频率。最常用的短语将具有最大的字体大小,而最不常用的术语将具有最小的字体大小。适度使用的术语都将具有最大和最小的字体大小。所以我的问题是,我有X数量的标签和Y数量的字体大小,我应该寻找什么样的算法来解决我的问题?
发布于 2013-09-14 02:55:57
对于其他任何想做类似事情的人来说,这里有一个方程式可以帮助你。
We will use the following variables, namely:
a = the smallest count (or occurrence).
b = the count of the tag being computed.
c = the largest count.
w = the smallest font-size.
x = the font-size for the tag. It is the unknown.
y = the largest font-size.
Now let's substitute the given values to their respective variables. Assuming that we are solving for the "thanksgiving" font-size.
a = 88
b = 168
c = 211
w = 12
x = ?
y = 50
And here's the formula:
x = (b-a) (y-w)
----------- + w
(c-a)
Or to put it in one liner (using c-like syntax):
x = ( ((b-a) * (y-w)) / (c-a) ) + w摘自http://blog.16codes.com/2007/12/how-to-create-tag-cloud-with-formula.html
发布于 2013-09-14 00:22:44
X和Y的值。这将确定每个频率获得的字体大小,了解到只要标签的数量超过可用字体大小,接近值的频率将以相同的大小显示。
实际上并不需要太多的算法。
https://stackoverflow.com/questions/18790677
复制相似问题