Skip to content

Commit ab1bacb

Browse files
committed
Support image and imageList item property types
1 parent cc28af8 commit ab1bacb

File tree

13 files changed

+34
-34
lines changed

13 files changed

+34
-34
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The client is available in the [Maven Central Repository](https://mvnrepository.
1313
<dependency>
1414
<groupId>com.recombee</groupId>
1515
<artifactId>api-client</artifactId>
16-
<version>2.0.1</version>
16+
<version>2.1.0</version>
1717
</dependency>
1818
```
1919

@@ -90,22 +90,24 @@ import java.util.Random;
9090
public class ItemPropertiesExample {
9191
public static void main(String[] args) {
9292

93-
RecombeeClient client = new RecombeeClient("client-test", "jGGQ6ZKa8rQ1zTAyxTc0EMn55YPF7FJLUtaMLhbsGxmvwxgTwXYqmUk5xVZFw98L");
93+
RecombeeClient client = new RecombeeClient("--my-database-id--", "--my-secret-token--");
9494

9595
try {
9696
client.send(new ResetDatabase()); //Clear everything from the database
9797

9898
/*
9999
We will use computers as items in this example
100-
Computers have three properties
100+
Computers have four properties
101101
- price (floating point number)
102102
- number of processor cores (integer number)
103103
- description (string)
104+
- image (url of computer's photo)
104105
*/
105106

106107
client.send(new AddItemProperty("price", "double"));
107108
client.send(new AddItemProperty("num-cores", "int"));
108109
client.send(new AddItemProperty("description", "string"));
110+
client.send(new AddItemProperty("image", "image"));
109111

110112
// Prepare requests for setting a catalog of computers
111113
final ArrayList<Request> requests = new ArrayList<Request>();
@@ -114,13 +116,15 @@ public class ItemPropertiesExample {
114116

115117
for(int i=0; i<NUM; i++)
116118
{
119+
final String itemId = String.format("computer-%s",i);
117120
final SetItemValues req = new SetItemValues(
118-
String.format("computer-%s",i), //itemId
121+
itemId,
119122
//values:
120123
new HashMap<String, Object>() {{
121124
put("price", 600.0 + 400*rand.nextDouble());
122125
put("num-cores", 1 + rand.nextInt(7));
123126
put("description", "Great computer");
127+
put("image", String.format("http://examplesite.com/products/%s.jpg", itemId));
124128
}}
125129
).setCascadeCreate(true); // Use cascadeCreate for creating item
126130
// with given itemId, if it doesn't exist;

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.recombee</groupId>
88
<artifactId>api-client</artifactId>
9-
<version>2.0.1</version>
9+
<version>2.1.0</version>
1010
<name>Recombee API Client</name>
1111
<description>A client library for easy use of the Recombee recommendation API</description>
1212
<url>http://recombee.com</url>

src/main/java/com/recombee/api_client/RecombeeClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ public class RecombeeClient {
8585

8686
final int BATCH_MAX_SIZE = 10000; //Maximal number of requests within one batch request
8787

88-
final String USER_AGENT = "recombee-java-api-client/2.0.1";
88+
final String USER_AGENT = "recombee-java-api-client/2.1.0";
8989

9090
private final OkHttpClient httpClient = new OkHttpClient();
9191

src/main/java/com/recombee/api_client/api_requests/AddItemProperty.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public class AddItemProperty extends Request {
2020
*/
2121
protected String propertyName;
2222
/**
23-
* Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
23+
* Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
2424
*/
2525
protected String type;
2626

2727
/**
2828
* Construct the request
2929
* @param propertyName 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.
30-
* @param type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`
30+
* @param type Value type of the item property to be created. One of: `int`, `double`, `string`, `boolean`, `timestamp`, `set`, `image` or `imageList`.
3131
*/
3232
public AddItemProperty (String propertyName,String type) {
3333
this.propertyName = propertyName;

src/main/java/com/recombee/api_client/api_requests/DeleteViewPortion.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.recombee.api_client.util.HTTPMethod;
1212

1313
/**
14-
* The view portions feature is currently experimental.
1514
* Deletes an existing view portion specified by (`userId`, `itemId`, `sessionId`) from the database.
1615
*/
1716
public class DeleteViewPortion extends Request {

src/main/java/com/recombee/api_client/api_requests/ItemBasedRecommendation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ public class ItemBasedRecommendation extends Request {
110110
*/
111111
protected String minRelevance;
112112
/**
113-
* **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.
113+
* **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`.
114114
*/
115115
protected Double rotationRate;
116116
/**
117-
* **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.
117+
* **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`.
118118
*/
119119
protected Double rotationTime;
120120
/**
@@ -261,15 +261,15 @@ public ItemBasedRecommendation setMinRelevance(String minRelevance) {
261261
}
262262

263263
/**
264-
* @param 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.
264+
* @param 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`.
265265
*/
266266
public ItemBasedRecommendation setRotationRate(double rotationRate) {
267267
this.rotationRate = rotationRate;
268268
return this;
269269
}
270270

271271
/**
272-
* @param 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.
272+
* @param 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`.
273273
*/
274274
public ItemBasedRecommendation setRotationTime(double rotationTime) {
275275
this.rotationTime = rotationTime;

src/main/java/com/recombee/api_client/api_requests/ListItemViewPortions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.recombee.api_client.util.HTTPMethod;
1212

1313
/**
14-
* The view portions feature is currently experimental.
1514
* List all the view portions of an item ever submitted by different users.
1615
*/
1716
public class ListItemViewPortions extends Request {

src/main/java/com/recombee/api_client/api_requests/ListUserViewPortions.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
import com.recombee.api_client.util.HTTPMethod;
1212

1313
/**
14-
* The view portions feature is currently experimental.
1514
* List all the view portions ever submitted by a given user.
1615
*/
1716
public class ListUserViewPortions extends Request {

src/main/java/com/recombee/api_client/api_requests/MergeUsers.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
public class MergeUsers extends Request {
1818

1919
/**
20-
* ID of the source user.
20+
* ID of the targer user.
2121
*/
2222
protected String targetUserId;
2323
/**
24-
* ID of the target user.
24+
* ID of the source user.
2525
*/
2626
protected String sourceUserId;
2727
/**
@@ -31,8 +31,8 @@ public class MergeUsers extends Request {
3131

3232
/**
3333
* Construct the request
34-
* @param targetUserId ID of the source user.
35-
* @param sourceUserId ID of the target user.
34+
* @param targetUserId ID of the targer user.
35+
* @param sourceUserId ID of the source user.
3636
*/
3737
public MergeUsers (String targetUserId,String sourceUserId) {
3838
this.targetUserId = targetUserId;

src/main/java/com/recombee/api_client/api_requests/RecommendItemsToUser.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,11 @@ public class RecommendItemsToUser extends Request {
107107
*/
108108
protected String minRelevance;
109109
/**
110-
* **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.
110+
* **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`.
111111
*/
112112
protected Double rotationRate;
113113
/**
114-
* **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.
114+
* **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`.
115115
*/
116116
protected Double rotationTime;
117117
/**
@@ -245,15 +245,15 @@ public RecommendItemsToUser setMinRelevance(String minRelevance) {
245245
}
246246

247247
/**
248-
* @param 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.
248+
* @param 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`.
249249
*/
250250
public RecommendItemsToUser setRotationRate(double rotationRate) {
251251
this.rotationRate = rotationRate;
252252
return this;
253253
}
254254

255255
/**
256-
* @param 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.
256+
* @param 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`.
257257
*/
258258
public RecommendItemsToUser setRotationTime(double rotationTime) {
259259
this.rotationTime = rotationTime;

0 commit comments

Comments
 (0)