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
{
"from" : string, // source language
"to" : string, // target language
"from_text" : string, // text to be translated
"id" : int // request id
}
{
"to_text" : string, // translated text
"id" : int // request id
}
{
"from" : string, // source language
"to" : string, // target language
"from_text" : string, // text to be translated
"to_text" : string, // bad translation
"id" : int // request id
}
{
"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
}
{
"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
}
{
"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
}
{
"fid" : int, // foreign key pointing at the bad translation
"page" : int // page number of the possible translations to be seen
}
{
"secondid" : int, // id of the possibleBetterTranslation
"operation": int //+1 or -1 for a vote
}
Virtual Enviroment set-up
$ git clone https://github.com/aiman-al-masoud/translator-cloud-project.git
and navigate to its root directory.
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).
$ 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
Inside the virtual environment you just created:
(venv)$ pip install -r requirements.txt
Get the models
Move to the *tests* directory and executepython3 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
sudo apt update
sudo apt-get install mysql-server
and check if it is correctly installed
systemctl is-active mysql
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
mysql -u root -p
systemctl status mysql.service
# check if the service is running
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)
);
pip install flask-mysqldb
For Linux/Unix platforms, before it, install
sudo apt install libmysqlclient-dev
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)
brew update
brew upgrade
brew install mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'Cloud_08';
FLUSH PRIVILEGES;
mysql -u root -p
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)