Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
[apps] Update latest app instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
GokulNC committed Nov 10, 2020
1 parent 1107338 commit 09b1b72
Showing 1 changed file with 54 additions and 58 deletions.
112 changes: 54 additions & 58 deletions apps/README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,59 @@
# Applications
# AI4Bharat Transliteration Application

Contains Applications built around the Transliteration engine. The contents of this folder (to be downloaded from [latest release](https://github.com/AI4Bharat/IndianNLP-Transliteration/releases/latest)) is sufficient for usage.
## Deep Indic Xlit Engine

1. Python Library for running transliteration from Roman to Native text
2. HTTPS API exposing for interation with web applications
3. NN based models and related metadata
A deep transliteration engine for major languages of the Indian sub-continent.

# Usage
This package provides support for:
1. Python Library for transliteration from Roman to Native text (using NN-based models)
2. HTTP API exposing for interation with web applications

### Python Library

*Note: Initially set pythonpath environment variable* <br>
`export PYTHONPATH=path/to/xlit_apps:$PYTHONPATH`
## Languages Supported

**Example 1** : Using word Transliteration
|ISO 639 code|Language|
|---|-----------------|
|bn |Bengali |
|gom|Konkani Goan |
|gu |Gujarati |
|hi |Hindi |
|kn |Kannada |
|mai|Maithili |
|ml |Malayalam |
|mr |Marathi |
|pa |Punjabi (Eastern)|
|sd |Sindhi (Western) |
|si |Sinhala |
|ta |Tamil |
|te |Telugu |
|ur |Urdu |

Note: <br>
`beam_width` increases beam search size, resulting in improved accuracy but increases time/compute. <br>
`topk` returns only specified number of top results.
## Usage

### Python Library

Import the transliteration engine by:
```
from xlit_src import XlitEngine
from ai4bharat.transliteration import XlitEngine
```

**Example 1** : Using word Transliteration

```py

e = XlitEngine("hi")
out = e.translit_word("aam", topk=5, beam_width=10)
print(out)
# output:{'hi': ['कम्प्यूटर', 'कंप्यूटर', 'कम्पूटर', 'कम्पुटर', 'कम्प्युटर']}

```
**Example 2** : Using Sentence Transliteration

Note: <br>
`beam_width` increases beam search size, resulting in improved accuracy but increases time/compute. <br>
Only single top most prediction is returned for sentences.
Note:
- `beam_width` increases beam search size, resulting in improved accuracy but increases time/compute.
- `topk` returns only specified number of top results.

**Example 2** : Using Sentence Transliteration

```
from xlit_src import XlitEngine
```py

e = XlitEngine("ta")
out = e.translit_sentence("vanakkam ulagam !", beam_width=10)
Expand All @@ -46,10 +62,12 @@ print(out)

```

Note:
- Only single top most prediction is returned for each word in sentence.

**Example 3** : Using Multiple language Transliteration

```
from xlit_src import XlitEngine
```py

e = XlitEngine(["ta", "ml"])
# leave empty or use "all" to load all available languages
Expand All @@ -68,47 +86,25 @@ out = e.translit_word("amma", lang_code = "ml", topk=5, beam_width=10)
print(out)
# output: ['അമ്മ', 'എമ്മ', 'അമ', 'എഎമ്മ', 'അഎമ്മ']

```

### Web API
### Web API Server

1. Make required modification in SSL paths in `api_expose.py`. By default set to local host and both http & https are enabled <br>
1. Make required modification in SSL paths in `api_expose.py`. By default set to local host and both http & https are enabled.

2. Run the API expose code <br>
`$ sudo env PATH=$PATH python3 api_expose.py` <br>
Export `GOOGLE_APPLICATION_CREDENTIALS` if needed, by default functions realted to Google cloud is disabled.
2. Run the API expose code:
`$ sudo env PATH=$PATH python3 api_expose.py`
(Export `GOOGLE_APPLICATION_CREDENTIALS` if needed, by default functions realted to Google cloud is disabled.)

3. In browser (or) curl, use link as https://{IP-address}:{port}/tl/{lang-id}/{word in eng script} <br>
If debug mode enabled port will be 8000, else port will be 80 <br>
example: <br>
https://localhost:80/tl/ta/amma <br>
https://localhost:80/languages <br>
3. In browser (or) curl, use link as http://{IP-address}:{port}/tl/{lang-id}/{word in eng script}
If debug mode enabled port will be 8000, else port will be 80.

Example:
http://localhost:80/tl/ta/amma
http://localhost:80/languages

### Language Codes:
```
* bn - Bengali
* gom - Konkani Goan
* gu - Gujarati
* hi - Hindi
* kn - Kannada
* mai - Maithili
* ml - Malayalam
* mr - Marathi
* pa - Punjabi Eastern
* sd - Sindhi
* si - Sinhala
* ta - Tamil
* te - Telugu
* ur - Urdu
```
---

## Dependencies:
* torch
* numpy
## Release Notes

Web api, also depends
* flask
* flask_cors
* gevent
This package contains applications built around the Transliteration engine. The contents of this package can also be downloaded from [latest GitHub release](https://github.com/AI4Bharat/IndianNLP-Transliteration/releases/latest) is sufficient for inference usage.

0 comments on commit 09b1b72

Please sign in to comment.