<repo_name>SaturnR/geogram<file_sep>/run.sh
#!/usr/bin/env bash


export FLASK_APP=main.py
flask run
<file_sep>/dbcontroller.py
#!/usr/bin/env python3

import sqlite3


class Controller:

    def __init__(self, db_path='./words.db'):
        self.words = {}
        self.db_path = db_path
    
    def save(self, data, append=False):
        '''data: type dictionary, like : {'გამარჯობა' : 10}'''
        conn = sqlite3.connect(self.db_path)
        c = conn.cursor()
        if not append:
            c.execute('CREATE TABLE words (word text, occurrence real)')
        for n in data:
            print(n)
            c.execute("INSERT INTO words VALUES ('"+n+"',0)")
            #c.execute("INSERT INTO words VALUES ('"+n+"',"+str(data[n])+")")
        conn.commit()
        conn.close()

    def load(self, dbfilter=""):
        conn = sqlite3.connect(self.db_path)
        c = conn.cursor()
        c.execute("SELECT * FROM words" + dbfilter)
        dbwords = c.fetchall()
        words = {}
        for w in dbwords:
            words[w[0]] = w[1]
        return words

    def delete(self, word):
        pass
    

if __name__ == "__main__":
    pass
    
    
    
<file_sep>/main.py
from flask import render_template, request
from flask import Flask, json
import sqlite3
from dbcontroller import Controller

app = Flask(__name__)
dbcon = Controller(db_path='extended.db')
db = './extended.db'
words = {}

@app.route('/')
def hello():
    global words
    words = dbcon.load()
    return render_template('main.html')

@app.route('/post', methods=["POST"])
def retValue():
    html = ""
    try:
        recv = request.json['data']
        for word in recv.split():
            wd = word.strip().strip(".").strip(",")\
                                        .strip(":").strip(";").strip("!")\
                                        .strip("(").strip(")").strip("'")\
                                                              .strip('"')
            if wd in words:
                html+='<b><font color="black">'+ word +'</font></b>'
            else:
                html+='<b><font color="red">'+ word +'</font></b>'
            html+=' '
    except Exception as es:
        print('error', es)
        
    data = {"text": html} 
    response = app.response_class(response=json.dumps(data),
                                  status=200,
                                  mimetype='application/json')
    return response

@app.route('/text_feed', methods = ['POST', 'GET'])
def result():
    global words
    if request.method == 'POST':
        result = request.form
        text = result['text_feed']
        print(text)
        psswd = '<PASSWORD>'
        if psswd in text:
            ws = text.strip(psswd).split()
            dbcon.save(ws, append=True)
            words = dbcon.load()
        return render_template("main.html")
<file_sep>/README.md
# geogram
Georgian grammar and orthography checker

Repository intended for georgian language grammar checker website.

links: 
- PyCHM is a Python library to manipulate CHM files 
  https://github.com/dottedmag/pychm
- ენობრივ შეცდომათა ლექსიკონი errata.ge
- GeoWordsDatabase 
  https://github.com/bumbeishvili/GeoWordsDatabase
- ქართული ორთოგრაფიული ლექსიკონი - 
  https://github.com/gamag/ka_GE.spell
<file_sep>/requirements.txt
attrs==19.3.0
backcall==0.1.0
Click==7.0
decorator==4.4.1
Flask==1.1.1
importlib-metadata==1.4.0
ipython==7.11.1
ipython-genutils==0.2.0
itsdangerous==1.1.0
jedi==0.15.2
Jinja2==2.10.3
MarkupSafe==1.1.1
more-itertools==8.1.0
packaging==20.0
parso==0.5.2
pexpect==4.7.0
pickleshare==0.7.5
pluggy==0.13.1
prompt-toolkit==3.0.2
ptyprocess==0.6.0
py==1.8.1
Pygments==2.5.2
pyparsing==2.4.6
pytest==5.3.2
six==1.13.0
traitlets==4.3.3
wcwidth==0.1.8
Werkzeug==0.16.0
zipp==0.6.0
