Skip to content

Commit

Permalink
publish php apidocs 1.12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
seth-mg committed Feb 6, 2019
2 parents 57586ae + f02c39e commit 3ebe18f
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
node {
node ("docker-light") {
def SOURCEDIR = pwd()
try {
stage("Clean up") {
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<<<<<<< HEAD
=======
[![Build Status](https://travis-ci.org/rosette-api/php.svg?branch=develop)](https://travis-ci.org/rosette-api/php)

>>>>>>> develop
# PHP client binding for Rosette API #
See the wiki for more information.

## Installation ##
`composer require "rosette/api: ~1.8"`
`composer require "rosette/api"`

If the version you are using is not [the latest from Packagist](https://packagist.org/packages/rosette/api),
please check for its [**compatibilty with api.rosette.com**](https://developer.rosette.com/features-and-functions?php).
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rosette/api",
"version": "1.9.0",
"version": "1.12.1",
"description": "Rosette API PHP client SDK",
"license": "Apache",
"keywords": [
Expand Down
2 changes: 1 addition & 1 deletion examples/categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
exit();
}
$categories_url_data = "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/";
$categories_url_data = "https://onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/";
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$params->set('contentUri', $categories_url_data);
Expand Down
1 change: 0 additions & 1 deletion examples/relationships.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$params->set('content', $relationships_text_data);
$api->setOption('accuracyMode', 'RECALL');

try {
$result = $api->relationships($params);
Expand Down
6 changes: 3 additions & 3 deletions examples/text_embedding.php → examples/semantic_vectors.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
exit();
}
$embeddings_data = "Cambridge, Massachusetts";
$semantic_vectors_data = "Cambridge, Massachusetts";
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$content = $embeddings_data;
$content = $semantic_vectors_data;
$params->set('content', $content);

try {
$result = $api->textEmbedding($params, false);
$result = $api->semanticVectors($params, false);
var_dump($result);
} catch (RosetteException $e) {
error_log($e);
Expand Down
28 changes: 28 additions & 0 deletions examples/similar_terms.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/**
* Example code to call Rosette API to get related terms from sample text
**/
require_once dirname(__FILE__) . '/../vendor/autoload.php';
use rosette\api\Api;
use rosette\api\DocumentParameters;
use rosette\api\RosetteException;

$options = getopt(null, array('key:', 'url::'));
if (!isset($options['key'])) {
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
exit();
}
$similar_terms_data = 'spy';
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
$params = new DocumentParameters();
$content = $similar_terms_data;
$params->set('content', $content);
$api->setOption('resultLanguages', array('spa', 'deu', 'jpn'));

try {
$result = $api->similarTerms($params, false);
var_dump($result);
} catch (RosetteException $e) {
error_log($e);
}
34 changes: 32 additions & 2 deletions source/rosette/api/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* Primary class for interfacing with the Rosette API
*
* @copyright 2015-2016 Basis Technology Corporation.
* @copyright 2015-2018 Basis Technology Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
Expand Down Expand Up @@ -38,7 +38,7 @@ class Api
*
* @var string
*/
private static $binding_version = '1.9.0';
private static $binding_version = '1.12.1';

/**
* User key (required for Rosette API).
Expand Down Expand Up @@ -697,6 +697,8 @@ public function relationships($params)
/**
* Calls the text-embedding endpoint.
*
* Deprecated. Please use `semanticVectors` instead
*
* @param $params
*
* @return mixed
Expand All @@ -708,6 +710,20 @@ public function textEmbedding($params)
return $this->callEndpoint($params, 'text-embedding');
}

/**
* Calls the semantic vectors endpoint.
*
* @param $params
*
* @return mixed
*
* @throws RosetteException
*/
public function semanticVectors($params)
{
return $this->callEndpoint($params, 'semantics/vector');
}

/**
* Calls the syntax/dependencies endpoint
*
Expand Down Expand Up @@ -749,4 +765,18 @@ public function topics($params)
{
return $this->callEndpoint($params, 'topics');
}

/**
* Calls the similarTerms endpoint
*
* @param $params
*
* @return mixed
*
* @throws RosetteException
*/
public function similarTerms($params)
{
return $this->callEndpoint($params, 'semantics/similar');
}
}
15 changes: 13 additions & 2 deletions spec/rosette/api/ApiSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public function it_calls_the_relationships_endpoint($params, $request)
$this->setMockRequest($request);
$this->relationships($params)->shouldHaveKeyWithValue('name', 'Rosette API');
}
public function it_calls_the_text_embedding_endpoint($params, $request)
public function it_calls_the_semantic_vectors_endpoint($params, $request)
{
$params->beADoubleOf('\rosette\api\DocumentParameters');
$params->contentUri = 'http://some.dummysite.com';
Expand All @@ -235,7 +235,7 @@ public function it_calls_the_text_embedding_endpoint($params, $request)
$request->getResponseCode()->willReturn(200);
$request->getResponse()->willReturn([ 'name' => 'Rosette API']);
$this->setMockRequest($request);
$this->textEmbedding($params)->shouldHaveKeyWithValue('name', 'Rosette API');
$this->semanticVectors($params)->shouldHaveKeyWithValue('name', 'Rosette API');
}
public function it_calls_the_syntax_dependencies_endpoint($params, $request)
{
Expand Down Expand Up @@ -269,6 +269,17 @@ public function it_calls_the_topics_endpoint($params, $request)
$this->setMockRequest($request);
$this->topics($params)->shouldHaveKeyWithValue('name', 'Rosette API');
}
public function it_calls_the_similar_terms_endpoint($params, $request)
{
$params->beADoubleOf('\rosette\api\DocumentParameters');
$params->content = 'Sample Data';
$request->beADoubleOf('rosette\api\RosetteRequest');
$request->makeRequest(Argument::any(), Argument::any(), Argument::any(), Argument::any(), Argument::any())->willReturn(true);
$request->getResponseCode()->willReturn(200);
$request->getResponse()->willReturn([ 'name' => 'Rosette API']);
$this->setMockRequest($request);
$this->similarTerms($params)->shouldHaveKeyWithValue('name', 'Rosette API');
}
public function it_fails_with_non_200_response($params, $request)
{
$params->beADoubleOf('\rosette\api\DocumentParameters');
Expand Down

0 comments on commit 3ebe18f

Please sign in to comment.