mysql_connect('localhost','bcspy','testpass1');
mysql_select_db('bcspy');
?>
Tag Clusters
$documents = mysql_query("SELECT * FROM documents");
while($documents_row = mysql_fetch_object($documents)) {
echo "".$documents_row->doc_id." - Dokument: ".$documents_row->doc_name."
";
echo "URL: ".$documents_row->doc_url."
";
echo "Tags: ";
$tags = mysql_query("SELECT * FROM tags WHERE doc_id = $documents_row->doc_id");
while($tags_row = mysql_fetch_object($tags)) {
echo "".$tags_row->tag_name." (".$tags_row->tag_count."), ";
}
echo "
";
}
$ourTagA = "Prolog";
$ourTagB = "development";
$both = 0;
echo $ourTagA." + ".$ourTagB."
";
$tagA = mysql_query("SELECT * FROM tags WHERE tag_name = '$ourTagA'");
$tagAcount = mysql_num_rows($tagA);
echo "Dokumentanzahl mit Tag ".$ourTagA.": ".$tagAcount."
";;
$tagB = mysql_query("SELECT * FROM tags WHERE tag_name = '$ourTagB'");
while($tagB_row = mysql_fetch_object($tagB)) {
$tagAtoo = mysql_query("SELECT * FROM tags WHERE tag_name = '$ourTagA' AND doc_id = $tagB_row->doc_id");
if (mysql_num_rows($tagAtoo) != 0) {
$both = $both + 1;
}
}
$tagBcount = mysql_num_rows($tagB);
echo "Dokumentanzahl mit Tag ".$ourTagB.": ".$tagBcount."
";
echo "Dokumentanzahl mit beiden Tags zusammen: ".$both."
";
$koinzidenz = (2 * $both) / ($tagAcount + $tagBcount);
echo "Koinzidenzwert: ".$koinzidenz;
?>