You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* RCB-527 Topics
- Added topics to Api.py
- Created topics example
- Code cleanup on all examples
- Passed against jugmaster
* Updated README
- cleaned up obsolete instructions
- added list of available endpoints
- added release notes reference
* Updated examples README
* Added topics to unit tests
1. If the application reads text in, set encoding to utf-8 in the first line of the script.
52
-
53
-
2. Import the `rosette.api` packages that your application needs. The `rosette.api` packages include
54
-
*`API`
55
-
*`DocumentParameters`
56
-
*`NameSimilarityParameters`
57
-
*`NameTranslationParameters`
58
-
*`MorphologyOutput`
59
-
*`DataFormat`
60
-
61
-
3. Create an `API` object with the `user_key` parameter.
62
-
63
-
4. Create a parameters object for your request input:
64
-
65
-
| Parameter | Endpoint |
66
-
| ----|----|
67
-
|`NameSimilarityParameters`| for `/name-similarity`|
68
-
|`NameTranslationParameters`| for `/translated-name`|
69
-
|`DocumentParameters`| for all other endpoints |
70
-
71
-
72
-
5. Set the parameters required for your operation: "`content`" or "`contentUri`" for `DocumentParameters`;
73
-
"`name`" and "`targetLanguage`" for `NameTranslationParameters`; "`name1.text`" and "`name2.text`" for
74
-
`NameSimilarityParameters`; Other parameters are optional.
75
-
76
-
6. Invoke the `API` method for the endpoint you are calling. The methods are
77
-
*`entities()`
78
-
*`categories()`
79
-
*`sentiment()`
80
-
*`language()`
81
-
*`morphology(tag)` where tag is a member of `MorphologyOutput`: `LEMMAS`, `PARTS_OF_SPEECH`, `COMPOUND_COMPONENTS`, `HAN_READINGS`, or `COMPLETE`. An empty tag is equivalent to `COMPLETE`.
82
-
*`sentences()`
83
-
*`tokens()`
84
-
*`relationships()`
85
-
*`name_translation()`
86
-
*`name_similarity()`
87
-
*`matched_name()`*deprecated
88
-
*`translated_name()`*deprecated
89
-
90
-
7. The API will return a dictionary with the results.
91
-
92
-
See [examples](examples) for more request samples.
93
-
94
-
## Docker ##
21
+
### Basic Usage
22
+
23
+
For help in how to call the various endpoints, please refer to the [examples](https://github.com/rosette-api/python/tree/develop/examples).
24
+
25
+
### Supported Endpoints
26
+
- categories
27
+
- entities
28
+
- info
29
+
- language
30
+
- morphology (complete, compound components, han readings, lemmas, parts of speech)
31
+
- name deduplication
32
+
- name similarity
33
+
- name translation
34
+
- ping
35
+
- relationships
36
+
- sentences
37
+
- sentiment
38
+
- syntax dependencies
39
+
- text embedding
40
+
- tokens
41
+
- topics
42
+
- transliteration
43
+
44
+
### Docker
95
45
A Docker image for running the examples against the compiled source library is available on Docker Hub.
96
46
97
47
Command: `docker run -e API_KEY=api-key -v "<binding root directory>:/source" rosetteapi/docker-python`
entities_text_data="Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS"
18
19
params=DocumentParameters()
19
20
params["content"] =entities_text_data
20
21
params["genre"] ="social-media"
21
22
try:
22
23
returnapi.entities(params)
23
-
exceptRosetteExceptionase:
24
-
print(e)
24
+
exceptRosetteExceptionasexception:
25
+
print(exception)
25
26
26
-
parser=argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the '+os.path.splitext(os.path.basename(__file__))[0] +' endpoint')
27
-
parser.add_argument('-k', '--key', help='Rosette API Key', required=True)
28
-
parser.add_argument('-u', '--url', help="Alternative API URL", default='https://api.rosette.com/rest/v1/')
0 commit comments