cleanup
This commit is contained in:
parent
5711e2b5f8
commit
2a36eaf00f
|
|
@ -1,17 +0,0 @@
|
||||||
FROM nginx:1.7
|
|
||||||
|
|
||||||
# Copy in conf files
|
|
||||||
COPY nginx.conf /etc/nginx/nginx.conf
|
|
||||||
COPY mime.types /etc/nginx/mime.types
|
|
||||||
COPY ssl.conf /etc/nginx/
|
|
||||||
COPY site.conf /etc/nginx/sites-enabled/
|
|
||||||
|
|
||||||
# COPY in certs
|
|
||||||
COPY ssl.crt /etc/nginx/ssl.crt
|
|
||||||
COPY ssl.key /etc/nginx/ssl.key
|
|
||||||
|
|
||||||
# Expose both the HTTP (80) and HTTPS (443) ports
|
|
||||||
EXPOSE 80 443
|
|
||||||
|
|
||||||
CMD ["nginx"]
|
|
||||||
|
|
||||||
|
|
@ -13,4 +13,5 @@ COPY ./ /app
|
||||||
RUN python /app/nltkDown.py
|
RUN python /app/nltkDown.py
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
EXPOSE 5000
|
EXPOSE 5000
|
||||||
|
|
||||||
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app"]
|
CMD ["gunicorn", "-b", "0.0.0.0:5000", "app"]
|
||||||
Binary file not shown.
|
|
@ -2,7 +2,6 @@ import logging
|
||||||
import os
|
import os
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from flask_ask import Ask, request, session, question, statement
|
from flask_ask import Ask, request, session, question, statement
|
||||||
import yaml
|
|
||||||
from nltk.corpus import treebank
|
from nltk.corpus import treebank
|
||||||
from textblob_de import TextBlobDE as TextBlob
|
from textblob_de import TextBlobDE as TextBlob
|
||||||
import siteobj as site2
|
import siteobj as site2
|
||||||
|
|
@ -69,13 +68,11 @@ def search_for(searchTerm):
|
||||||
else:
|
else:
|
||||||
return question("Dazu konnte nichts gefunden werden. Möchten Sie nach etwas anderem Suchen?")
|
return question("Dazu konnte nichts gefunden werden. Möchten Sie nach etwas anderem Suchen?")
|
||||||
|
|
||||||
|
return question(response + " noch etwas?")
|
||||||
return question(response + "noch etwas?")
|
|
||||||
|
|
||||||
@ask.intent('News', mapping={'site': 'Site'}, default={'site': ''})
|
@ask.intent('News', mapping={'site': 'Site'}, default={'site': ''})
|
||||||
def news(site):
|
def news(site):
|
||||||
session.attributes["siteName"] = site
|
session.attributes["siteName"] = site
|
||||||
#site = util.get_session_value(session.attributes, "siteName")
|
|
||||||
|
|
||||||
if site is not None:
|
if site is not None:
|
||||||
obj = get_site_obj(site)
|
obj = get_site_obj(site)
|
||||||
|
|
@ -106,11 +103,9 @@ def search_answer(number):
|
||||||
else:
|
else:
|
||||||
session.attributes["lastCall"] = "search_answer"
|
session.attributes["lastCall"] = "search_answer"
|
||||||
return question("Wonach wollen Sie suchen?")
|
return question("Wonach wollen Sie suchen?")
|
||||||
|
|
||||||
if obj is None: # should never be called
|
if obj is None: # should never be called
|
||||||
return question("Error. Wonach wollen Sie suchen?")
|
return question("Error. Wonach wollen Sie suchen?")
|
||||||
|
|
||||||
|
|
||||||
links = util.get_session_value(session.attributes, "lastSearch")
|
links = util.get_session_value(session.attributes, "lastSearch")
|
||||||
|
|
||||||
# if the site uses relative links, make absolute ones
|
# if the site uses relative links, make absolute ones
|
||||||
|
|
@ -122,9 +117,12 @@ def search_answer(number):
|
||||||
else:
|
else:
|
||||||
newLinks.append( link)
|
newLinks.append( link)
|
||||||
links = newLinks
|
links = newLinks
|
||||||
|
|
||||||
if int(number) > len(links):
|
if int(number) > len(links):
|
||||||
return question("Dieser Artikel existiert leider nicht, versuchen Sie eine andere Nummer.")
|
return question("Dieser Artikel existiert leider nicht, versuchen Sie eine andere Nummer.")
|
||||||
|
|
||||||
art = obj.read_headlines(links[int(number)-1])
|
art = obj.read_headlines(links[int(number)-1])
|
||||||
|
|
||||||
response = ""
|
response = ""
|
||||||
for element in art:
|
for element in art:
|
||||||
response += element
|
response += element
|
||||||
|
|
@ -132,7 +130,7 @@ def search_answer(number):
|
||||||
session.attributes["lastCall"] = "search2"
|
session.attributes["lastCall"] = "search2"
|
||||||
return question(response)
|
return question(response)
|
||||||
|
|
||||||
|
# https://github.com/markuskiller/textblob-de
|
||||||
@ask.intent('Senti', mapping={'number': 'Nummer'}, default={'number': 1})
|
@ask.intent('Senti', mapping={'number': 'Nummer'}, default={'number': 1})
|
||||||
def get_sentiment(number):
|
def get_sentiment(number):
|
||||||
site = util.get_session_value(session.attributes, "siteName")
|
site = util.get_session_value(session.attributes, "siteName")
|
||||||
|
|
@ -172,11 +170,16 @@ def get_sentiment(number):
|
||||||
sent = newText.sentiment[0]
|
sent = newText.sentiment[0]
|
||||||
|
|
||||||
if sent < 0:
|
if sent < 0:
|
||||||
good = "shit"
|
good = "eher negativ"
|
||||||
else:
|
else:
|
||||||
good = "nice"
|
good = "positiv"
|
||||||
|
|
||||||
return question(good)
|
return question("Das Sentiment ist " + good)
|
||||||
|
|
||||||
|
|
||||||
|
### ###
|
||||||
|
# DEFUALT #
|
||||||
|
### ###
|
||||||
|
|
||||||
@ask.intent('AMAZON.HelpIntent')
|
@ask.intent('AMAZON.HelpIntent')
|
||||||
def help():
|
def help():
|
||||||
|
|
@ -195,6 +198,10 @@ def launch():
|
||||||
def session_ended():
|
def session_ended():
|
||||||
return "{}", 200
|
return "{}", 200
|
||||||
|
|
||||||
|
### ###
|
||||||
|
# INIT #
|
||||||
|
### ###
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
if 'ASK_VERIFY_REQUESTS' in os.environ:
|
if 'ASK_VERIFY_REQUESTS' in os.environ:
|
||||||
|
|
@ -202,4 +209,4 @@ if __name__ == '__main__':
|
||||||
if verify == 'false':
|
if verify == 'false':
|
||||||
application.config['ASK_VERIFY_REQUESTS'] = False
|
application.config['ASK_VERIFY_REQUESTS'] = False
|
||||||
|
|
||||||
application.run(host='127.0.0.1',port=80)
|
application.run(host='0.0.0.0',port=80)
|
||||||
|
|
|
||||||
|
|
@ -1,36 +0,0 @@
|
||||||
# http://www.ulliwaltinger.de/sentiment/
|
|
||||||
# https://github.com/solariz/german_stopwords
|
|
||||||
#!/usr/bin/env python
|
|
||||||
# https://github.com/markuskiller/textblob-de
|
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
import nltk
|
|
||||||
import copy
|
|
||||||
import encodings
|
|
||||||
import csv
|
|
||||||
from siteobj import *
|
|
||||||
from nltk.corpus import treebank
|
|
||||||
from textblob_de import TextBlobDE as TextBlob
|
|
||||||
|
|
||||||
|
|
||||||
def get_sentiment(url):
|
|
||||||
NewsText = obj.read_article(url)
|
|
||||||
|
|
||||||
newText = ""
|
|
||||||
for text in NewsText:
|
|
||||||
newText += text
|
|
||||||
|
|
||||||
newText = TextBlob(newText)
|
|
||||||
|
|
||||||
sent = newText.sentiment[0]
|
|
||||||
if sent < 0:
|
|
||||||
good = "shit"
|
|
||||||
else:
|
|
||||||
good = "nice"
|
|
||||||
print(good, newText.sentiment,"\n", link.split("/")[-1], "\n")
|
|
||||||
return good
|
|
||||||
|
|
||||||
obj = Golem()
|
|
||||||
news, links = obj.get_news()
|
|
||||||
|
|
||||||
for link in links:
|
|
||||||
get_sentiment(link)
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
|
|
||||||
|
|
||||||
def check_session_for(sessionAttributes, key):
|
def check_session_for(sessionAttributes, key):
|
||||||
|
"""Returns True or False based on wether the variable exists"""
|
||||||
if key in sessionAttributes:
|
if key in sessionAttributes:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# returns value to key in session if set
|
|
||||||
# returns None if not
|
|
||||||
def session_value_is(sessionAttributes, key, value):
|
def session_value_is(sessionAttributes, key, value):
|
||||||
|
"""Returns True or False based on wether the variable has the expected Value"""
|
||||||
if key in sessionAttributes and sessionAttributes[key] == value:
|
if key in sessionAttributes and sessionAttributes[key] == value:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def get_session_value(sessionAttributes, key):
|
def get_session_value(sessionAttributes, key):
|
||||||
|
"""Returns the Value or None"""
|
||||||
if key in sessionAttributes:
|
if key in sessionAttributes:
|
||||||
return sessionAttributes[key]
|
return sessionAttributes[key]
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue