faas/sample-functions/SentimentAnalysis
Alex Ellis (OpenFaaS Ltd) b45e2a52a4 Bump alpine to 3.11
There's a new release which appears to have no apparent down-
sides or breakages.

https://www.alpinelinux.org/posts/Alpine-3.11.2-released.html

Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
2019-12-27 10:08:02 +00:00
..
2019-12-27 10:08:02 +00:00
2019-12-27 10:08:02 +00:00
2018-07-10 21:07:36 +01:00
2018-02-23 08:23:29 +00:00

SentimentAnalysis

Python function provides a rating on sentiment positive/negative (polarity -1.0-1.0) and subjectivity to provided to each of the sentences sent in via the TextBlob project.

Example:

Run in the function:

# curl -s http://localhost:8080/system/functions --data-binary \
'{ 
   "service": "sentimentanalysis",
   "image": "functions/sentimentanalysis",
   "envProcess": "python ./handler.py",
   "network": "func_functions"
   }'

Now test the function:

# curl http://localhost:8080/function/sentimentanalysis -d "Personally I like functions to do one thing and only one thing well, it makes them more readable."
Polarity: 0.166666666667 Subjectivity: 0.6

# curl http://localhost:8080/function/sentimentanalysis -d "Functions are great and proven to be awesome"
Polarity: 0.9 Subjectivity: 0.875

# curl http://localhost:8080/function/sentimentanalysis -d "The hotel was clean, but the area was terrible"; echo
Polarity: -0.316666666667 Subjectivity: 0.85