-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c919f0
commit 81f90c9
Showing
28 changed files
with
2,601 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Nepali Transliterator (NepaliXlit) Webapp | ||
|
||
**Adaptation of [IndicXlit](https://github.com/AI4Bharat/IndicXlit) for Nepali systems.** | ||
|
||
<hr> | ||
|
||
Follow the instructions to run the app on your system | ||
|
||
1. Create a virtual environment, so dependencies don't clash | ||
|
||
``` | ||
python3 -m venv venv | ||
source venv/bin/activate | ||
``` | ||
2. Move to the app folder | ||
``` | ||
cd app | ||
``` | ||
3. Install the necessary dependencies | ||
``` | ||
pip install -r app/dependencies.txt | ||
``` | ||
4. Run the application | ||
``` | ||
python3 app.py | ||
``` | ||
Your app will be live at `http://127.0.0.1:8000` | ||
It will take a few minutes for the first time to download the model and initialize the system. | ||
<hr> | ||
![webapp screenshot](app/webapp_ss.png) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
dist/ | ||
*.egg-info/ | ||
venv/ | ||
__pycache__ |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from fastapi import FastAPI, HTTPException, Request | ||
from fastapi.templating import Jinja2Templates | ||
from pydantic import BaseModel | ||
from transliteration import XlitEngine | ||
from time import time | ||
|
||
app = FastAPI() | ||
templates = Jinja2Templates(directory=".") | ||
|
||
engine = XlitEngine("ne", beam_width=10) | ||
|
||
|
||
class Query(BaseModel): | ||
text: str | ||
|
||
@app.get("/") | ||
async def index(request: Request): | ||
return templates.TemplateResponse("index.html", {"request": request}) | ||
|
||
@app.post("/transliterate") | ||
def transliterate(query: Query): | ||
try: | ||
# Make predictions using the loaded model | ||
start_time = time() | ||
out = engine.translit_sentence(query.text) | ||
end_time = time() | ||
|
||
return {"original": query.text, "translit": out, "time_taken": end_time-start_time} | ||
except Exception as exp: | ||
raise HTTPException(status_code=500, detail=str(exp)) | ||
|
||
|
||
if __name__ == "__main__": | ||
import uvicorn | ||
uvicorn.run(app, host="127.0.0.1", port=8000) | ||
|
||
# uvicorn app:app --reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
pydload | ||
flask | ||
flask_cors | ||
Flask-Limiter | ||
gevent | ||
sacremoses | ||
pandas | ||
tqdm | ||
ujson | ||
mock | ||
tensorboardX | ||
pyarrow | ||
fairseq | ||
fastapi | ||
pydantic | ||
uvicorn | ||
|
||
urduhack | ||
indic_nlp_library |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Transliteration App</title> | ||
<style> | ||
body { | ||
font-family: sans-serif; /* Change main font to sans-serif */ | ||
} | ||
.container { | ||
max-width: 600px; | ||
margin: 0 auto; | ||
padding: 20px; | ||
text-align: center; | ||
} | ||
|
||
.input-section { | ||
margin-bottom: 20px; | ||
} | ||
|
||
textarea { | ||
width: 100%; | ||
margin: 10px 0px 40px 0px; | ||
padding: 10px; | ||
font-size: medium; | ||
} | ||
|
||
button { | ||
background-color: #4CAF50; | ||
color: white; | ||
padding: 10px 20px; | ||
border: none; | ||
cursor: pointer; | ||
border-radius: 5px; | ||
font-size: medium; | ||
} | ||
|
||
button:hover { | ||
background-color: #45a049; | ||
} | ||
|
||
.spinner { | ||
animation: spin 1s linear infinite; | ||
border: 2px solid #f3f3f3; /* Light grey */ | ||
border-top: 2px solid #3498db; /* Blue */ | ||
border-radius: 50%; | ||
width: 20px; | ||
height: 20px; | ||
display: inline-block; | ||
margin-left: 10px; | ||
vertical-align: middle; | ||
} | ||
|
||
.output-section { | ||
font-size: 30px; | ||
margin-top: 20px; | ||
} | ||
|
||
.time-taken { | ||
font-size: 14px; | ||
color: #888; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>NepaliXlit</h1> | ||
<div class="input-section"> | ||
<textarea id="textInput" rows="10" cols="50" placeholder="Enter text..."></textarea> | ||
<button onclick="transliterate()">Transliterate</button> | ||
<span id="loading" class="spinner" style="display: none;"></span> | ||
</div> | ||
<div class="output-section"> | ||
<p id="output"></p> | ||
<p id="timeTaken" class="time-taken"></p> | ||
</div> | ||
</div> | ||
|
||
<script> | ||
function transliterate() { | ||
// Show the loading spinner | ||
document.getElementById("loading").style.display = "inline-block"; | ||
|
||
var inputText = document.getElementById("textInput").value; | ||
fetch('/transliterate', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json' | ||
}, | ||
body: JSON.stringify({ text: inputText }) | ||
}) | ||
.then(response => response.json()) | ||
.then(data => { | ||
// Hide the loading spinner | ||
document.getElementById("loading").style.display = "none"; | ||
|
||
console.log(data) | ||
document.getElementById("output").innerText = "Transliteration: " + data.translit.ne; | ||
document.getElementById("timeTaken").innerText = "Time taken: " + (parseFloat(data.time_taken)).toFixed(2) + " seconds" | ||
}) | ||
.catch(error => console.error('Error:', error)); | ||
} | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from .xlit_src import XlitEngine | ||
from .__metadata import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__version__ = "1.1.3" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from .engine import XlitEngineRNN |
Oops, something went wrong.