|
CWIS Developer Documentation
|
Recommendation engine. More...

Public Member Functions | |
| __construct (&$DB, $ItemTableName, $RatingTableName, $ItemIdFieldName, $UserIdFieldName, $RatingFieldName, $ContentFields) | |
| Object constructor. More... | |
| DebugLevel ($Setting) | |
| Set level for debugging output. More... | |
| Recommend ($UserId, $StartingResult=0, $NumberOfResults=10) | |
| Recommend items for specified user. More... | |
| AddResultFilterFunction ($FunctionName) | |
| Add function to be called to filter returned recommendation list. More... | |
| NumberOfResults () | |
| Get number of recommendations generated. More... | |
| SearchTime () | |
| Get time it took to generate the most recent recommendation. More... | |
| GetSourceList ($UserId, $RecommendedItemId) | |
| Return list of items used to generate recommendation of specified item. More... | |
| FindSimilarItems ($ItemId, $FieldList=NULL) | |
| Dynamically generate and return list of items similar to specified item. More... | |
| RecommendFieldValues ($ItemId, $FieldList=NULL) | |
| Dynamically generate and return list of recommended field values for item. More... | |
| UpdateForItems ($StartingItemId, $NumberOfItems) | |
| Update recommender data for range of items. More... | |
| UpdateForItem ($ItemId, $FullPass=FALSE) | |
| Update recommender data for specified item. More... | |
| DropItem ($ItemId) | |
| Drop item from stored recommender data. More... | |
| PruneCorrelations () | |
| Prune any stored correlation values that are below-average. More... | |
| GetItemIds () | |
| Retrieve all item IDs. More... | |
Static Public Member Functions | |
| static | ClearCaches () |
| Clear internal caches of item and correlation data. More... | |
Public Attributes | |
| const | CONTENTFIELDTYPE_TEXT = 1 |
| const | CONTENTFIELDTYPE_NUMERIC = 2 |
| const | CONTENTFIELDTYPE_CONTROLLEDNAME = 3 |
| const | CONTENTFIELDTYPE_DATE = 4 |
| const | CONTENTFIELDTYPE_DATERAMGE = 5 |
Protected Member Functions | |
| LoadItemIds () | |
| Load internal item ID cache (if not already loaded). More... | |
| GetFieldData ($ItemId, $FieldName) | |
| Get data for field. More... | |
| CalculateContentCorrelation ($ItemIdA, $ItemIdB, $FieldList=NULL) | |
| Calculate content correlation between two items and return value to caller. More... | |
| UpdateContentCorrelation ($ItemIdA, $ItemIdB) | |
| Calculate content correlation between two items and update in DB. More... | |
| NormalizeAndParseText ($Text) | |
| Normalize text string and parse into words. More... | |
| CalcTextCorrelation ($WordsA, $WordsB) | |
| Get value for correlation between two sets of words. More... | |
| ContentCorrelation ($ItemIdA, $ItemIdB, $NewCorrelation=-1) | |
| Get/set stored value for correlation between two items. More... | |
| FilterOnSuppliedFunctions ($Results) | |
| Run results through supplied filter functions. More... | |
Recommendation engine.
Definition at line 13 of file Recommender.php.
| Recommender::__construct | ( | & | $DB, |
| $ItemTableName, | |||
| $RatingTableName, | |||
| $ItemIdFieldName, | |||
| $UserIdFieldName, | |||
| $RatingFieldName, | |||
| $ContentFields | |||
| ) |
Object constructor.
| object | $DB | Database to use. |
| string | $ItemTableName | Name of database table containing items. |
| string | $RatingTableName | Name of database table used to store item ratings. |
| string | $ItemIdFieldName | Name of column in ratings table that contains item IDs. |
| string | $UserIdFieldName | Name of column in ratings table that contains user IDs. |
| string | $RatingFieldName | Name of column in ratings table that contains rating value. |
| array | $ContentFields | Array of arrays with information about content fields, indexed by field identifiers, with the second-level arrays having "DBFieldName", "Weight", and "FieldType" elements. |
Definition at line 41 of file Recommender.php.
References DebugLevel().
| Recommender::AddResultFilterFunction | ( | $FunctionName | ) |
Add function to be called to filter returned recommendation list.
| callable | $FunctionName | Filter function, that accepts an item ID and returns TRUE if item should be filtered out of results. |
Definition at line 195 of file Recommender.php.
|
protected |
Get value for correlation between two sets of words.
| array | $WordsA | First set of words. |
| array | $WordsB | Second set of words. |
Definition at line 883 of file Recommender.php.
Referenced by CalculateContentCorrelation().

|
protected |
Calculate content correlation between two items and return value to caller.
| int | $ItemIdA | ID for first item. |
| int | $ItemIdB | ID for second item. |
| array | $FieldList | List of fields to correlate. (OPTIONAL, defaults to all fields) |
Definition at line 676 of file Recommender.php.
References CalcTextCorrelation(), DebugLevel(), and GetFieldData().
Referenced by FindSimilarItems(), and UpdateContentCorrelation().

|
static |
Clear internal caches of item and correlation data.
This is primarily intended for situations where memory may have run low.
Definition at line 595 of file Recommender.php.
|
protected |
Get/set stored value for correlation between two items.
| int | $ItemIdA | ID of first item. |
| int | $ItemIdB | ID of second item. |
| int | $NewCorrelation | New value for correlation. (OPTIONAL) |
Definition at line 899 of file Recommender.php.
Referenced by UpdateContentCorrelation().

