Merge branch 'develop'
diff --git a/README.md b/README.md
index d15accf..673980d 100644
--- a/README.md
+++ b/README.md
@@ -101,9 +101,21 @@
// assume you have created an itemrec engine named 'engine1'
// we try to get top 10 recommendations for a user (user ID 5)
$client->identify('5');
- $command = $client->getCommand('itemrec_get_top_n', array('pio_engine' => 'engine1', 'pio_n' => 10))
+ $command = $client->getCommand('itemrec_get_top_n', array('pio_engine' => 'engine1', 'pio_n' => 10));
$rec = $client->execute($command);
print_r($rec);
} catch (Exception $e) {
- echo 'Caught exception: ', $e->getMessage(), "\n";
+ echo 'Caught exception: ', $e->getMessage(), "\n";
+ }
+
+### Retrieving Top N Similar Items for an Item
+
+ try {
+ // assume you have created an itemsim engine named 'engine2'
+ // we try to get top 10 similar items for an item (item ID 6)
+ $command = $client->getCommand('itemsim_get_top_n', array('pio_iid' => '6', 'pio_engine' => 'engine1', 'pio_n' => 10));
+ $rec = $client->execute($command);
+ print_r($rec);
+ } catch (Exception $e) {
+ echo 'Caught exception: ', $e->getMessage(), "\n";
}
diff --git a/src/PredictionIO/Command/CreateItem.php b/src/PredictionIO/Command/CreateItem.php
index 99248d9..c3928b8 100644
--- a/src/PredictionIO/Command/CreateItem.php
+++ b/src/PredictionIO/Command/CreateItem.php
@@ -42,7 +42,7 @@
/**
* Set the "itypes" parameter for the current command
*
- * $itypes can be supplied as an array of integers, or a "," delimited list of integers.
+ * $itypes can be supplied as an array of strings, or a "," delimited list of strings.
*
* @param array|string $itypes Item types
*
diff --git a/src/PredictionIO/Command/ItemsimGetTopN.php b/src/PredictionIO/Command/ItemsimGetTopN.php
new file mode 100644
index 0000000..5108758
--- /dev/null
+++ b/src/PredictionIO/Command/ItemsimGetTopN.php
@@ -0,0 +1,124 @@
+<?php
+
+namespace PredictionIO\Command;
+
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Service\Command\AbstractCommand;
+
+/**
+ * ItemSim Engine Get Top N Similar Items for an Item
+ *
+ * Retrieve top N similar items for this specific item.
+ *
+ * @guzzle engine type="string" required="true"
+ * @guzzle iid type="string" required="true"
+ * @guzzle n type="integer" required="true"
+ * @guzzle itypes type="string"
+ * @guzzle latlng type="string"
+ * @guzzle within type="float"
+ * @guzzle unit type="enum:km,mi"
+ */
+class ItemsimGetTopN extends AbstractCommand
+{
+ /**
+ * Set the "engine" parameter for the current command
+ *
+ * @param string $engine Engine Name
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setEngine($engine)
+ {
+ return $this->set('pio_engine', $engine);
+ }
+
+ /**
+ * Set the "iid" parameter for the current command
+ *
+ * @param string $iid Item ID
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setIid($iid)
+ {
+ return $this->set('pio_iid', $iid);
+ }
+
+ /**
+ * Set the "n" parameter for the current command
+ *
+ * @param integer $n N
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setN($n)
+ {
+ return $this->set('pio_n', $n);
+ }
+
+ /**
+ * Set the "itypes" parameter for the current command
+ *
+ * $itypes can be supplied as an array of integers, or a "," delimited list of integers.
+ *
+ * @param array|string $itypes Item types
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setItypes($itypes)
+ {
+ if (is_array($itypes)) {
+ return $this->set('pio_itypes', implode(',', $itypes));
+ } else {
+ return $this->set('pio_itypes', $itypes);
+ }
+ }
+
+ /**
+ * Set the "latlng" parameter for the current command
+ *
+ * In "latitude,longitude" format, e.g. "20.17,114.08"
+ *
+ * @param string $latlng Latitude and longitude
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setLatlng($latlng)
+ {
+ return $this->set('pio_latlng', $latlng);
+ }
+
+ /**
+ * Set the "within" parameter for the current command
+ *
+ * @param float $within Radius
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setWithin($within)
+ {
+ return $this->set('pio_within', $within);
+ }
+
+ /**
+ * Set the "unit" parameter for the current command
+ *
+ * @param string $unit Unit of radius
+ *
+ * @return ItemsimGetTopN
+ */
+ public function setUnit($unit)
+ {
+ return $this->set('pio_unit', $unit);
+ }
+
+ /**
+ * Create the request object that will carry out the command. Used internally by Guzzle.
+ */
+ protected function build()
+ {
+ $this->request = $this->client->createRequest(RequestInterface::GET, 'engines/itemsim/' . $this->get('pio_engine') . '/topn', null, $this->getAll());
+ }
+}
+
+?>
\ No newline at end of file