Skip to content

Commit

Permalink
Support image and imageList item property types
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraFiedler committed Apr 5, 2018
1 parent 30a42dd commit 255f5f4
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 22 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,19 @@ client = RecombeeClient('--my-database-id--', '--my-secret-token--')
client.send(ResetDatabase.new) # Clear everything from the database

# We will use computers as items in this example
# Computers have three properties
# Computers have five properties
# - price (floating point number)
# - number of processor cores (integer number)
# - description (string)
# - date from which it is in stock (timestamp)
# - image (url of computer's photo)

# Add properties of items
client.send(AddItemProperty.new('price', 'double'))
client.send(AddItemProperty.new('num-cores', 'int'))
client.send(AddItemProperty.new('description', 'string'))
client.send(AddItemProperty.new('time', 'timestamp'))
client.send(AddItemProperty.new('in_stock_from', 'timestamp'))
client.send(AddItemProperty.new('image', 'image'))

# Prepare requests for setting a catalog of computers
requests = (1..NUM).map do |i|
Expand All @@ -95,7 +98,8 @@ requests = (1..NUM).map do |i|
'price' => rand(15000.0 .. 25000.0),
'num-cores' => rand(1..8),
'description' => 'Great computer',
'time' => DateTime.now
'in_stock_from' => DateTime.now,
'image' => "http://examplesite.com/products/computer-#{i}.jpg"
},
#optional parameters:
{
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class RecombeeClient
include HTTParty

BATCH_MAX_SIZE = 10000
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.0.1'}
USER_AGENT = {'User-Agent' => 'recombee-ruby-api-client/2.1.0'}

##
# - +account+ -> Name of your account at Recombee
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/api/add_item_property.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class AddItemProperty < ApiRequest
# * *Required arguments*
# - +property_name+ -> Name of the item property to be created. Currently, the following names are reserved:`id`, `itemid`, case insensitively. Also, the length of the property name must not exceed 63 characters.
#
# - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
# - +type+ -> Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
#
#
def initialize(property_name, type)
Expand Down
2 changes: 0 additions & 2 deletions lib/recombee_api_client/api/delete_view_portion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module RecombeeApiClient
require_relative '../errors'

##
#The view portions feature is currently experimental.
#
#Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
#
class DeleteViewPortion < ApiRequest
Expand Down
4 changes: 2 additions & 2 deletions lib/recombee_api_client/api/item_based_recommendation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ class ItemBasedRecommendation < ApiRequest
#
# - +minRelevance+ -> **Expert option** If the *targetUserId* is provided: Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested qualit, and may return less than *count* items when there is not enough data to fulfill it.
#
# - +rotationRate+ -> **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items.
# - +rotationRate+ -> **Expert option** If the *targetUserId* is provided: If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.01`.
#
# - +rotationTime+ -> **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
# - +rotationTime+ -> **Expert option** If the *targetUserId* is provided: Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
#
# - +expertSettings+ -> Dictionary of custom options.
#
Expand Down
2 changes: 0 additions & 2 deletions lib/recombee_api_client/api/list_item_view_portions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module RecombeeApiClient
require_relative '../errors'

##
#The view portions feature is currently experimental.
#
#List all the view portions of an item ever submitted by different users.
#
class ListItemViewPortions < ApiRequest
Expand Down
2 changes: 0 additions & 2 deletions lib/recombee_api_client/api/list_user_view_portions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module RecombeeApiClient
require_relative '../errors'

##
#The view portions feature is currently experimental.
#
#List all the view portions ever submitted by a given user.
#
class ListUserViewPortions < ApiRequest
Expand Down
4 changes: 2 additions & 2 deletions lib/recombee_api_client/api/recommend_items_to_user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ class RecommendItemsToUser < ApiRequest
#
# - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested relevancy, and may return less than *count* items when there is not enough data to fulfill it.
#
# - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items.
# - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.1`.
#
# - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
# - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
#
# - +expertSettings+ -> Dictionary of custom options.
#
Expand Down
6 changes: 2 additions & 4 deletions lib/recombee_api_client/api/set_view_portion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ module RecombeeApiClient
require_relative '../errors'

##
#The view portions feature is currently experimental.
#
#Sets viewed portion of an item (for example a video or article) by a user (at a session).
#If you send new request with the same (`userId`, `itemId`, `sessionId`), the portion gets updated.
#
Expand All @@ -21,10 +19,10 @@ class SetViewPortion < ApiRequest
# * *Required arguments*
# - +user_id+ -> User who viewed a portion of the item
# - +item_id+ -> Viewed item
# - +portion+ -> Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ).
# - +portion+ -> Viewed portion of the item (number between 0.0 (viewed nothing) and 1.0 (viewed full item) ). It should be the really viewed part of the item, no matter seeking, so for example if the user seeked immediately to half of the item and then viewed 10% of the item, the `portion` should still be `0.1`.
#
# * *Optional arguments (given as hash optional)*
# - +sessionId+ -> Id of session in which the user viewed the item
# - +sessionId+ -> ID of session in which the user viewed the item. Default is `null` (`None`, `nil`, `NULL` etc. depending on language).
# - +timestamp+ -> UTC timestamp of the rating as ISO8601-1 pattern or UTC epoch time. The default value is the current time.
# - +cascadeCreate+ -> Sets whether the given user/item should be created if not present in the database.
#
Expand Down
4 changes: 2 additions & 2 deletions lib/recombee_api_client/api/user_based_recommendation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@ class UserBasedRecommendation < ApiRequest
#
# - +minRelevance+ -> **Expert option** Specifies the threshold of how much relevant must the recommended items be to the user. Possible values one of: "low", "medium", "high". The default value is "low", meaning that the system attempts to recommend number of items equal to *count* at any cost. If there are not enough data (such as interactions or item properties), this may even lead to bestseller-based recommendations to be appended to reach the full *count*. This behavior may be suppressed by using "medium" or "high" values. In such case, the system only recommends items of at least the requested qualit, and may return less than *count* items when there is not enough data to fulfill it.
#
# - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items.
# - +rotationRate+ -> **Expert option** If your users browse the system in real-time, it may easily happen that you wish to offer them recommendations multiple times. Here comes the question: how much should the recommendations change? Should they remain the same, or should they rotate? Recombee API allows you to control this per-request in backward fashion. You may penalize an item for being recommended in the near past. For the specific user, `rotationRate=1` means maximal rotation, `rotationRate=0` means absolutely no rotation. You may also use, for example `rotationRate=0.2` for only slight rotation of recommended items. Default: `0.1`.
#
# - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized.
# - +rotationTime+ -> **Expert option** Taking *rotationRate* into account, specifies how long time it takes to an item to recover from the penalization. For example, `rotationTime=7200.0` means that items recommended less than 2 hours ago are penalized. Default: `7200.0`.
#
# - +expertSettings+ -> Dictionary of custom options.
#
Expand Down
2 changes: 1 addition & 1 deletion lib/recombee_api_client/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RecombeeApiClient
VERSION = '2.0.1'
VERSION = '2.1.0'
end

0 comments on commit 255f5f4

Please sign in to comment.