From afad055089b013e61e7ae96d4e94c7e42bfd3482 Mon Sep 17 00:00:00 2001 From: Catherine Yan <52057120+Chyan214@users.noreply.github.com> Date: Sun, 27 Oct 2019 20:14:01 -0500 Subject: [PATCH] =?UTF-8?q?=C2=AF\=5F(=E3=83=84)=5F/=C2=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Decisions need to be made on the database and how the server will be hosted befor a database can be created. Preferably a linux computer, because it is better for MySQL. Additionally, we could find an online database, but it will probably cost money, so I would not recommend. --- README.md | 13 +++++- extension/backend/server/app.py | 46 +++++++++++++++++++ .../backend/tokenizer_files/Documentation.txt | 4 +- 3 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 extension/backend/server/app.py diff --git a/README.md b/README.md index 8ba5e5c..6133553 100644 --- a/README.md +++ b/README.md @@ -11,15 +11,24 @@ CS506 Project ## Installation Installations and downloads required before running the application ### Downloads -* (optional test data) Reddit World News Database: https://www.kaggle.com/rootuser/worldnews-on-reddit +* (optional test data) Reddit World News Database: https://www.kaggle.com/rootuser/worldnews-on-reddit +* MySQL documentation: https://dev.mysql.com/doc/mysql-getting-started/en/ +* Recommended Database/Downloads: + * free remote mysql(100MB cap): https://remotemysql.com/ + * Community Server: https://dev.mysql.com/downloads/mysql/ + * Visual Studio database: https://dev.mysql.com/downloads/windows/visualstudio/ + * MySQL WorkBench: https://dev.mysql.com/downloads/workbench/ + * General mySQL installer: https://dev.mysql.com/downloads/installer/ Currently looking at Google News vector space -### Library installs +### Installs * `pip install beautifulsoup4` * `pip install spacy` * `python -m spacy download en_core_web_sm` * `pip install --upgrade gensim` +* `pip install Flask` +* `pip install Flask-MySQLdb` Note: 'en_core_web_sm' installation is subject to change for higher accuracy diff --git a/extension/backend/server/app.py b/extension/backend/server/app.py new file mode 100644 index 0000000..8a78dff --- /dev/null +++ b/extension/backend/server/app.py @@ -0,0 +1,46 @@ +from flask import Flask +from flask_mysqldb import MySQL + +# requires a hosting site for database + +app = Flask(__name__) + +# configure database +# probably should use extern variables for this infomation +# documentation https://flask-mysqldb.readthedocs.io/en/latest/ +app.config['MYSQL_HOST'] = '' +app.config['MYSQL_USER'] = '' +app.config['MYSQL_PASSWORD'] = '' +app.config['MYSQL_DB'] = '' + +# instanization of mysql object +mysql = MySQL(app) + +@app.route('/') +# sample section where infomation if placed into database +def home(): + # create cursor object + # allows us to execute querries + cursor = mysql.connection.cursor() + # insert info into the user model + cursor.execute("INSERT INTO user(name,email) VALUES(%s,%s)", (name,email)) + # saves the changes + mysql.conntection.commit() + cursor.close() + return 'Flask' + +@app.route('/users') +# sample code how infomation is retrieved from database +def users(): + cursor = mysql.connection.cursor() + # returns the number of rows in user model in database + resultValue = cur.execute("SELECT * FROM users") + if resultValue > 0: # e.g. there is something inside of the database + # returns all of rows which has been fetched by the cursor + userDetails = cursor.fetchall() + for user in userDetails: + print(user[0]) # username + print(user[0]) # user email + +if __name__ == "__main__": + app.run() \ No newline at end of file diff --git a/extension/backend/tokenizer_files/Documentation.txt b/extension/backend/tokenizer_files/Documentation.txt index 7c34a64..e61b98e 100644 --- a/extension/backend/tokenizer_files/Documentation.txt +++ b/extension/backend/tokenizer_files/Documentation.txt @@ -14,7 +14,7 @@ class Paragraph: Methods: - preprocessing( text): + preprocessing(text): Lemmatize non-stop words, removes punctuation, lowercase all non proper nouns Parameters @@ -49,7 +49,7 @@ Methods: each sentence[x] is a sentence in the given text - predict(claim, text): + predict(claim, text): Predicts which paragraph/setences is most similar to the given claim using the loaded vector space