Skip to content
Snippets Groups Projects
Commit 2e9e88b3 authored by Alex Ellis's avatar Alex Ellis
Browse files

New function

parent 274bf319
No related branches found
No related tags found
No related merge requests found
FROM python:2.7-alpine
RUN pip install textblob
RUN python -m textblob.download_corpora
ADD https://github.com/alexellis/faas/releases/download/0.5.1-alpha/fwatchdog /usr/bin
RUN chmod +x /usr/bin/fwatchdog
WORKDIR /root/
COPY handler.py .
ENV fprocess="python handler.py"
HEALTHCHECK --interval=1s CMD [ -e /tmp/.lock ] || exit 1
CMD ["fwatchdog"]
#!/bin/sh
echo "Building functions/sentimentanalysis"
docker build -t functions/sentimentanalysis .
import sys
from textblob import TextBlob
def get_stdin():
buf = ""
for line in sys.stdin:
buf = buf + line
return buf
if(__name__ == "__main__"):
st = get_stdin()
blob = TextBlob(st)
out =""
for sentence in blob.sentences:
out = out + "Polarity: " + str(sentence.sentiment.polarity) + " Subjectivity: " + str(sentence.sentiment.subjectivity) + "\n"
print(out)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment