Added coffeehouse_emotions
This commit is contained in:
parent
3c494acd87
commit
9e785c73ec
|
@ -23,6 +23,8 @@ echo "### Starting CoffeeHouse-CoreNLP ###"
|
||||||
make start_corenlp &
|
make start_corenlp &
|
||||||
echo "### Starting CoffeeHouse-NSFW ###"
|
echo "### Starting CoffeeHouse-NSFW ###"
|
||||||
make start_nsfw &
|
make start_nsfw &
|
||||||
|
echo "### Starting CoffeeHouse-Emotions ###"
|
||||||
|
make start_emotions &
|
||||||
|
|
||||||
echo "### Checking Service Status ###"
|
echo "### Checking Service Status ###"
|
||||||
|
|
||||||
|
@ -60,6 +62,13 @@ while sleep 60; do
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
ps aux | grep coffeehouse_emotions | grep -q -v grep
|
||||||
|
EMOTION_STATUS=$?
|
||||||
|
if [ $EMOTION_STATUS -ne 0 ]; then
|
||||||
|
echo "ERROR: coffeehouse_emotion has been terminated, terminating container."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
ps aux | grep coffeehouse_ping | grep -q -v grep
|
ps aux | grep coffeehouse_ping | grep -q -v grep
|
||||||
PING_STATUS=$?
|
PING_STATUS=$?
|
||||||
if [ $PING_STATUS -ne 0 ]; then
|
if [ $PING_STATUS -ne 0 ]; then
|
||||||
|
|
483
Makefile
483
Makefile
|
@ -1,235 +1,250 @@
|
||||||
clean_apt:
|
clean_apt:
|
||||||
rm -rf mods/apt/build mods/apt/dist mods/apt/coffeehousemod_apt.egg-info
|
rm -rf mods/apt/build mods/apt/dist mods/apt/coffeehousemod_apt.egg-info
|
||||||
|
|
||||||
clean_stopwords:
|
clean_stopwords:
|
||||||
rm -rf mods/stopwords/build mods/stopwords/dist mods/stopwords/coffeehousemod_stopwords.egg-info
|
rm -rf mods/stopwords/build mods/stopwords/dist mods/stopwords/coffeehousemod_stopwords.egg-info
|
||||||
|
|
||||||
clean_tokenizer:
|
clean_tokenizer:
|
||||||
rm -rf mods/tokenizer/build mods/tokenizer/dist mods/tokenizer/coffeehousemod_tokenizer.egg-info
|
rm -rf mods/tokenizer/build mods/tokenizer/dist mods/tokenizer/coffeehousemod_tokenizer.egg-info
|
||||||
|
|
||||||
clean_dltc:
|
clean_dltc:
|
||||||
rm -rf dltc/build dltc/dist dltc/coffeehouse_dltc.egg-info
|
rm -rf dltc/build dltc/dist dltc/coffeehouse_dltc.egg-info
|
||||||
|
|
||||||
clean_nlpfr:
|
clean_nlpfr:
|
||||||
rm -rf nlpfr/build nlpfr/dist nlpfr/nltk.egg-info
|
rm -rf nlpfr/build nlpfr/dist nlpfr/nltk.egg-info
|
||||||
|
|
||||||
clean_alg:
|
clean_alg:
|
||||||
rm -rf alg/build alg/dist alg/coffeehouse_alg.egg-info
|
rm -rf alg/build alg/dist alg/coffeehouse_alg.egg-info
|
||||||
|
|
||||||
clean_rf:
|
clean_rf:
|
||||||
rm -rf resource_fetch/build resource_fetch/dist resource_fetch/resource_fetch.egg-info
|
rm -rf resource_fetch/build resource_fetch/dist resource_fetch/resource_fetch.egg-info
|
||||||
|
|
||||||
clean_his:
|
clean_his:
|
||||||
rm -rf hyper_internal_service/build hyper_internal_service/dist hyper_internal_service/hyper_internal_service.egg-info
|
rm -rf hyper_internal_service/build hyper_internal_service/dist hyper_internal_service/hyper_internal_service.egg-info
|
||||||
|
|
||||||
clean_langdetect:
|
clean_langdetect:
|
||||||
rm -rf services/language_detection/build services/language_detection/dist services/language_detection/coffeehouse_languagedetection.egg-info
|
rm -rf services/language_detection/build services/language_detection/dist services/language_detection/coffeehouse_languagedetection.egg-info
|
||||||
|
|
||||||
clean_spamdetect:
|
clean_spamdetect:
|
||||||
rm -rf services/spam_detection/build services/spam_detection/dist services/spam_detection/coffeehouse_spamdetection.egg-info
|
rm -rf services/spam_detection/build services/spam_detection/dist services/spam_detection/coffeehouse_spamdetection.egg-info
|
||||||
|
|
||||||
clean_ping:
|
clean_emotions:
|
||||||
rm -rf services/ping_service/build services/ping_service/dist services/ping_service/coffeehouse_ping.egg-info
|
rm -rf services/emotions/build services/emotions/dist services/emotions/coffeehouse_emotions.egg-info
|
||||||
|
|
||||||
clean_translation:
|
clean_ping:
|
||||||
rm -rf services/translation/build services/translation/dist services/translation/coffeehouse_translation.egg-info
|
rm -rf services/ping_service/build services/ping_service/dist services/ping_service/coffeehouse_ping.egg-info
|
||||||
|
|
||||||
clean_corenlp:
|
clean_translation:
|
||||||
cd services/corenlp; make clean
|
rm -rf services/translation/build services/translation/dist services/translation/coffeehouse_translation.egg-info
|
||||||
|
|
||||||
clean_nsfw:
|
clean_corenlp:
|
||||||
rm -rf services/nsfw_detection/build services/nsfw_detection/dist services/nsfw_detection/coffeehouse_nsfw.egg-info
|
cd services/corenlp; make clean
|
||||||
|
|
||||||
clean:
|
clean_nsfw:
|
||||||
make clean_apt clean_stopwords clean_tokenizer clean_nlpfr
|
rm -rf services/nsfw_detection/build services/nsfw_detection/dist services/nsfw_detection/coffeehouse_nsfw.egg-info
|
||||||
make clean_dltc
|
|
||||||
make clean_his
|
clean:
|
||||||
make clean_alg
|
make clean_apt clean_stopwords clean_tokenizer clean_nlpfr
|
||||||
make clean_rf
|
make clean_dltc
|
||||||
make clean_translation
|
make clean_his
|
||||||
make clean_langdetect
|
make clean_alg
|
||||||
make clean_spamdetect
|
make clean_rf
|
||||||
make clean_nsfw
|
make clean_translation
|
||||||
make clean_corenlp
|
make clean_langdetect
|
||||||
make clean_ping
|
make clean_spamdetect
|
||||||
|
make clean_emotions
|
||||||
# ======================================================================================================================
|
make clean_nsfw
|
||||||
|
make clean_corenlp
|
||||||
build_apt:
|
make clean_ping
|
||||||
cd mods/apt; python3 setup.py build; python3 setup.py sdist
|
|
||||||
|
# ======================================================================================================================
|
||||||
build_stopwords:
|
|
||||||
cd mods/stopwords; python3 setup.py build; python3 setup.py sdist
|
build_apt:
|
||||||
|
cd mods/apt; python3 setup.py build; python3 setup.py sdist
|
||||||
build_tokenizer:
|
|
||||||
cd mods/tokenizer; python3 setup.py build; python3 setup.py sdist
|
build_stopwords:
|
||||||
|
cd mods/stopwords; python3 setup.py build; python3 setup.py sdist
|
||||||
build_mods:
|
|
||||||
make build_apt build_stopwords build_tokenizer
|
build_tokenizer:
|
||||||
|
cd mods/tokenizer; python3 setup.py build; python3 setup.py sdist
|
||||||
build_nlpfr:
|
|
||||||
make build_mods
|
build_mods:
|
||||||
cd nlpfr; python3 setup.py build; python3 setup.py sdist
|
make build_apt build_stopwords build_tokenizer
|
||||||
|
|
||||||
build_dltc:
|
build_nlpfr:
|
||||||
cd dltc; python3 setup.py build; python3 setup.py sdist
|
make build_mods
|
||||||
|
cd nlpfr; python3 setup.py build; python3 setup.py sdist
|
||||||
build_alg:
|
|
||||||
cd alg; python3 setup.py build; python3 setup.py sdist
|
build_dltc:
|
||||||
|
cd dltc; python3 setup.py build; python3 setup.py sdist
|
||||||
build_his:
|
|
||||||
cd hyper_internal_service; python3 setup.py build; python3 setup.py sdist
|
build_alg:
|
||||||
|
cd alg; python3 setup.py build; python3 setup.py sdist
|
||||||
build_rf:
|
|
||||||
cd resource_fetch; python3 setup.py build; python3 setup.py sdist
|
build_his:
|
||||||
|
cd hyper_internal_service; python3 setup.py build; python3 setup.py sdist
|
||||||
build_langdetect:
|
|
||||||
cd services/language_detection; python3 setup.py build; python3 setup.py sdist
|
build_rf:
|
||||||
|
cd resource_fetch; python3 setup.py build; python3 setup.py sdist
|
||||||
build_spamdetect:
|
|
||||||
cd services/spam_detection; python3 setup.py build; python3 setup.py sdist
|
build_langdetect:
|
||||||
|
cd services/language_detection; python3 setup.py build; python3 setup.py sdist
|
||||||
build_translation:
|
|
||||||
cd services/translation; python3 setup.py build; python3 setup.py sdist
|
build_spamdetect:
|
||||||
|
cd services/spam_detection; python3 setup.py build; python3 setup.py sdist
|
||||||
build_corenlp:
|
|
||||||
cd services/corenlp; make build
|
build_emotions:
|
||||||
|
cd services/emotions; python3 setup.py build; python3 setup.py sdist
|
||||||
build_nsfw:
|
|
||||||
cd services/nsfw_detection; python3 setup.py build; python3 setup.py sdist
|
build_translation:
|
||||||
|
cd services/translation; python3 setup.py build; python3 setup.py sdist
|
||||||
build_ping:
|
|
||||||
cd services/ping_service; python3 setup.py build; python3 setup.py sdist
|
build_corenlp:
|
||||||
|
cd services/corenlp; make build
|
||||||
build:
|
|
||||||
make build_nlpfr
|
build_nsfw:
|
||||||
make build_his
|
cd services/nsfw_detection; python3 setup.py build; python3 setup.py sdist
|
||||||
make build_dltc
|
|
||||||
make build_alg
|
build_ping:
|
||||||
make build_rf
|
cd services/ping_service; python3 setup.py build; python3 setup.py sdist
|
||||||
make buid_translation
|
|
||||||
make build_langdetect
|
build:
|
||||||
make build_spamdetect
|
make build_nlpfr
|
||||||
make build_nsfw
|
make build_his
|
||||||
make build_corenlp
|
make build_dltc
|
||||||
make build_ping
|
make build_alg
|
||||||
|
make build_rf
|
||||||
# ======================================================================================================================
|
make buid_translation
|
||||||
|
make build_langdetect
|
||||||
install_apt:
|
make build_spamdetect
|
||||||
cd mods/apt; python3 setup.py install
|
make build_emotions
|
||||||
|
make build_nsfw
|
||||||
install_stopwords:
|
make build_corenlp
|
||||||
cd mods/stopwords; python3 setup.py install
|
make build_ping
|
||||||
|
|
||||||
install_tokenizer:
|
# ======================================================================================================================
|
||||||
cd mods/tokenizer; python3 setup.py install
|
|
||||||
|
install_apt:
|
||||||
install_mods:
|
cd mods/apt; python3 setup.py install
|
||||||
make install_apt install_stopwords install_tokenizer
|
|
||||||
|
install_stopwords:
|
||||||
install_nlpfr:
|
cd mods/stopwords; python3 setup.py install
|
||||||
make install_mods
|
|
||||||
cd nlpfr; python3 setup.py install
|
install_tokenizer:
|
||||||
|
cd mods/tokenizer; python3 setup.py install
|
||||||
install_dltc:
|
|
||||||
cd dltc; python3 setup.py install
|
install_mods:
|
||||||
|
make install_apt install_stopwords install_tokenizer
|
||||||
install_alg:
|
|
||||||
cd alg; python3 setup.py install
|
install_nlpfr:
|
||||||
|
make install_mods
|
||||||
install_his:
|
cd nlpfr; python3 setup.py install
|
||||||
cd hyper_internal_service; python3 -m pip install -Ur dev_requirements.txt; python3 setup.py install
|
|
||||||
|
install_dltc:
|
||||||
install_rf:
|
cd dltc; python3 setup.py install
|
||||||
cd resource_fetch; python3 setup.py install
|
|
||||||
python3 -m resource_fetch
|
install_alg:
|
||||||
|
cd alg; python3 setup.py install
|
||||||
install_langdetect:
|
|
||||||
cd services/language_detection; python3 setup.py install
|
install_his:
|
||||||
|
cd hyper_internal_service; python3 -m pip install -Ur dev_requirements.txt; python3 setup.py install
|
||||||
install_spamdetect:
|
|
||||||
cd services/spam_detection; python3 setup.py install
|
install_rf:
|
||||||
|
cd resource_fetch; python3 setup.py install
|
||||||
install_translation:
|
python3 -m resource_fetch
|
||||||
cd services/translation; python3 setup.py install
|
|
||||||
|
install_langdetect:
|
||||||
install_nsfw:
|
cd services/language_detection; python3 setup.py install
|
||||||
python3 -m pip install opencv-python
|
|
||||||
python3 -m pip install scikit-image
|
install_spamdetect:
|
||||||
python3 -m pip install pydload
|
cd services/spam_detection; python3 setup.py install
|
||||||
cd services/nsfw_detection; python3 setup.py install
|
|
||||||
|
install_emotions:
|
||||||
install_ping:
|
cd services/emotions; python3 setup.py install
|
||||||
cd services/ping_service; python3 setup.py install
|
|
||||||
|
install_translation:
|
||||||
install_full:
|
cd services/translation; python3 setup.py install
|
||||||
make install_rf
|
|
||||||
make install
|
install_nsfw:
|
||||||
|
python3 -m pip install opencv-python
|
||||||
install:
|
python3 -m pip install scikit-image
|
||||||
make install_nlpfr
|
python3 -m pip install pydload
|
||||||
make install_his
|
cd services/nsfw_detection; python3 setup.py install
|
||||||
make install_dltc
|
|
||||||
make install_alg
|
install_ping:
|
||||||
make install_translation
|
cd services/ping_service; python3 setup.py install
|
||||||
make install_langdetect
|
|
||||||
make install_spamdetect
|
install_full:
|
||||||
make install_nsfw
|
make install_rf
|
||||||
make build_corenlp
|
make install
|
||||||
make install_ping
|
|
||||||
|
install:
|
||||||
# ======================================================================================================================
|
make install_nlpfr
|
||||||
|
make install_his
|
||||||
system_prep_python:
|
make install_dltc
|
||||||
apt -y install python3 python3-distutils python3-dev python3-setuptools
|
make install_alg
|
||||||
|
make install_translation
|
||||||
system_prep_pip:
|
make install_langdetect
|
||||||
apt -y install wget curl
|
make install_spamdetect
|
||||||
wget https://bootstrap.pypa.io/get-pip.py
|
make install_emotions
|
||||||
python3 get-pip.py
|
make install_nsfw
|
||||||
rm get-pip.py
|
make build_corenlp
|
||||||
|
make install_ping
|
||||||
system_prep_gcc:
|
|
||||||
apt -y install gcc build-essential
|
# ======================================================================================================================
|
||||||
python3 -m pip install cython
|
|
||||||
|
system_prep_python:
|
||||||
system_prep_java:
|
apt -y install python3 python3-distutils python3-dev python3-setuptools
|
||||||
apt -y install openjdk-8-jre openjdk-8-jdk ant
|
|
||||||
|
system_prep_pip:
|
||||||
# ======================================================================================================================
|
apt -y install wget curl
|
||||||
|
wget https://bootstrap.pypa.io/get-pip.py
|
||||||
start_langdetect:
|
python3 get-pip.py
|
||||||
python3 -m coffeehouse_languagedetection --start-server
|
rm get-pip.py
|
||||||
|
|
||||||
start_spamdetect:
|
system_prep_gcc:
|
||||||
python3 -m coffeehouse_spamdetection --start-server
|
apt -y install gcc build-essential
|
||||||
|
python3 -m pip install cython
|
||||||
start_translation:
|
|
||||||
python3 -m coffeehouse_translation --start-server
|
system_prep_java:
|
||||||
|
apt -y install openjdk-8-jre openjdk-8-jdk ant
|
||||||
start_nsfw:
|
|
||||||
python3 -m coffeehouse_nsfw --start-server
|
# ======================================================================================================================
|
||||||
|
|
||||||
start_corenlp:
|
start_langdetect:
|
||||||
cd services/corenlp; make start
|
python3 -m coffeehouse_languagedetection --start-server
|
||||||
|
|
||||||
start_ping:
|
start_spamdetect:
|
||||||
python3 -m coffeehouse_ping --start-server
|
python3 -m coffeehouse_spamdetection --start-server
|
||||||
|
|
||||||
start_warmup:
|
start_emotions:
|
||||||
cd scripts; python3 warmup.py
|
python3 -m coffeehouse_emotions --start-server
|
||||||
|
|
||||||
# ======================================================================================================================
|
start_translation:
|
||||||
|
python3 -m coffeehouse_translation --start-server
|
||||||
docker_build:
|
|
||||||
docker build -t="coffeehouse_utils" -f Dockerfile .
|
start_nsfw:
|
||||||
|
python3 -m coffeehouse_nsfw --start-server
|
||||||
docker_run:
|
|
||||||
docker run -it --name coffeehouse_utils -h coffeehouse_utils --restart always -p 5600:5600 -p 5601:5601 -p 5602:5602 -p 5603:5603 -p 5604:5604 -p 5606:5606 coffeehouse_utils
|
start_corenlp:
|
||||||
|
cd services/corenlp; make start
|
||||||
docker_run_no_expose:
|
|
||||||
docker run -it --name coffeehouse_utils -h coffeehouse_utils --restart always coffeehouse_utils
|
start_ping:
|
||||||
|
python3 -m coffeehouse_ping --start-server
|
||||||
docker_rm:
|
|
||||||
|
start_warmup:
|
||||||
|
cd scripts; python3 warmup.py
|
||||||
|
|
||||||
|
# ======================================================================================================================
|
||||||
|
|
||||||
|
docker_build:
|
||||||
|
docker build -t="coffeehouse_utils" -f Dockerfile .
|
||||||
|
|
||||||
|
docker_run:
|
||||||
|
docker run -it --name coffeehouse_utils -h coffeehouse_utils --restart always -p 5600:5600 -p 5601:5601 -p 5602:5602 -p 5603:5603 -p 5604:5604 -p 5606:5606 coffeehouse_utils
|
||||||
|
|
||||||
|
docker_run_no_expose:
|
||||||
|
docker run -it --name coffeehouse_utils -h coffeehouse_utils --restart always coffeehouse_utils
|
||||||
|
|
||||||
|
docker_rm:
|
||||||
docker rm -f coffeehouse_utils
|
docker rm -f coffeehouse_utils
|
|
@ -44,4 +44,5 @@ make start_translate # Starts the translation server, runs on port 5603
|
||||||
| CoffeeHouse NSFW Classifier | HTTP | 5602 |
|
| CoffeeHouse NSFW Classifier | HTTP | 5602 |
|
||||||
| CoffeeHouse Translate | HTTP | 5603 |
|
| CoffeeHouse Translate | HTTP | 5603 |
|
||||||
| CoffeeHouse CoreNLP | HTTP | 5604 |
|
| CoffeeHouse CoreNLP | HTTP | 5604 |
|
||||||
|
| CoffeeHouse Emotions | HTTP | 5605 |
|
||||||
| CoffeeHouse Language Detection | HTTP | 5606 |
|
| CoffeeHouse Language Detection | HTTP | 5606 |
|
|
@ -0,0 +1,3 @@
|
||||||
|
# CoffeeHouse Emotion
|
||||||
|
|
||||||
|
Library for detecting emotions :)
|
|
@ -0,0 +1,7 @@
|
||||||
|
from . import main
|
||||||
|
from .main import *
|
||||||
|
|
||||||
|
from . import server
|
||||||
|
from .server import *
|
||||||
|
|
||||||
|
__all__ = ["main", "SpamDetection", "Server"]
|
|
@ -0,0 +1,70 @@
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from .main import EmotionPrediction
|
||||||
|
from .server import Server
|
||||||
|
|
||||||
|
|
||||||
|
def _real_main(argv=None):
|
||||||
|
"""
|
||||||
|
The main command-line processor
|
||||||
|
|
||||||
|
:param argv:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
if argv[1] == '--help':
|
||||||
|
_help_menu(argv)
|
||||||
|
if argv[1] == '--test':
|
||||||
|
_test_model(argv)
|
||||||
|
if argv[1] == '--start-server':
|
||||||
|
_start_server(argv)
|
||||||
|
|
||||||
|
|
||||||
|
def _start_server(argv=None):
|
||||||
|
"""
|
||||||
|
Starts the server
|
||||||
|
|
||||||
|
:param argv:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
server = Server()
|
||||||
|
server.start()
|
||||||
|
|
||||||
|
|
||||||
|
def _help_menu(argv=None):
|
||||||
|
"""
|
||||||
|
Displays the help menu and commandline usage
|
||||||
|
|
||||||
|
:param argv:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
print(
|
||||||
|
"CoffeeHouse EmotionPrediction CLI\n\n"
|
||||||
|
" --help\n"
|
||||||
|
" --test\n"
|
||||||
|
" --start-server\n"
|
||||||
|
)
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
|
def _test_model(argv=None):
|
||||||
|
"""
|
||||||
|
Tests the model's prediction by allowing user input and displaying the
|
||||||
|
prediction output
|
||||||
|
|
||||||
|
:param argv:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
print("Loading")
|
||||||
|
emotion_prediction = EmotionPrediction()
|
||||||
|
print("Ready\n")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
input_text = input("> ")
|
||||||
|
print(emotion_prediction.predict(input_text))
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
try:
|
||||||
|
_real_main(sys.argv)
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print('\nInterrupted by user')
|
|
@ -0,0 +1,30 @@
|
||||||
|
import os
|
||||||
|
from resource_fetch import ResourceFetch
|
||||||
|
from coffeehouse_dltc.main import DLTC
|
||||||
|
|
||||||
|
__all__ = ['EmotionPrediction']
|
||||||
|
|
||||||
|
|
||||||
|
class EmotionPrediction(object):
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
"""
|
||||||
|
Public Constructor
|
||||||
|
"""
|
||||||
|
self.dltc = DLTC()
|
||||||
|
self.rf = ResourceFetch()
|
||||||
|
self.model_directory = os.path.join(
|
||||||
|
self.rf.fetch("Intellivoid", "CoffeeHouseData-ProfleIO"),
|
||||||
|
"advanced_sentiments_build"
|
||||||
|
)
|
||||||
|
self.dltc.load_model_cluster(self.model_directory)
|
||||||
|
|
||||||
|
def predict(self, text_input):
|
||||||
|
"""
|
||||||
|
Takes the user input and predicts if the input is either
|
||||||
|
spam or ham
|
||||||
|
|
||||||
|
:param text_input:
|
||||||
|
:return: Returns dictionary "neutral", "happiness", "affection", "sadness" and "anger" prediction values
|
||||||
|
"""
|
||||||
|
return self.dltc.predict_from_text(text_input)
|
|
@ -0,0 +1,58 @@
|
||||||
|
from hyper_internal_service import web
|
||||||
|
|
||||||
|
from .main import EmotionPrediction
|
||||||
|
|
||||||
|
__all__ = ['Server']
|
||||||
|
|
||||||
|
|
||||||
|
class Server(object):
|
||||||
|
|
||||||
|
def __init__(self, port=5605):
|
||||||
|
"""
|
||||||
|
Public Constructor
|
||||||
|
:param port:
|
||||||
|
"""
|
||||||
|
self.port = port
|
||||||
|
self.web_application = web.Application()
|
||||||
|
self.web_application.add_routes(
|
||||||
|
[web.post('/', self.predict)]
|
||||||
|
)
|
||||||
|
self.emotion_prediction = EmotionPrediction()
|
||||||
|
|
||||||
|
async def predict(self, request):
|
||||||
|
"""
|
||||||
|
Handles the predict request "/", usage:
|
||||||
|
POST:: "input": str
|
||||||
|
:param request:
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
post_data = await request.post()
|
||||||
|
results = self.emotion_prediction.predict(post_data['input'])
|
||||||
|
response = {
|
||||||
|
"status": True,
|
||||||
|
"results": {
|
||||||
|
"neutral": str(results['neutral']),
|
||||||
|
"happiness": str(results['happiness']),
|
||||||
|
"affection": str(results['affection']),
|
||||||
|
"sadness": str(results['sadness']),
|
||||||
|
"anger": str(results['anger'])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return web.json_response(response)
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
"""
|
||||||
|
Starts the web application
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
web.run_app(app=self.web_application, port=self.port)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def stop(self):
|
||||||
|
"""
|
||||||
|
Stops the web application
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
self.web_application.shutdown()
|
||||||
|
self.web_application.cleanup()
|
||||||
|
return True
|
|
@ -0,0 +1,31 @@
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
from setuptools.command.install import install
|
||||||
|
|
||||||
|
|
||||||
|
class PostInstallCommand(install):
|
||||||
|
"""Post-installation for installation mode."""
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
install.run(self)
|
||||||
|
from resource_fetch import ResourceFetch
|
||||||
|
rf = ResourceFetch()
|
||||||
|
|
||||||
|
# Update the model
|
||||||
|
rf.fetch("Intellivoid", "CoffeeHouseData-ProfileIO")
|
||||||
|
setup(
|
||||||
|
name='coffeehouse_emotions',
|
||||||
|
version='1.0.0',
|
||||||
|
description='Predicts input to probable emotions',
|
||||||
|
url='https://github.com/Intellivoid/CoffeeHousePy',
|
||||||
|
author='Zi Xing Narrakas',
|
||||||
|
author_email='netkas@intellivoid.info',
|
||||||
|
classifiers=[
|
||||||
|
'Development Status :: 3 - Internal/Alpha',
|
||||||
|
'Topic :: Text Processing',
|
||||||
|
'Programming Language :: Python :: 3',
|
||||||
|
],
|
||||||
|
cmdclass={
|
||||||
|
'install': PostInstallCommand,
|
||||||
|
},
|
||||||
|
packages=find_packages()
|
||||||
|
)
|
Loading…
Reference in New Issue