Skip to content

Operation

Sotiris edited this page Jul 10, 2019 · 2 revisions

This page illustrates a step-by-step procedure to set up this project

Step 0: Preparation and Installation

The procedure of installation is outlined in the Installation Page

Step 1: Gather Documents

  1. In order to setup the project you need to gather Government Gazette Documents from ET either by hand or using the Fetching Tool to either fetch using your own parameters or schedule the task.
  2. Put the data in directory. For example:
data/
  |-   file1.{pdf,txt}
  |-   file2.{pdf,txt}
     ...
  |-   filen.{pdf,txt}
  1. If the data is already in .txt format then you can head over Step 3

Step 2: Converting the documents

If the documents are in PDF format (either contain text or not) you should convert them to plain text format. For this purpose you will need to follow the steps outlined here to setup the conversion process. Then you can batch-convert the documents with one command:

python3 scripts/converter.py -input_dir ../data/1998/ -output_dir ../data/1998/ -pdf2txt pdf2txt.py

Step 3: Codification Procedure

  1. Populate the database with detected laws
>>> from codifier import LawCodifier
>> cod = LawCodifier('../data/new')
  1. Get the new laws published at the GG Issues (ΦΕΚ Α')
>> cod.codify_new_laws()
  1. Codify the a law using the codify_law(law) command (under development)
>>> cod.codify_law(ν. 4448/2018')
  1. Get a law as a string or export it to PDF via the Texification Tool using xelatex
# as a string
>> result = cod.get_law('ν. 4448/2018')
# or a pdf using xelatex
>> cod.texify_law('ν. 4448/2018', 'Κωδικοποιημένος_Νόμος.pdf') 
  1. The data is organized in the MongoDB database in versions for easier lookup. The contents of each version are organized in periods.
_id: "ν. 4448/2018"
versions: Array
   0: Object
      articles: Object
             1: Object
                0: Array
                   0: "Τα Μέρη, στο πλαίσιο του παρόντος Μνημονίου Κατανόησης και σύμφωνα με ..."
             2: Object
      lemmas: Object
      titles: Object
      _version: 0
      amendee: "ν. 4448/2018"
  1. For more details visit the Codifier page

Step 4: Optional Functionality

  1. Apply Topic Models on Government Gazette Issues
  2. Document Embeddings with Doc2Vec

Step 5: Deploying the Angular Application

  1. Navigate to angularui/
  2. Run npm install to install project dependencies.
  3. Run ng build to compile the project.
  4. Run ng serve to serve the project.
  5. Navigate to localhost:4200 where the application is deployed.

Deploying on a virtual machine

Follow this guide to deploy the flask application with nginx and gunicorn.

Run gunicorn via:

gunicorn --workers NWORKERS app:app -b localhost:8000

Configuration file at /etc/nginx/conf.d/virtual.conf

server {
    listen       80;
    server_name  3gm.papachristoumarios.me openlaws.ellak.gr 3gm.ellak.gr;

    location / {
        proxy_pass http://127.0.0.1:8000;
    }
}

Supervisor configuration:

[program:3gm]
directory=/var/www/gsoc2018-3gm/3gm
command=gunicorn --workers 3 app:app -b localhost:8000
autostart=true
autorestart=true
stderr_logfile=/var/log/3gm.err.log
stdout_logfile=/var/log/3gm.out.log