Skip to content

aiman-al-masoud/translator-cloud-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

API Documentation

Community

Here some notes about the community.html page:

  • suggesting an exsisting bad translation is equal to an upvote for that translation
  • hash from_text and to_text in the better translation
  • suggesting an exsisting better translation proposal is equal to an upvote for that translation
API

Translate API

Query

{
"from" : string, // source language
"to" : string, // target language
"from_text" : string, // text to be translated
"id" : int // request id
}

Response

{
"to_text" : string, // translated text
"id" : int // request id
}

badTranslations write

{
"from" : string, // source language
"to" : string, // target language
"from_text" : string, // text to be translated
"to_text" : string, // bad translation
"id" : int // request id
}

badTranslations read (TODO: update for the filter)

Query

{
  "page" : int, //page number to be loaded
  "from" : string, // source language if we want to filter the results
  "to" : string // target language if we want to filter the results
}

Response

{
"from" : string, // source language
"to" : string, // target language
"from_text" : string, // text to be translated
"to_text" : string, // bad translation
"id" : int // request id
"complaints": int // number of complaints
}

possibleBetterTranslations write

{
  "from_text" : string, // text to be translated
  "to_text" : string, // proposed translation
  "secondid" : int, // request id
  "fid" : int // foreign key pointing at the bad translation
}

possibleBetterTranslations read

{
  "fid" : int, // foreign key pointing at the bad translation
  "page" : int // page number of the possible translations to be seen
}

possibleBetterTranslations votes

{
  "secondid" : int, // id of the possibleBetterTranslation
  "operation": int //+1 or -1 for a vote
}
Virtual Enviroment set-up

1) Clone this repo

$ git clone https://github.com/aiman-al-masoud/translator-cloud-project.git

and navigate to its root directory.

2) Create a python virtual environment

Use this name necessarily, because of the .gitignore

$ python3 -m venv .venv

(You'll be prompted to install the 'venv' module if you don't have it yet).

3) Activate the virtual environment

$ source .venv/bin/activate

(You should notice that the console starts displaying the virtual environment's name before your username and the dollar-sign).

To exit from the virtual environment

$ deactivate

4) Install this app's dependencies

Inside the virtual environment you just created:

(venv)$ pip install -r requirements.txt
Get the models Move to the *tests* directory and execute
python3 install-language-models.py -f en -t it -txt "Hello World"
# en -> it
python3 install-language-models.py -f it -t en -txt "Ciao Mondo"
# it -> en

If there are any problems with downloading language packages:

$ python3
>>> import argostranslate.package
>>> argostranslate.package.update_package_index()
>>> exit()

And then run the two commands above.

MySQL set-up using Ubuntu

1) Update repositories

sudo apt update

2) Install MySQL

sudo apt-get install mysql-server

and check if it is correctly installed

systemctl is-active mysql

3) Set password

sudo mysql_secure_installation
# enter "2"

Use as password: Cloud_08

sudo mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Cloud_08';
FLUSH PRIVILEGES;
exit

4) Enter in mySQL

mysql -u root -p
systemctl status mysql.service
# check if the service is running

5) Create database and tables

CREATE DATABASE `flask`;
use flask;
CREATE TABLE badTranslations (
FROMTAG varchar(2) not null,
TOTAG varchar(2) not null,
FROM_TEXT varchar(60) not null,
TO_TEXT varchar(60) not null,
ID integer(30) not null,
PRIMARY KEY (ID)
);

6) Install the python library

pip install flask-mysqldb

For Linux/Unix platforms, before it, install

sudo apt install libmysqlclient-dev

7) Upgrade the database

Login to MySQL

mysql -u root -p
# pswd is "Cloud_08"

Set the using database

mysql> use flask;

Add the new column to the table badTranslations

mysql> ALTER TABLE badTranslations ADD COMPLAINTS integer(5) not null;
CREATE TABLE possibleBetterTranslations (
FROM_TEXT varchar(60) not null,
TO_TEXT varchar(60) not null,
SECONDID integer(30) not null,
FID integer(30) not null,
FOREIGN KEY (FID) REFERENCES badTranslations(ID),
PRIMARY KEY (SECONDID)
);

Add a new column to the table possibleBetterTranslations

mysql> ALTER TABLE possibleBetterTranslations ADD VOTES integer(5) not null;
mysql> ALTER TABLE possibleBetterTranslations ADD TIMESTAMP timestamp not null;
MySQL set-up on Mac (M1)

1) Update repositories

brew update
brew upgrade

2) Install MySQL

brew install mysql

3) Set password

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Cloud_08';
FLUSH PRIVILEGES;

4) Enter in mySQL

mysql -u root -p

5) Create database and tables

CREATE DATABASE `flask`;
use flask;
CREATE TABLE badTranslations (
FROMTAG varchar(2) not null,
TOTAG varchar(2) not null,
FROM_TEXT varchar(60) not null,
TO_TEXT varchar(60) not null,
ID integer(30) not null,
PRIMARY KEY (ID)
);
Neo4j set-up To run the db use the following command:
docker run --publish=7474:7474 --publish=7687:7687 --volume=$HOME/neo4j/data:/data neo4j

For other details see the dedicated documentation file (./scripts/docker-files/db)