[Clipart] tag used in openclipart

Roger Martín rg1024 at gmail.com
Wed Jan 12 02:07:29 PST 2011

2011/1/12 Francis Bond <bond at ieee.org>

> I am very interested in how you got the data.  Could you show us how to do
> it?
I have a copy of ocal database ( date 12/dic/2010) and with a little and
rudimentary php program (see end) made the stats.
What do you need ? a sql table with all tag, for example?

Off course, i can program all batches process.

the program (sorry if you don't understand php)


mysql_connect("localhost","openclipart","opencli") or die("no conect");
mysql_selectdb("openclipart") or die("no db");

$rs= mysql_query("SELECT id,filename, upload_tags FROM ocal_files"); // can
be improved
$resul = array();
$ntags =0;

while ( $row= mysql_fetch_array($rs)) {
    $tags = explode(",", strtolower($row["upload_tags"]));
    $words= count($tags); //($row["upload_tags"]);
    if ( $words==1 && $tags[0]==""){
        $example[0] = $row['id'];
    $example[$words] = $row['id'];

    foreach( $tags as $tag){
       if ($tag) {
    if ($words>$record){
        $record= $words;
        $thewinner= "{$row['filename']} (
tags:<br>".strtolower($row["upload_tags"])."<br> with $record tags";

echo "<p>Total tags: ", $ntags, "<br>Distinct: ", count($resul),
     "<br>Media: ", round($ntags/count($resul),2);
echo "<br>Clipart without tags: $notags";
echo "<br>total clipart: $total";

echo "<p>Random 100 tags<br>";
foreach  (array_rand($resul,100) as $tag){
    echo "$tag ({$resul[$tag]}), ";

echo "<p>top 100 tag<br>";
foreach  ($resul as $tag=>$counter){
    echo "$tag ($counter), ";
    if ($i>100)


echo "<p>less used<br>";
foreach  ($resul as $tag=>$counter){
    echo "$tag ($counter), ";
    if ($i>100)

echo "<p>Clipart with..<br>";
foreach  ($wordsResult as $tag=>$counter){
  echo "with $tag tags: $counter (", round($counter/$total*100,3), "% )  for
example ", $example[$tag], "<br>";
echo "<p>The winner is $thewinner</p>";
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/clipart/attachments/20110112/14ad2671/attachment.html>

More information about the clipart mailing list