Skip to content

Commit a456d79

Browse files
committed
Initial commit to pages
1 parent 28c02c0 commit a456d79

33 files changed

+1182
-0
lines changed

README.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
2+
# Getting Started with FirstLanguage API
3+
4+
## Introduction
5+
6+
Collection of NLP APIs to help developers. We have grouped the APIs under Basic and Advanced. Basic APIs cover all basic text operations like POSTag, Stemmer etc and Advanced cover all the APIs like QA, translation etc.
7+
8+
### OpenAPI Specification
9+
10+
This API is documented in **OpenAPI v3.0 format**.
11+
In addition to standard
12+
OpenAPI syntax we use a few [vendor extensions](https://github.com/Redocly/redoc/blob/master/docs/redoc-vendor-extensions.md).
13+
14+
## Building
15+
16+
You must have Python `3 >=3.7, <= 3.9` installed on your system to install and run this SDK. This SDK package depends on other Python packages like nose, jsonpickle etc. These dependencies are defined in the `requirements.txt` file that comes with the SDK. To resolve these dependencies, you can use the PIP Dependency manager. Install it by following steps at [https://pip.pypa.io/en/stable/installing/](https://pip.pypa.io/en/stable/installing/).
17+
18+
Python and PIP executables should be defined in your PATH. Open command prompt and type `pip --version`. This should display the version of the PIP Dependency Manager installed if your installation was successful and the paths are properly defined.
19+
20+
* Using command line, navigate to the directory containing the generated files (including `requirements.txt`) for the SDK.
21+
* Run the command `pip install -r requirements.txt`. This should install all the required dependencies.
22+
23+
![Building SDK - Step 1](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&step=installDependencies)
24+
25+
## Installation
26+
27+
The following section explains how to use the firstlanguageapi library in a new project.
28+
29+
### 1. Open Project in an IDE
30+
31+
Open up a Python IDE like PyCharm. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
32+
33+
![Open project in PyCharm - Step 1](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&step=pyCharm)
34+
35+
Click on `Open` in PyCharm to browse to your generated SDK directory and then click `OK`.
36+
37+
![Open project in PyCharm - Step 2](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&step=openProject0)
38+
39+
The project files will be displayed in the side bar as follows:
40+
41+
![Open project in PyCharm - Step 3](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&step=openProject1)
42+
43+
### 2. Add a new Test Project
44+
45+
Create a new directory by right clicking on the solution name as shown below:
46+
47+
![Add a new project in PyCharm - Step 1](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&step=createDirectory)
48+
49+
Name the directory as "test".
50+
51+
![Add a new project in PyCharm - Step 2](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&step=nameDirectory)
52+
53+
Add a python file to this project.
54+
55+
![Add a new project in PyCharm - Step 3](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&step=createFile)
56+
57+
Name it "testSDK".
58+
59+
![Add a new project in PyCharm - Step 4](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&step=nameFile)
60+
61+
In your python file you will be required to import the generated python library using the following code lines
62+
63+
```python
64+
from firstlanguageapi.firstlanguageapi_client import FirstlanguageapiClient
65+
```
66+
67+
![Add a new project in PyCharm - Step 5](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&libraryName=firstlanguageapi.firstlanguageapi_client&className=FirstlanguageapiClient&step=projectFiles)
68+
69+
After this you can write code to instantiate an API client object, get a controller object and make API calls. Sample code is given in the subsequent sections.
70+
71+
### 3. Run the Test Project
72+
73+
To run the file within your test project, right click on your Python file inside your Test project and click on `Run`
74+
75+
![Run Test Project - Step 1](https://apidocs.io/illustration/python?workspaceFolder=Firstlanguageapi-Python&projectName=firstlanguageapi&libraryName=firstlanguageapi.firstlanguageapi_client&className=FirstlanguageapiClient&step=runProject)
76+
77+
## Test the SDK
78+
79+
You can test the generated SDK and the server with test cases. `unittest` is used as the testing framework and `nose` is used as the test runner. You can run the tests as follows:
80+
81+
Navigate to the root directory of the SDK and run the following commands
82+
83+
```
84+
pip install -r test-requirements.txt
85+
nosetests
86+
```
87+
88+
## Initialize the API Client
89+
90+
**_Note:_** Documentation for the client can be found [here.](/doc/client.md)
91+
92+
The following parameters are configurable for the API Client:
93+
94+
| Parameter | Type | Description |
95+
| --- | --- | --- |
96+
| `apikey` | `string` | API Key can be copied from your dashboard |
97+
| `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests |
98+
| `override_http_client_configuration` | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
99+
| `timeout` | `float` | The value to use for connection timeout. <br> **Default: 60** |
100+
| `max_retries` | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
101+
| `backoff_factor` | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
102+
| `retry_statuses` | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
103+
| `retry_methods` | `Array of string` | The http methods on which retry is to be done. <br> **Default: ['GET', 'PUT']** |
104+
105+
The API client can be initialized as follows:
106+
107+
```python
108+
from firstlanguageapi.firstlanguageapi_client import FirstlanguageapiClient
109+
from firstlanguageapi.configuration import Environment
110+
111+
client = FirstlanguageapiClient(
112+
apikey='apikey',
113+
environment=Environment.PRODUCTION,)
114+
```
115+
116+
## Authorization
117+
118+
This API uses `Custom Header Signature`.
119+
120+
## List of APIs
121+
122+
* [Basic AP Is](/doc/controllers/basic-ap-is.md)
123+
* [Advanced AP Is](/doc/controllers/advanced-ap-is.md)
124+
125+
## Classes Documentation
126+
127+
* [Utility Classes](/doc/utility-classes.md)
128+
* [HttpResponse](/doc/http-response.md)
129+
* [HttpRequest](/doc/http-request.md)
130+

doc/client.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
2+
# Client Class Documentation
3+
4+
The following parameters are configurable for the API Client:
5+
6+
| Parameter | Type | Description |
7+
| --- | --- | --- |
8+
| `apikey` | `string` | API Key can be copied from your dashboard |
9+
| `http_client_instance` | `HttpClient` | The Http Client passed from the sdk user for making requests |
10+
| `override_http_client_configuration` | `bool` | The value which determines to override properties of the passed Http Client from the sdk user |
11+
| `timeout` | `float` | The value to use for connection timeout. <br> **Default: 60** |
12+
| `max_retries` | `int` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
13+
| `backoff_factor` | `float` | A backoff factor to apply between attempts after the second try. <br> **Default: 2** |
14+
| `retry_statuses` | `Array of int` | The http statuses on which retry is to be done. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
15+
| `retry_methods` | `Array of string` | The http methods on which retry is to be done. <br> **Default: ['GET', 'PUT']** |
16+
17+
The API client can be initialized as follows:
18+
19+
```python
20+
from firstlanguageapi.firstlanguageapi_client import FirstlanguageapiClient
21+
from firstlanguageapi.configuration import Environment
22+
23+
client = FirstlanguageapiClient(
24+
apikey='apikey',
25+
environment=Environment.PRODUCTION,)
26+
```
27+
28+
## FirstLanguage API Client
29+
30+
The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.
31+
32+
## Controllers
33+
34+
| Name | Description |
35+
| --- | --- |
36+
| basic_ap_is | Gets BasicAPIsController |
37+
| advanced_ap_is | Gets AdvancedAPIsController |
38+

doc/controllers/advanced-ap-is.md

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Advanced AP Is
2+
3+
Advanced text processing APIs
4+
5+
```python
6+
advanced_ap_is_controller = client.advanced_ap_is
7+
```
8+
9+
## Class Name
10+
11+
`AdvancedAPIsController`
12+
13+
## Methods
14+
15+
* [Get Classification](/doc/controllers/advanced-ap-is.md#get-classification)
16+
* [Get QA](/doc/controllers/advanced-ap-is.md#get-qa)
17+
* [Get NER](/doc/controllers/advanced-ap-is.md#get-ner)
18+
19+
20+
# Get Classification
21+
22+
# Stemmer : Defintion and it's usage
23+
24+
# Languages covered:
25+
26+
```python
27+
def get_classification(self,
28+
body)
29+
```
30+
31+
## Parameters
32+
33+
| Parameter | Type | Tags | Description |
34+
| --- | --- | --- | --- |
35+
| `body` | `object` | Body, Required | Add a JSON Input as per the schema defined below |
36+
37+
## Response Type
38+
39+
[`Responseclassify`](/doc/models/responseclassify.md)
40+
41+
## Example Usage
42+
43+
```python
44+
body = jsonpickle.decode('{"key1":"val1","key2":"val2"}')
45+
46+
result = advanced_ap_is_controller.get_classification(body)
47+
```
48+
49+
## Errors
50+
51+
| HTTP Status Code | Error Description | Exception Class |
52+
| --- | --- | --- |
53+
| 400 | Error output | [`ErrorsException`](/doc/models/errors-exception.md) |
54+
| 426 | Please use HTTPS protocol | [`ApiClassify426ErrorException`](/doc/models/api-classify-426-error-exception.md) |
55+
56+
57+
# Get QA
58+
59+
# Stemmer : Defintion and it's usage
60+
61+
# Languages covered:
62+
63+
```python
64+
def get_qa(self,
65+
body=None)
66+
```
67+
68+
## Parameters
69+
70+
| Parameter | Type | Tags | Description |
71+
| --- | --- | --- | --- |
72+
| `body` | `object` | Body, Optional | Add a JSON Input as per the schema defined below |
73+
74+
## Response Type
75+
76+
[`ApiQaResponse`](/doc/models/api-qa-response.md)
77+
78+
## Example Usage
79+
80+
```python
81+
result = advanced_ap_is_controller.get_qa()
82+
```
83+
84+
## Example Response *(as JSON)*
85+
86+
```json
87+
{
88+
"score": 0.028566665947437286,
89+
"start": 0,
90+
"end": 20,
91+
"answer": "உப்பு, புளி, மிளகாய்"
92+
}
93+
```
94+
95+
## Errors
96+
97+
| HTTP Status Code | Error Description | Exception Class |
98+
| --- | --- | --- |
99+
| 400 | Bad Request | [`ErrorsException`](/doc/models/errors-exception.md) |
100+
| 426 | Please use HTTPS protocol | [`M426ErrorException`](/doc/models/m426-error-exception.md) |
101+
102+
103+
# Get NER
104+
105+
# Stemmer : Defintion and it's usage
106+
107+
# Languages covered:
108+
109+
```python
110+
def get_ner(self,
111+
body=None)
112+
```
113+
114+
## Parameters
115+
116+
| Parameter | Type | Tags | Description |
117+
| --- | --- | --- | --- |
118+
| `body` | `object` | Body, Optional | Add a JSON Input as per the schema defined below |
119+
120+
## Response Type
121+
122+
[`List of ApiNerResponse`](/doc/models/api-ner-response.md)
123+
124+
## Example Usage
125+
126+
```python
127+
result = advanced_ap_is_controller.get_ner()
128+
```
129+
130+
## Example Response *(as JSON)*
131+
132+
```json
133+
[
134+
{
135+
"entity_group": "PER",
136+
"word": "محمد",
137+
"start": "4",
138+
"end": "9"
139+
},
140+
{
141+
"entity_group": "LOC",
142+
"word": "برلين",
143+
"start": "18",
144+
"end": "24"
145+
}
146+
]
147+
```
148+
149+
## Errors
150+
151+
| HTTP Status Code | Error Description | Exception Class |
152+
| --- | --- | --- |
153+
| 400 | Bad Request | [`ErrorsException`](/doc/models/errors-exception.md) |
154+
| 426 | Please use HTTPS protocol | [`M426ErrorException`](/doc/models/m426-error-exception.md) |
155+

0 commit comments

Comments
 (0)