|
1 | | -Python Examples |
2 | | -================== |
3 | | - |
4 | | -These examples are scripts that can be run independently to demonstrate the Rosette API functionality. |
5 | | - |
6 | | -Prerequisite: Either run `pip install rosette_api` or run `python setup.py install` in the python top level folder. |
7 | | - |
8 | | -Alternatively, you can run all the examples with the command line: |
9 | | -`find -maxdepth 1 -name "*.py" -exec tox -- {} --key api-key --url alternate_url \;` |
10 | | - |
11 | | -You can now run your desired _endpoint_.py file to see it in action. |
12 | | -For example, run `python/examples/categories.py` if you want to see the categories |
13 | | -functionality demonstrated. |
14 | | - |
15 | | -All files require you to input your Rosette API User Key after --key to run. |
16 | | -For example: `python ping.py --key 1234567890` |
17 | | -All also allow you to input your own service URL if desired. |
18 | | -For example: `python ping.py --key 1234567890 --service_url http://www.myurl.com` |
19 | | -Some (specified below) allow an additional input of either a file (.html or .txt) or a URL with `--file` or `--url` |
20 | | - |
21 | | -Each example, when run, prints its output to the console. |
22 | | - |
23 | | -| File Name | What it does | |
24 | | -| ------------- |------------- | |
25 | | -| categories.py | Gets the category of a document at a URL | |
26 | | -| entities.py | Gets the entities from a piece of text | |
27 | | -| info.py | Gets information about Rosette API | |
28 | | -| language.py | Gets the language of a piece of text | |
29 | | -| matched-name.py | Gets the similarity score of two names | |
30 | | -| morphology_complete.py | Gets the complete morphological analysis of a piece of text| |
31 | | -| morphology_compound-components.py | Gets the de-compounded words from a piece of text | |
32 | | -| morphology_han-readings.py | Gets the Chinese words from a piece of text | |
33 | | -| morphology_lemmas.py | Gets the lemmas of words from a piece of text | |
34 | | -| morphology_parts-of-speech.py | Gets the part-of-speech tags for words in a piece of text | |
35 | | -| name_deduplication.py | De-duplicates a list of names | |
36 | | -| ping.py | Pings the Rosette API to check for reachability | |
37 | | -| relationships.py | Gets the relationships between entities from a piece of text | |
38 | | -| sentences.py | Gets the sentences from a piece of text | |
39 | | -| sentiment.py | Gets the sentiment of a local file | |
40 | | -| tokens.py | Gets the tokens (words) from a piece of text | |
41 | | -| topics.py | Returns key phrases and concepts from provided content | |
42 | | -| translated-name.py | Translates a name from one language to another | |
43 | | -| transliteration.py | Transliterates the given text | |
44 | | - |
| 1 | +## Endpoint Examples |
| 2 | + |
| 3 | +Each example file demonstrates one of the capabilities of the Rosette Platform. |
| 4 | + |
| 5 | +Here are some methods for running the examples. Each example will also accept an optional `--url` parameter for |
| 6 | +overriding the default URL. |
| 7 | + |
| 8 | +A note on pre-requisites. Rosette API only supports TLS 1.2 so ensure your toolchain also supports it. |
| 9 | + |
| 10 | +#### Virtualenv/Latest Release |
| 11 | +``` |
| 12 | +git clone [email protected]:rosette-api/python.git |
| 13 | +cd python/examples |
| 14 | +virtualenv rosette_venv |
| 15 | +source rosette_venv/bin/activate |
| 16 | +pip install rosette_api |
| 17 | +python ping.py -k $API_KEY |
| 18 | +``` |
| 19 | + |
| 20 | +#### Virtualenv/Local Source |
| 21 | +``` |
| 22 | +git clone [email protected]:rosette-api/python.git |
| 23 | +cd python |
| 24 | +virtualenv rosette_venv |
| 25 | +source rosette_venv/bin/activate |
| 26 | +python setup.py install |
| 27 | +cd examples |
| 28 | +python ping.py -k $API_KEY |
| 29 | +``` |
| 30 | + |
| 31 | +#### Docker/Latest Release |
| 32 | +``` |
| 33 | +git clone [email protected]:rosette-api/python.git |
| 34 | +cd python/examples |
| 35 | +docker run -it -v $(pwd):/source --entrypoint bash python:3.6-slim |
| 36 | +cd /source |
| 37 | +pip install rosette_api |
| 38 | +python ping.py -k $API_KEY |
| 39 | +``` |
| 40 | + |
| 41 | +#### Docker/Local Source |
| 42 | +``` |
| 43 | +git clone [email protected]:rosette-api/python.git |
| 44 | +cd python |
| 45 | +docker run -it -v $(pwd):/source --entrypoint bash python:3.6-slim |
| 46 | +cd /source |
| 47 | +python setup.py install |
| 48 | +cd examples |
| 49 | +python ping.py -k $API_KEY |
| 50 | +``` |
0 commit comments