| Recommender::DebugLevel | ( | $Setting | ) |
Set level for debugging output.
| int | $Setting | New debugging output level. |
Definition at line 67 of file Recommender.php.
Referenced by __construct(), CalculateContentCorrelation(), FindSimilarItems(), Recommend(), RecommendFieldValues(), UpdateContentCorrelation(), UpdateForItem(), and UpdateForItems().

| Recommender::DropItem | ( | $ItemId | ) |
Drop item from stored recommender data.
| int | $ItemId | ID of item to drop. |
Definition at line 551 of file Recommender.php.
|
protected |
Run results through supplied filter functions.
| array | $Results | Results to filter. |
Definition at line 956 of file Recommender.php.
Referenced by FindSimilarItems().

| Recommender::FindSimilarItems | ( | $ItemId, | |
$FieldList = NULL |
|||
| ) |
Dynamically generate and return list of items similar to specified item.
| int | $ItemId | ID of item. |
| array | $FieldList | List of fields to consider. (OPTIONAL, defaults to all fields) |
Definition at line 271 of file Recommender.php.
References CalculateContentCorrelation(), DebugLevel(), FilterOnSuppliedFunctions(), and LoadItemIds().
Referenced by RecommendFieldValues().

|
protected |
Get data for field.
| int | $ItemId | ID of item to retrieve data for. |
| string | $FieldName | Name of field. |
Definition at line 644 of file Recommender.php.
References NormalizeAndParseText().
Referenced by CalculateContentCorrelation().

| Recommender::GetItemIds | ( | ) |
| Recommender::GetSourceList | ( | $UserId, | |
| $RecommendedItemId | |||
| ) |
Return list of items used to generate recommendation of specified item.
| int | $UserId | ID of user that recommendation was generated for. |
| int | $RecommendedItemId | ID of item that was recommended. |
Definition at line 228 of file Recommender.php.
|
protected |
Load internal item ID cache (if not already loaded).
Definition at line 626 of file Recommender.php.
Referenced by FindSimilarItems(), UpdateForItem(), and UpdateForItems().

|
protected |
Normalize text string and parse into words.
| string | $Text | Text string. |
Definition at line 785 of file Recommender.php.
Referenced by GetFieldData().

| Recommender::NumberOfResults | ( | ) |
Get number of recommendations generated.
Definition at line 205 of file Recommender.php.
| Recommender::PruneCorrelations | ( | ) |
Prune any stored correlation values that are below-average.
Definition at line 562 of file Recommender.php.
| Recommender::Recommend | ( | $UserId, | |
$StartingResult = 0, |
|||
$NumberOfResults = 10 |
|||
| ) |
Recommend items for specified user.
| int | $UserId | ID of user. |
| int | $StartingResult | Index into list of recommended items (first item is 0). (OPTIONAL, defaults to 0) |
| int | $NumberOfResults | Number of items to return. (OPTIONAL, defaults to 10) |
Definition at line 83 of file Recommender.php.
References DebugLevel().
| Recommender::RecommendFieldValues | ( | $ItemId, | |
$FieldList = NULL |
|||
| ) |
Dynamically generate and return list of recommended field values for item.
| int | $ItemId | ID of item. |
| array | $FieldList | List of fields to recommend values for. (OPTIONAL, defaults to all fields) |
Definition at line 339 of file Recommender.php.
References DebugLevel(), and FindSimilarItems().
| Recommender::SearchTime | ( | ) |
Get time it took to generate the most recent recommendation.
Definition at line 214 of file Recommender.php.
|
protected |
Calculate content correlation between two items and update in DB.
| int | $ItemIdA | ID for first item. |
| int | $ItemIdB | ID for second item. |
Definition at line 765 of file Recommender.php.
References CalculateContentCorrelation(), ContentCorrelation(), and DebugLevel().
Referenced by UpdateForItem().

| Recommender::UpdateForItem | ( | $ItemId, | |
$FullPass = FALSE |
|||
| ) |
Update recommender data for specified item.
| int | $ItemId | ID of item to update. |
| bool | $FullPass | If TRUE, update is assumed to be part of an update of all items. (OPTIONAL, default to FALSE) |
Definition at line 521 of file Recommender.php.
References DebugLevel(), LoadItemIds(), and UpdateContentCorrelation().
Referenced by UpdateForItems().

| Recommender::UpdateForItems | ( | $StartingItemId, | |
| $NumberOfItems | |||
| ) |
Update recommender data for range of items.
| int | $StartingItemId | ID of first item to update. |
| int | $NumberOfItems | Number of items to update. |
Definition at line 474 of file Recommender.php.
References DebugLevel(), LoadItemIds(), and UpdateForItem().
| const Recommender::CONTENTFIELDTYPE_CONTROLLEDNAME = 3 |
Definition at line 20 of file Recommender.php.
| const Recommender::CONTENTFIELDTYPE_DATE = 4 |
Definition at line 21 of file Recommender.php.
Referenced by SPTRecommender\__construct().
| const Recommender::CONTENTFIELDTYPE_DATERAMGE = 5 |
Definition at line 22 of file Recommender.php.
| const Recommender::CONTENTFIELDTYPE_NUMERIC = 2 |
Definition at line 19 of file Recommender.php.
Referenced by SPTRecommender\__construct().
| const Recommender::CONTENTFIELDTYPE_TEXT = 1 |
Definition at line 18 of file Recommender.php.
Referenced by SPTRecommender\__construct().