Nodes using prefill from Calais returning with nothing ( using Taxonomy MLT)

malukalu - February 26, 2009 - 03:03
Project:More Like This
Version:6.x-1.1
Component:Code
Category:bug report
Priority:normal
Assigned:febbraro
Status:postponed (maintainer needs more info)
Description

So I have this piece of content :
President Barack Obama's first budget will seek $634 billion over 10 years as a down payment on health care reform _ a little more than half what it may ultimately cost to provide every American with medical coverage. The budget also proposes a mix of tax cuts for the middle class and tax increases for upper-income households. That includes extending beyond 2010 the $400 annual tax cut in the stimulus plan just signed into law.

I used Calais with a relevancy threshold of .45 and got back the terms:
Person/Barack Obama
Calais Document Category/ Technology

Looking at the database i see a relevance score of .591 and 1.00 respectively.

I have MLT configured with a relevance score of .33 .

When i go to this node and click on the edit tab i see that the Prefill with calis term check box is marked but the greyed MLT Terms field is empty. Consequently the MLT taxonomy block displays no results. If i go into the node and uncheck the PreFill with Calais terms checkbox and select both of these terms and hit save it works ( of course :))

Am I missing some other config step? I uninstalled and reinstalled my MLT module to make sure i didnt have any only data/schema stuff there and I still see this problem. I should mention that i have another taxonomy thats not a calais one that ive applied to this node as well ( but dont care to use for MLT). I'm using taxonomy hide to hide this category (in case thats a problem)

Cheers!

#1

febbraro - March 2, 2009 - 21:10
Status:active» postponed (maintainer needs more info)

Under general, what is your global term relevancy threshold?

Under taxonomy, What do you have for number of results? and for Node Relevancy Threshold for MLT Taxonomy?

The configs can be a bit confusing, there may be a problem there.

#2

malukalu - March 2, 2009 - 21:38

Under general i have Global term relevancy set to .33. Under taxonomy i have the number of results set to 10. I just checked the node relevancy threshold for my node type and it had nothing entered. I just tried entering the value .1 and it seems to work fine so i guess thats what i was missing?

#3

malukalu - March 2, 2009 - 21:43

With the latest release should the nodes that i create automatically ( in my case via feedapi) have the prefill with Calais terms checkbox enabled if i have it enabled in the MLT configuration page?
I thought i had this working but as i look at my recent nodes that were created it seems like that checkbox is no longer checked and i have to check the prefill with calais checkbox with each node now.

#4

febbraro - March 2, 2009 - 22:07

So for FeedAPI populated nodes, are you getting MLT terms applied from Calais, but the checkbox is disabled, or no terms either?

#5

malukalu - March 3, 2009 - 00:11

The nodes are getting calias suggested terms applied to them automatically. I can see those show up on the node taxonomy terms just fine. When i go to edit one of these existing nodes i can see that "Prefill from Calais" check box is not checked and the taxonomy check box is checked. If click the check box for the "Prefill from Calais" checkbox and hit save then i can see results from the taxonomy MLT block

#6

patchak - May 9, 2009 - 16:31

I have a somehow similar situation, I would like to have the pre-fill from Calais checkbox checked automatically on all nodes, so that the MLT block would be working by default.

I just installed this module on a site with more than 30 000 nodes and I was wondering how to apply this settings to all the nodes now?

thanks for any help,
Patchak

#7

malukalu - May 12, 2009 - 18:29

Only way i got this to work was to hack the calais module a bit to save the MLT settings and suggested terms via its nodeapi call. What I did is a bit bugy as i see error message in the logs but it seems to work fine. Basically every node that is loaded/viewed is checked to see if the MLT settings have been saved . If it hasnt it does so then otherwise its a nop which it does now... I would imagine the Phase2 guys would have a much more elegant approach.. like applying in bulk ( hint hint) as well as having the option to apply the suggested terms for MLT by default

#8

patchak - May 12, 2009 - 18:50

malukalu : maybe you can share some code to help jumpstart this feature? Would be really cool, we are also needing to use this automatically and we would love doing it without hacking the module too much ;)

This is a great feature request, as I think with calais it should work automatically, especially for the people who use feedapi...
Patchak

#9

patchak - May 31, 2009 - 14:38

Malukalu : ping ?? ;)

