Skip to content

Commit

Permalink
added recording translation obtained
Browse files Browse the repository at this point in the history
  • Loading branch information
dipteshkanojia committed Mar 8, 2022
1 parent ad902d8 commit 1736a4b
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- resolved icon issue while selecting languages.
- resolved "hidden input" dependencies, jquery based language selection using semantic ui default hidden fields.
- navbar icon trimmed.
- added collection of translated text to a file (step towards feedback)
#### 31/12/2021
- **v0.5.1**: Asynchrounous translation finally!
- Changed model to Facebook M2M for supporting 100+ languages.
Expand Down
Empty file added recordTranslations.tsv
Empty file.
Binary file modified routes/__pycache__/request_api.cpython-38.pyc
Binary file not shown.
6 changes: 4 additions & 2 deletions routes/request_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime, timedelta
from flask import jsonify, abort, request, Blueprint, render_template
#from flask import Flask, flash, Response, redirect, url_for, request, session, abort, render_template, make_response, jsonify
import io

from transformers import M2M100ForConditionalGeneration, M2M100Tokenizer
import torch
Expand Down Expand Up @@ -30,8 +31,6 @@ def index():

@REQUEST_API.route('/translate', methods=['POST'])
def translate():
# print( request.form['data'])
# print(request.method, request.form['sourcelang'])

if not request.form:
abort(400)
Expand All @@ -58,6 +57,9 @@ def translate():
result = {
"translated_text": translation[0]
}
with io.open("recordTranslations.tsv", "a") as transWrite:
transWrite.write(source_l + "\t" + target_l + "\t" + "\"" + source_text.strip() + "\"" + "\t" + "\"" + translation[0].strip() + "\"" + "\n")

return jsonify(result), 200


5 changes: 1 addition & 4 deletions templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,13 @@
<br /><br /><br /><br />
<div class="container">
<form method="POST" action="">
<!--input type="hidden" id="sourcelang" name="sourcelang" class="sourcelang" ></input-->
<!--input type="hidden" id="targetlang" name="targetlang" class="targetlang" ></input-->
<!--input type="hidden" id="domainval" name="domainval"></input>-->
A sample sentence: The digital age, also referred to as the information society, is characterized by ever growing volumes of information.<br /><br/>
<br /><br />
<div class="form-group">
<div class="container ui stackable equal width grid">
<div class="ui fluid search dropdown button column">
<i class="cloud icon"></i>
<span class="text">Model</span>
<span class="text">Model-Domain</span>
<div class="menu">
<div class="item disabled">Facebook M2M</div>
</div>
Expand Down

0 comments on commit 1736a4b

Please sign in to comment.