Using autocategorise with multiple taxonomies?
malukalu - April 24, 2009 - 16:42
| Project: | autocategorise |
| Version: | 6.x-1.4 |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | needs review |
Jump to:
Description
This doesn't seem to work when i enable autocategorise with two vocabularies. It seems to choose one or the other. I have a few hundred nodes already in my system. I set up two taxonomies ( one for cities, one for animals in my example). Once i populate the taxonomies i hit the autocategorise button for each taxonomy. This results in my nodes being tagged by the taxonomy I last hit autocatogorise in.. Further more i tried deleting my nodes and re-creating them ( from an rss feed / feedapi) and it had the same issue ( only ony taxonomy would auto tag)... any ideas? Should this work?

#1
According to what I've read, this is *supposed* to work. But, I had the exact same experience a few weeks ago. The current version only seems to work for one vocabulary at a time. I also tried using the autocategorise button and importing nodes with the same result. I've seen several posts about similar problems for earlier versions and notes that the problem has been fixed, but I don't believe it has. I gave up on using it until someone takes over the project and fixes the problems.
#2
I don't have time to sort this out.
I'm releasing a dev version instead, and inviting y'all to send your fixes.
#3
I've installed 6.x-1.4 on a site with existing content categorized by the OpenCalais module.
Calais provides very granular terms. For example in the medical realm, it may tag a story with terms like post-partum depression, lymphoma, etc.
I want Autocategorise to additionally tag the story with a higher-level, or or broad term, such as Health, from a separate vocabulary of such broad topics.
Autocategorise does that successfully on my install, once I've fed in a list of synonyms.
But when activated, Autocategorise also deletes all but one of the Calais terms. Not all of them, but rather all but one.
#4
Got the same problems. I fixed it by rewriting the following function. It seems to work for me, but testing will be necessery. Required terms are not implemented...
<?php
function _apply_vocab_to_node($vid, $node, $terms, $vocab){
if (!count($terms)) {
drupal_set_message('This vocabulary has no terms in it');
return;
}
// get all assigned terms
$results = db_query("SELECT t.tid FROM {term_node} AS t LEFT JOIN {term_data} AS d ON t.tid=d.tid WHERE t.nid=%d AND t.vid=%d AND d.vid=%d", $node->nid, $node->vid, $vocab->vid);
$node_terms = array();
while ($result=db_fetch_object($results)) {
$node_terms[] = $result->tid;
}
// Append title to body of node
$haystack = strtolower($node->title .' '. $node->body);
foreach ($terms as $tid => $synonyms) {
// only one term is allowed and we allready have one
if(!empty($node_terms) && !$vocab->multiple) {break;}
// stop checking this tid when it is already assigned to the node
if(in_array($tid, $node_terms)) {continue;}
foreach ($synonyms as $synonym) {
//This will compare parts of words using strpos instead of whole words
if (is_int(strpos($haystack, strtolower($synonym)))){
db_query("INSERT INTO {term_node} (nid, vid, tid) VALUES (%d, %d, %d)", $node->nid, $node->vid, $tid);
$node_terms[] = $tid;
// no check for further synonyms, we assigned the tid
break;
}
}
}
}
?>
#5
Ok see head.
I didn't use the code above, but preferred to stick with the taxonomy module function taxonomy_node_save()
Can somebody test a bit and let me know?