Any chance you could share your code so everyone could use it?
thanks a lot!!
Patchak

#10

malukalu - June 1, 2009 - 20:33

Here it is. Like i said its a bit of a hack but it seems to work... i do get some duplicate key entry problems once in a while but im not sure if its related to my changes.
here is the original morelikethis_nodeapi

/**
* Implementation of hook_nodeapi().
*/
function morelikethis_nodeapi(&$node, $op) {
  switch ($op) {
    case 'insert':
    case 'update':
    if(property_exists($node, 'morelikethis')) {
      _morelikethis_set_calais_defaults($node);
        morelikethis_save($node, $node->morelikethis);
      }
      break;
    case 'delete':
      db_query('DELETE FROM {morelikethis} WHERE nid = %d', $node->nid);
      db_query('DELETE FROM {morelikethis_node_settings} WHERE vid = %d', $node->vid);
      break;
    case 'load': 
    case 'prepare':
      $mlt_node_settings = _morelikethis_get_node_settings($node->vid);
      _morelikethis_set_node_settings($node, $mlt_node_settings);
    break;
  }
}

Here is my updated method

/**
* Implementation of hook_nodeapi().
*/
function morelikethis_nodeapi(&$node, $op) {
  switch ($op) {
    case 'insert':
    case 'update':
    if (!property_exists($node, 'morelikethis')) {
    set_default_node_settings($node);
    }
    if(property_exists($node, 'morelikethis')) {
      _morelikethis_set_calais_defaults($node);
        morelikethis_save($node, $node->morelikethis);
      }
      break;
    case 'delete':
      db_query('DELETE FROM {morelikethis} WHERE nid = %d', $node->nid);
      db_query('DELETE FROM {morelikethis_node_settings} WHERE vid = %d', $node->vid);
      break;
    case 'load': 
    case 'prepare':
  if (!property_exists($node, 'morelikethis')) {
    set_default_node_settings($node);
    _morelikethis_set_calais_defaults($node);
        morelikethis_save($node, $node->morelikethis);
    }
      $mlt_node_settings = _morelikethis_get_node_settings($node->vid);
      _morelikethis_set_node_settings($node, $mlt_node_settings);
    break;
  }
}

Basically i add this to the 'update'

    if (!property_exists($node, 'morelikethis')) {
    set_default_node_settings($node);
    }

and this to the the 'prepare'

  if (!property_exists($node, 'morelikethis')) {
    set_default_node_settings($node);
    _morelikethis_set_calais_defaults($node);
        morelikethis_save($node, $node->morelikethis);
           }

and here is my method i added set_default_node_settings

/**
* Custom Default node settings . Enables prefill with calais and all the contrib modules
*
* @param unknown_type $node
*/
function set_default_node_settings($node)
{
    $key = drupal_strtolower($node->type);
   
    if(!_morelikethis_is_enabled($key))
      return;
    $node->morelikethis['prefill-with-calais'] = TRUE;
$terms = drupal_implode_tags(morelikethis_load($node->vid));
$node->morelikethis['terms']= $terms;
$services = _morelikethis_providers();
    $options = array();
    foreach($services as $key => $service){
      $options[$key] = $service['#title'];
    }
    $contribs_enabled = array_keys($options);
    $node->morelikethis["enabled-contribs"]=$contribs_enabled;
}

You dont need the prepare part if you are not worried about existing nodes i think. I had alot of existing content for which i didnt wan to go back and re-edit each one. Otherwise all you should need is the change to the "insert/update" bit which accounts for nodes that are being inserted.... sorry for the messy code!!

#11

febbraro - June 10, 2009 - 19:48
Assigned to:Anonymous» febbraro

For this I think you are generally on the right path, but I think you can make it much more specific to handling the bulk processing from Calais scenario.

Instead of calling set_default_node_settings from nodeapi, instead you can rename set_default_node_settings to morelikethis_calais_postprocess which is an implementation of hook_calais_postprocess.

In the postprocess, check that the type is enabled for morelikethis and if the property morelikethis does not exist and then you can set those defaults. That is how I would implement it anyway. If you do chose to do it that way post a patch up here, we would love to integrate that back into morelikethis.

Thanks for sticking with it, sorry I have not been more of a help recently.

#12

deltab - October 25, 2009 - 06:31

subscribing

 
 

Drupal is a registered trademark of Dries Buytaert.