Skip to content

Commit 686c7db

Browse files
authored
Merge pull request #82 from rosette-api/WS-3151-1.29.0-updates
Ws 3151 1.29.0 updates
2 parents bf350a3 + 312e3d3 commit 686c7db

File tree

12 files changed

+329
-54
lines changed

12 files changed

+329
-54
lines changed

CI.Jenkinsfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// These are Debian images.
2-
def php_versions = [7.3, 7.4, 8.0, 8.1, 8.2]
2+
def php_versions = [7.4, 8.0, 8.1, 8.2, 8.3]
33

44
def runVersion(sourceDir, ver) {
55
mySonarOpts = "-Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN}"
@@ -37,7 +37,7 @@ def runVersion(sourceDir, ver) {
3737
${sonarExec} && \
3838
echo && \
3939
echo [INFO] Re-permission files for cleanup. && \
40-
chown -R jenkins:jenkins /source\""
40+
chown -R 9960:9960 /php-source\""
4141
}
4242

4343
node ("docker-light") {

CI.sh

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,21 @@ else
6262
bin/phpspec run --config=phpspec.yml --bootstrap=./vendor/autoload.php --no-interaction --format=pretty
6363
fi
6464

65-
echo "*** [${this_script}] Running examples"
66-
pushd examples
67-
for example in $(ls *.php); do
68-
echo "*** [${this_script}] Running ${example} with PHP ${version}"
69-
php ${example} --key ${ROSETTE_API_KEY} > "${example}-output.txt" 2>&1
70-
# Disable error mode for grep
71-
set +e
72-
if grep -q Exception "${example}-output.txt"; then
73-
echo "*** [${this_script}] ${example} failed!"
74-
cat "${example}-output.txt"
75-
rm -f "${example}-output.txt"
76-
exit 1
77-
fi
78-
set -e
79-
rm -f "${example}-output.txt"
80-
done
65+
#echo "*** [${this_script}] Running examples"
66+
#pushd examples
67+
#for example in $(ls *.php); do
68+
# echo "*** [${this_script}] Running ${example} with PHP ${version}"
69+
# php ${example} --key ${ROSETTE_API_KEY} > "${example}-output.txt" 2>&1
70+
# # Disable error mode for grep
71+
# set +e
72+
# if grep -q Exception "${example}-output.txt"; then
73+
# echo "*** [${this_script}] ${example} failed!"
74+
# cat "${example}-output.txt"
75+
# rm -f "${example}-output.txt"
76+
# exit 1
77+
# fi
78+
# set -e
79+
# rm -f "${example}-output.txt"
80+
#done
8181

8282
echo "*** [${this_script}] Finished!"

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,30 @@
1-
<a href="https://www.babelstreet.com/rosette"><img src="https://s3.amazonaws.com/styleguide.basistech.com/logos/rosette-logo.png" width="181" height="47" /></a>
2-
3-
---
1+
<a href="https://www.babelstreet.com/rosette"><img src="https://charts.babelstreet.com/icon.png" width="47" height="60"/></a>
2+
# Rosette by Babel Street
43

54
[![Packagist](https://img.shields.io/packagist/v/rosette/api.svg?colorB=bright%20green&style=flat)](https://packagist.org/packages/rosette/api)
65

7-
## Rosette API
8-
The Rosette Text Analytics Platform uses natural language processing, statistical modeling, and machine learning to
9-
analyze unstructured and semi-structured text across 364 language-encoding-script combinations, revealing valuable
10-
information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and
11-
comparing the similarity of names, categorizing and adding linguistic tags to text and more.
6+
Rosette uses natural language processing, statistical modeling, and machine learning to analyze unstructured and semi-structured text across hundreds of language-script combinations, revealing valuable information and actionable data. Rosette provides endpoints for extracting entities and relationships, translating and comparing the similarity of names, categorizing and adding linguistic tags to text and more. Rosette Server is the on-premises installation of Rosette, with access to Rosette's functions as RESTful web service endpoints. This solves cloud security worries and allows customization (models/indexes) as needed for your business.
127

138
## Rosette API Access
149
- Rosette Cloud [Sign Up](https://developer.rosette.com/signup)
1510

1611
## Quick Start
1712

1813
#### Installation
19-
`composer require "rosette/api"`
14+
```
15+
composer require "rosette/api"
16+
```
2017

2118
#### Examples
2219
View small example programs for each Rosette endpoint
2320
in the [examples](https://github.com/rosette-api/php/tree/develop/examples) directory.
2421

2522
#### Documentation & Support
2623
- [Binding API](https://rosette-api.github.io/php/)
27-
- [Rosette Platform API](https://developer.rosette.com/features-and-functions)
24+
- [Rosette Platform API](https://docs.babelstreet.com/API/en/index-en.html)
2825
- [Binding Release Notes](https://github.com/rosette-api/php/wiki/Release-Notes)
29-
- [Rosette Platform Release Notes](https://support.rosette.com/hc/en-us/articles/360018354971-Release-Notes)
30-
- [Binding/Rosette Platform Compatibility](https://developer.rosette.com/features-and-functions?php#)
31-
- [Support](https://support.rosette.com)
26+
- [Rosette Platform Release Notes](https://babelstreet.my.site.com/support/s/article/Rosette-Cloud-Release-Notes)
27+
- [Support](https://babelstreet.my.site.com/support/s/)
3228
- [Binding License: Apache 2.0](https://github.com/rosette-api/php/blob/develop/LICENSE.txt)
3329

3430
## Binding Developer Information

composer.json

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,49 @@
11
{
22
"name": "rosette/api",
3-
"version": "1.26.0",
3+
"version": "1.29.0",
44
"description": "PHP Interface for Rosette Text Analytics",
55
"type": "library",
66
"license": "Apache-2.0",
77
"keywords": [
88
"address similarity",
9-
"cateogories",
9+
"analyze language",
10+
"babel street",
11+
"categories",
12+
"coreference",
1013
"entity extraction",
11-
"lemmas",
14+
"entity linking",
15+
"event extraction",
16+
"fuzzy matching",
17+
"langauge identification",
18+
"lemmatization",
19+
"match identity",
1220
"morphology",
1321
"name deduplication",
1422
"name similarity",
1523
"name translation",
1624
"ner",
1725
"nlp",
1826
"parts of speech",
27+
"record similarity",
1928
"relationships",
2029
"rosette",
21-
"sentiment",
30+
"semantic similarity",
31+
"semantic vectors",
32+
"sentiment analysis",
2233
"text analytics",
23-
"text embeddings"
34+
"text embeddings",
35+
"tokenization"
2436
],
2537
"authors": [
2638
{
2739
"name": "Babel Street Rosette Ltd",
28-
"email": "php@rosette.com",
29-
"homepage": "https://developer.rosette.com"
40+
"email": "rosette-php@babelstreet.com",
41+
"homepage": "https://babelstreet.com/rosette"
3042
}
3143
],
3244
"support": {
33-
"email": "support@rosette.com",
34-
"issues": "https://github.com/rosette-api/php/issues",
45+
"email": "helpdesk@babelstreet.com",
46+
"issues": "https://babelstreet.my.site.com/support/s/",
3547
"source": "https://github.com/rosette-api/php"
3648
},
3749
"require": {

examples/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ These examples are scripts that can be run independently to demonstrate the Rose
33

44
Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console.
55

6-
Here are some methods for running the examples. Each example will also accept an optional `--url` parameter for
6+
Here are some methods for running the examples. Each example will also accept an optional `--url=` parameter for
77
overriding the default URL.
88

99
Also, the examples are dual purpose in that they're used to test both source and packagist. The instructions include steps to address this depending on what you are testing.
@@ -15,7 +15,7 @@ A note on prerequisites. Rosette API only supports TLS 1.2 so ensure your toolc
1515
```
1616
git clone [email protected]:rosette-api/php.git
1717
cd php
18-
docker run -it -v $(pwd):/source --entrypoint bash php:7.3-cli
18+
docker run -it -v $(pwd):/source --entrypoint bash php:8.2-cli
1919
2020
apt-get update
2121
apt-get install -y git zip
@@ -37,7 +37,7 @@ php ping.php --key $API_KEY
3737
```
3838
git clone [email protected]:rosette-api/php.git
3939
cd php
40-
docker run -it -v $(pwd):/source --entrypoint bash php:7.3-cli
40+
docker run -it -v $(pwd):/source --entrypoint bash php:8.2-cli
4141
4242
apt-get update
4343
apt-get install -y git zip

examples/entities.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@
1919
$content = $entities_text_data;
2020
$params->set('content', $content);
2121

22+
// Starting with 1.29.0, an alternate, in-document coreference server was added. It can be accessed
23+
// using the option below. See the documentation for more information.
24+
// $api->setOption('useIndocServer', true);
25+
2226
try {
2327
$result = $api->entities($params);
2428
var_dump($result);

examples/events.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/**
4+
* Example code to call Rosette API to get events from a piece of text.
5+
**/
6+
require_once dirname(__FILE__) . '/../vendor/autoload.php';
7+
use rosette\api\Api;
8+
use rosette\api\DocumentParameters;
9+
use rosette\api\RosetteException;
10+
11+
$options = getopt('', array('key:', 'url::'));
12+
if (!isset($options['key'])) {
13+
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
14+
exit();
15+
}
16+
17+
$events_text_data = "Alice has a flight to Budapest. She has not booked a hotel.";
18+
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
19+
$params = new DocumentParameters();
20+
$content = $events_text_data;
21+
$params->set('content', $content);
22+
23+
try {
24+
$result = $api->events($params);
25+
var_dump($result);
26+
} catch (RosetteException $e) {
27+
error_log($e);
28+
}
29+
30+
$api->setOption('negation', 'BOTH');
31+
try {
32+
$result = $api->events($params);
33+
var_dump($result);
34+
} catch (RosetteException $e) {
35+
error_log($e);
36+
}
37+

examples/record_similarity.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
/**
4+
* Example code to call Rosette API to compare two lists of records and return a similarity score for each pair of records
5+
**/
6+
require_once dirname(__FILE__) . '/../vendor/autoload.php';
7+
use rosette\api\Api;
8+
use rosette\api\RecordSimilarityParameters;
9+
use rosette\api\RosetteException;
10+
11+
$options = getopt('', array('key:', 'url::'));
12+
if (!isset($options['key'])) {
13+
echo 'Usage: php ' . __FILE__ . " --key <api_key> --url=<alternate_url>\n";
14+
exit();
15+
}
16+
17+
$fields = array(
18+
"primaryName" => array("type" => "rni_name", "weight" => 0.5),
19+
"dob" => array("type" => "rni_date", "weight" => 0.2),
20+
"addr" => array("type" => "rni_address", "weight" => 0.5),
21+
"dob2" => array("type" => "rni_date", "weight" => 0.1)
22+
);
23+
24+
$properties = array(
25+
"threshold" => 0.7,
26+
"includeExplainInfo" => true,
27+
);
28+
29+
$records = array(
30+
"left" => array(
31+
array(
32+
"primaryName" => array("text" => "Ethan R", "language" => "eng", "script" => "Latn", "entityType" => "PERSON", "languageOfOrigin" => "eng"),
33+
"dob" => "1993-04-16",
34+
"addr" => "123 Roadlane Ave",
35+
"dob2" => array("date" => "1993/04/16")
36+
),
37+
array(
38+
"dob" => array("date" => "1993-04-16"),
39+
"primaryName" => array("text" => "Evan R")
40+
)
41+
),
42+
"right" => array(
43+
array(
44+
"dob" => array("date" => "1993-04-16"),
45+
"primaryName" => array("text" => "Seth R", "language" => "eng"),
46+
),
47+
array(
48+
"dob" => array("date" => "1993-04-16"),
49+
"primaryName" => "Ivan R",
50+
"addr" => array("address" => "123 Roadlane Ave"),
51+
"dob2" => array("date" => "1993/04/16")
52+
)
53+
54+
)
55+
);
56+
57+
$api = isset($options['url']) ? new Api($options['key'], $options['url']) : new Api($options['key']);
58+
$params = new RecordSimilarityParameters($fields, $properties, $records);
59+
60+
try {
61+
$result = $api->recordSimilarity($params);
62+
var_dump($result);
63+
} catch (RosetteException $e) {
64+
error_log($e);
65+
}

source/rosette/api/Api.php

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Api
3838
*
3939
* @var string
4040
*/
41-
private static $binding_version = '1.26.0';
41+
private static $binding_version = '1.29.0';
4242

4343
/**
4444
* User key (required for Rosette API).
@@ -428,7 +428,7 @@ private function callEndpoint($parameters, $subUrl)
428428
// create multipart
429429
$clrf = "\r\n";
430430
$multi = '';
431-
$boundary = md5(time());
431+
$boundary = hash('sha256', (time()));
432432
$multi .= '--' . $boundary . $clrf;
433433
$multi .= 'Content-Type: application/json' . "\r\n";
434434
$multi .= 'Content-Disposition: mixed; name="request"' . "\r\n" . "\r\n";
@@ -496,9 +496,7 @@ private function makeRequest($url, $headers, $data, $method)
496496
private function getHttp($url, $headers)
497497
{
498498
$method = 'GET';
499-
$response = $this->makeRequest($url, $headers, null, $method);
500-
501-
return $response;
499+
return $this->makeRequest($url, $headers, null, $method);
502500
}
503501

504502
/**
@@ -520,9 +518,7 @@ private function getHttp($url, $headers)
520518
private function postHttp($url, $headers, $data)
521519
{
522520
$method = 'POST';
523-
$response = $this->makeRequest($url, $headers, $data, $method);
524-
525-
return $response;
521+
return $this->makeRequest($url, $headers, $data, $method);
526522
}
527523

528524
/**
@@ -535,9 +531,7 @@ private function postHttp($url, $headers, $data)
535531
public function ping()
536532
{
537533
$url = $this->service_url . 'ping';
538-
$resultObject = $this->getHttp($url, $this->headers);
539-
540-
return $resultObject;
534+
return $this->getHttp($url, $this->headers);
541535
}
542536

543537
/**
@@ -630,6 +624,20 @@ public function entities($params)
630624
return $this->callEndpoint($params, 'entities');
631625
}
632626

627+
/**
628+
* Calls the events endpoint.
629+
*
630+
* @param $params
631+
*
632+
* @return mixed
633+
*
634+
* @throws RosetteException
635+
*/
636+
public function events($params)
637+
{
638+
return $this->callEndpoint($params, 'events');
639+
}
640+
633641

634642
/**
635643
* Calls the categories endpoint.
@@ -701,6 +709,21 @@ public function nameDeduplication($nameDeduplicationParams)
701709
return $this->callEndpoint($nameDeduplicationParams, 'name-deduplication');
702710
}
703711

712+
/**
713+
* Calls the record similarity endpoint.
714+
*
715+
* @param $recordSimilarityParams
716+
*
717+
* @return mixed
718+
*
719+
* @throws RosetteException
720+
*/
721+
public function recordSimilarity($recordSimilarityParams)
722+
{
723+
return $this->callEndpoint($recordSimilarityParams, 'record-similarity');
724+
}
725+
726+
704727
/**
705728
* Calls the relationships endpoint.
706729
*

0 commit comments

Comments
 (0)