Closed (fixed)
Project:
Recommender API
Version:
6.x-2.0-beta3
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Reporter:
Created:
3 Sep 2009 at 13:41 UTC
Updated:
20 Jun 2011 at 13:02 UTC
I'd like to use the Recommender API with the Flag module to generate node output similar to the Similar Groups module. ie. Users who flagged this node also flagged these nodes. The flag_content table in the database has columns for uid ($field_mouse) and content_id ($field_cheese) and I can generate the number of users who flagged each node via Views. So in this case what should $field_weight be?
Comments
Comment #1
danithaca commentedI'll take a look soon.
Comment #2
danithaca commentedThis is a good question. There are 2 ways you can do this:
1) Use any table field that has the constant 1. For example, you can use {node}->status. Basically, the $field_weight variable tells RecAPI that how important a $mouse_id<->$cheese_id pair would be. In your case, suppose a user can make 3 flags on a node, then the weight would be 3. But since a user can only flag once on one node, the weight should always be the constant 1.
2) Alternatively, you can use a SQL query in the $field_table variable for maximum flexibility. For an example, you can refer to http://drupal.org/project/uc_rec. A code snippet is copied here.
Remember to use the param 'missing'=>'zero'. That tells RecAPI to treat all the missing uid<->content_id pairs as 0 flags.
If you submit you code here, I can take a look too.
Please feel free to ask other questions. As of now, I'll change the issue status to 'fixed'.
Comment #3
hitfactory commentedI managed to get a block of results by aping the Similar Groups module and calling recommender_similarity_classical. The following returns results:
But...the recommender_item2items used in the UC module is closer to what I am looking for but calling recommender_item2items with the same SQL returns no results.
Any idea why that would be?
Comment #4
hitfactory commentedComment #5
danithaca commentedrecommender_item2item is very similar to recommender_classical or recommender_user2user. Only difference is that item2item tries find similarities between items (or "cheese" in my terminology), where as user2user finds similarity between users (or "mouse" in my terminology) and then give recommendations.
So, you probably need to switch $field_mouse and $field_cheese in item2item. Code might look like
Comment #6
chaps2 commentedTo use Recommender API with Flag try the Flag Recommender module.
Comment #7
danithaca commented@chaps2: Thanks for writing the Flag Recommender module. I have updated it on this module's description page.