Commit e4eef220 authored by G.M. Amashi S. Bastiansz's avatar G.M. Amashi S. Bastiansz 🎯

Merge branch 'amashi_dev' of http://gitlab.sliit.lk/2020_077/2020_077 into amashi_dev

parents a5b80859 6abb1837
"""
This file is used as a main file for the user-inputs which have same words/sentences
appears in common.json file
###
# This file is used as a main file for the user-inputs which have same words/sentences
# appears in common.json file
@author Amashi Bastiansz | IT17143950
@version 1.2
@since 2020-07-30
"""
# @author Amashi Bastiansz | IT17143950
# @version 1.2
# @since 2020-07-30
###
import json
import os
......@@ -18,13 +18,13 @@ jsonPath = os.path.join(REVENG, 'common.json')
def checkInJson(message):
"""
# This method is used to create a GIF image for the user-input which is similar
with a sentence appears in common.json file
###
# This method is used to create a GIF image for the user-input which is similar
# with a sentence appears in common.json file
# Also, this method is used to create a GIF image for the user-input which is similar
with a word appears in common.json file
"""
# Also, this method is used to create a GIF image for the user-input which is similar
# with a word appears in common.json file
###
# convert user-input into lowercase
message = message.lower()
......
"""
This file is used to create firbase configuration for the application
###
# This file is used to create firbase configuration for the application
Each application has unique firbase configuration.
# Each application has unique firbase configuration.
@author Amashi Bastiansz | IT17143950
@version 1.0
@since 2020-08-13
"""
# @author Amashi Bastiansz | IT17143950
# @version 1.0
# @since 2020-08-13
###
import json
import os
......@@ -47,10 +47,10 @@ store = firebase.storage()
def getStorageInstance():
"""
This method is used to redirect to the firebase cloud storage
###
# This method is used to redirect to the firebase cloud storage
@return Firebase Cloud Storage
"""
# @return Firebase Cloud Storage
###
return store
"""
This file is used to fetch images of the hand signs from the system database
###
# This file is used to fetch images of the hand signs from the system database
@author Amashi Bastiansz | IT17143950
@version 1.6
@since 2020-08-30
"""
# @author Amashi Bastiansz | IT17143950
# @version 1.6
# @since 2020-08-30
###
import json
import os
......@@ -23,14 +23,14 @@ store = getStorageInstance()
def getImagesCommonWord(message):
"""
This method is used to select hand signs for user-entered text
###
# This method is used to select hand signs for user-entered text
These hand signs are for the words in the common_word section in the
common.json file
# These hand signs are for the words in the common_word section in the
# common.json file
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
images = store.child().list_files()
imageRes = []
......@@ -50,17 +50,17 @@ def getImagesCommonWord(message):
def getImagesForCommonWord(message):
"""
This method is used to select hand signs for user-entered text
###
# This method is used to select hand signs for user-entered text
These hand signs are for the words in the common_word section in the
common.json file
# These hand signs are for the words in the common_word section in the
# common.json file
This method is specifically made for the words which may have more than one hand sign
in the sign language (the words which are need multiple signs to show one verbal word)
# This method is specifically made for the words which may have more than one hand sign
# in the sign language (the words which are need multiple signs to show one verbal word)
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
images = store.child().list_files()
imageRes = []
......@@ -80,12 +80,12 @@ def getImagesForCommonWord(message):
def getImagesForRareWord(message):
"""
This method is used to select hand signs for user-entered text
which is not appeared in common.json file
###
# This method is used to select hand signs for user-entered text
# which is not appeared in common.json file
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
images = store.child().list_files()
imageRes = []
......@@ -105,12 +105,12 @@ def getImagesForRareWord(message):
def getImagesRareWord(message):
"""
This method is used to select hand signs for user-entered text
which is not appeared in common.json file
###
# This method is used to select hand signs for user-entered text
# which is not appeared in common.json file
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
images = store.child().list_files()
imageRes = []
......@@ -130,14 +130,14 @@ def getImagesRareWord(message):
def getImagesCommonSentence(sentence):
"""
This method is used to select hand signs for user-entered sentence
###
# This method is used to select hand signs for user-entered sentence
These hand signs are for the sentences in the common_sentence section in the
common.json file
# These hand signs are for the sentences in the common_sentence section in the
# common.json file
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
sendingToGIF = []
imageRes = []
......
"""
This file is used to display the created GIF to user
This file is still at TESTING PHASE
###
# This file is used to display the created GIF to user
@author Amashi Bastiansz | IT17143950
@version 1.2
@since 2020-10-01
"""
# This file is still at TESTING PHASE
# @author Amashi Bastiansz | IT17143950
# @version 1.2
# @since 2020-10-01
###
import os
import urllib.request
......@@ -22,23 +22,23 @@ app = Flask(__name__)
def allowed_file(filename):
"""
This method is used check the extension of selected file
###
# This method is used check the extension of selected file
@return the extension to check whether it is allowed
"""
# @return the extension to check whether it is allowed
###
return '.' in filename and filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/', methods=['POST'])
def upload_image():
"""
This method is used upload the selected file to the exact folder
after checking whether the extensions are matched.
###
# This method is used upload the selected file to the exact folder
# after checking whether the extensions are matched.
@return redirect to upload.html
"""
# @return redirect to upload.html
###
if 'file' not in request.files:
flash('No file part')
......@@ -59,11 +59,12 @@ def upload_image():
@app.route('/display/<filename>')
def display_image(filename):
"""
This method is used display the uploaded file back to the user
###
# This method is used display the uploaded file back to the user
# @return display the file in the interface
###
@return display the file in the interface
"""
return redirect(url_for('static', filename='uploads/' + filename), code=301)
......
"""
This file is used to display the created GIF to the user on the interface
Still in TESTING phase
@author Amashi Bastiansz | IT17143950
@version 1.5
@since 2020-10-01
"""
###
# This file is used to display the created GIF to the user on the interface
# Still in TESTING phase
# @author Amashi Bastiansz | IT17143950
# @version 1.5
# @since 2020-10-01
###
from flask import Flask
......
"""
This file is used to:
###
# This file is used to:
# generate a GIF image
# send the generated GIF to the folder
# delete the GIF from cache
@author Amashi Bastiansz | IT17143950
@version 1.5
@since 2020-10-01
"""
# @author Amashi Bastiansz | IT17143950
# @version 1.5
# @since 2020-10-01
###
import imageio
import os
......@@ -24,11 +24,11 @@ gifName = ''.join(random.choices(string.ascii_uppercase +
def generateGIF(images):
"""
This method is used to generate a path for the created GIF image
###
# This method is used to generate a path for the created GIF image
@return the generated GIF path
"""
# @return the generated GIF path
###
gifPath = os.path.join(PATH + "\\output\\" + gifName + '.gif')
imageio.mimwrite(gifPath, images, duration=0.5)
......@@ -37,19 +37,20 @@ def generateGIF(images):
def sendGIF():
"""
This method is used to send the generated GIF to the exact folder to store it
"""
###
# This method is used to send the generated GIF to the exact folder to store it
###
x = imageio.mimread(os.path.join(PATH + "\\output\\" + gifName + '.gif'))
return x
def deleteFromCache():
"""
This method is used to delete the generated GIF from cache after uploading it to
the exact project folder
###
# This method is used to delete the generated GIF from cache after uploading it to
# the exact project folder
@return call to generateGIF() method with selected hand images
"""
# @return call to generateGIF() method with selected hand images
###
os.remove(os.path.join(PATH + "\\output\\" + gifName + '.gif'))
"""
This file is used to process the user-entered input
###
# This file is used to process the user-entered input
Through the methods in this file, the system will apply different Tokenization techniques
(in NLP) in order to make the input more identifiable
# Through the methods in this file, the system will apply different Tokenization techniques
# (in NLP) in order to make the input more identifiable
@author Amashi Bastiansz | IT17143950
@version 1.4
@since 2020-07-15
"""
# @author Amashi Bastiansz | IT17143950
# @version 1.4
# @since 2020-07-15
###
import os
import json
......@@ -24,10 +24,10 @@ from reveng.gifMaker import generateGIF
def checkCommon(message):
"""
This method is used to return the checkInJson() method in checkCommon.py file
"""
###
#This method is used to return the checkInJson() method in checkCommon.py file
###
return checkInJson(message)
......@@ -40,13 +40,13 @@ jsonPath = os.path.join(REVENG, 'common.json')
def checkInCommonSentence(sentence):
"""
# This method is used to compare the user-input with common_sentence
section in common.json file
###
# This method is used to compare the user-input with common_sentence
# section in common.json file
#If a similar setence appear in common_sentence section in common.json
file the method will return true
"""
#If a similar setence appear in common_sentence section in common.json
# file the method will return true
###
with open(jsonPath) as jsonfile:
data = json.load(jsonfile)
......@@ -61,13 +61,13 @@ def checkInCommonSentence(sentence):
def checkInCommonWord(word):
"""
This method is used to compare the user-input with common_words
section in common.json file
###
# This method is used to compare the user-input with common_words
# section in common.json file
If a similar setence appear in common_word section in common.json
file the method will return true
"""
# If a similar setence appear in common_word section in common.json
# file the method will return true
###
with open(jsonPath) as jsonfile:
data = json.load(jsonfile)
......@@ -82,10 +82,10 @@ def checkInCommonWord(word):
def processInput(message):
"""
This method is used to send the fetched hand images to generateGIF()
method to create the final GIF image
"""
###
# This method is used to send the fetched hand images to generateGIF()
# method to create the final GIF image
###
message = message.lower()
if len(message.split(" ")) >= 2:
......
"""
This file is used to check a user-entered sentence with json file
and return the relevant GIF image
###
# This file is used to check a user-entered sentence with json file
# and return the relevant GIF image
@author Amashi Bastiansz | IT17143950
@version 2.0
@since 2020-07-15
"""
# @author Amashi Bastiansz | IT17143950
# @version 2.0
# @since 2020-07-15
###
import json
import os
......@@ -16,10 +16,10 @@ REVENG = os.path.dirname(os.path.abspath(__file__))
def processCommonSentence(message):
"""
This method is used to process a sentence which has similar sentences in common.json file
and to return the GIF
"""
###
# This method is used to process a sentence which has similar sentences in common.json file
# and to return the GIF
###
splitMessage = message.split(" ")
gif = getImagesCommonSentence(splitMessage)
......@@ -27,10 +27,10 @@ def processCommonSentence(message):
def processRareSentence(message):
"""
This method is used to process a sentence which does not have similar sentences in common.json file
and to return the GIF
"""
###
# This method is used to process a sentence which does not have similar sentences in common.json file
#and to return the GIF
###
splitMessage = message.split(" ")
gif = getImagesCommonSentence(splitMessage)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment