|
1 | | -PHP Examples |
2 | | -============ |
3 | | - |
| 1 | +## Endpoint Examples |
4 | 2 | These examples are scripts that can be run independently to demonstrate the Rosette API functionality. |
5 | 3 |
|
6 | | -You can now run your desired _endpoint_.php file to see it in action. Before running the examples |
7 | | -for the first time: |
8 | | - |
9 | | -1. ```cd examples``` |
10 | | -2. ```composer update``` |
11 | | -3. The examples are dual purpose in that they're used to test both source and packagist. In order to meet that requirement, the examples expect the vendor directory to be at the same level as examples/. |
12 | | -```cp -r ./vendor/. ../vendor``` or you can edit the example to reference the vendor directory that is in the examples directory. |
13 | | - |
14 | | -For example, run `php categories.php` if you want to see the categories functionality demonstrated. |
15 | | - |
16 | | -All files require you to input your Rosette API User Key after `--key` to run. |
17 | | -For example: `php ping.php --key 1234567890` |
18 | | -All also allow you to input your own service URL if applicable. |
19 | | -For example: `php ping.php --key 1234567890 --url http://www.myurl.com` |
20 | | - |
21 | | - |
22 | | -Each example, when run, prints its output to the console. |
23 | | - |
24 | | -| File Name | What it does | |
25 | | -| ------------- |------------- | |
26 | | -| categories.php | Gets the category of a document at a URL | |
27 | | -| entities.php | Gets the entities from a piece of text | |
28 | | -| info.php | Gets information about Rosette API | |
29 | | -| language.php | Gets the language of a piece of text | |
30 | | -| morphology_complete.php | Gets the complete morphological analysis of a piece of text| |
31 | | -| morphology_compound-components.php | Gets the de-compounded words from a piece of text | |
32 | | -| morphology_han-readings.php | Gets the Chinese words from a piece of text | |
33 | | -| morphology_lemmas.php | Gets the lemmas of words from a piece of text | |
34 | | -| morphology_parts-of-speech.php | Gets the part-of-speech tags for words in a piece of text | |
35 | | -| name_deduplication.php | Fuzzy deduplication of a list of names | |
36 | | -| name_translation.php | Translates a name from one language to another | |
37 | | -| name_similarity.php | Gets the similarity score of two names | |
38 | | -| ping.php | Pings the Rosette API to check for reachability | |
39 | | -| sentences.php | Gets the sentences from a piece of text | |
40 | | -| sentiment.php | Gets the sentiment of a local file | |
41 | | -| tokens.php | Gets the tokens (words) from a piece of text | |
42 | | -| topics.php | Gets the key phrases and concepts from a piece of text | |
43 | | -| transliteration.php | Transliterates content | |
| 4 | +Each example file demonstrates one of the capabilities of the Rosette Platform. Each example, when run, prints its output to the console. |
| 5 | + |
| 6 | +Here are some methods for running the examples. Each example will also accept an optional `--url` parameter for |
| 7 | +overriding the default URL. |
| 8 | + |
| 9 | +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. |
| 10 | + |
| 11 | +A note on prerequisites. Rosette API only supports TLS 1.2 so ensure your toolchain also supports it. |
| 12 | + |
| 13 | +#### Docker/Latest Version From Packagist |
| 14 | + |
| 15 | +``` |
| 16 | +git clone git@github.com:rosette-api/php.git |
| 17 | +cd php |
| 18 | +docker run -it -v $(pwd):/source --entrypoint bash php:7.3-cli |
| 19 | +
|
| 20 | +apt-get update |
| 21 | +apt-get install -y git zip |
| 22 | +
|
| 23 | +curl -s -o /usr/local/bin/composer https://getcomposer.org/composer.phar |
| 24 | +chmod +x /usr/local/bin/composer |
| 25 | +composer self-update |
| 26 | +
|
| 27 | +cd /source/examples |
| 28 | +composer require "rosette/api" |
| 29 | +mv vendor/ ../. |
| 30 | +
|
| 31 | +php ping.php --key $API_KEY |
| 32 | +
|
| 33 | +``` |
| 34 | + |
| 35 | +#### Docker/Latest Source |
| 36 | + |
| 37 | +``` |
| 38 | +git clone git@github.com:rosette-api/php.git |
| 39 | +cd php |
| 40 | +docker run -it -v $(pwd):/source --entrypoint bash php:7.3-cli |
| 41 | +
|
| 42 | +apt-get update |
| 43 | +apt-get install -y git zip |
| 44 | +
|
| 45 | +curl -s -o /usr/local/bin/composer https://getcomposer.org/composer.phar |
| 46 | +chmod +x /usr/local/bin/composer |
| 47 | +composer self-update |
| 48 | +
|
| 49 | +cd /source |
| 50 | +composer install |
| 51 | +cd examples |
| 52 | +
|
| 53 | +php ping.php --key $API_KEY |
44 | 54 |
|
| 55 | +``` |
0 commit comments