Merge branch '45-service-reporting-update-net-preview-to-stable-version' into 'master'
authorJan Vales (Someone) <jan.vales@tuwien.ac.at>
Wed, 16 Jan 2019 23:42:32 +0000 (00:42 +0100)
committerJan Vales (Someone) <jan.vales@tuwien.ac.at>
Wed, 16 Jan 2019 23:42:32 +0000 (00:42 +0100)
Resolve "service reporting - update .net preview to stable version"

Closes #45

See merge request aic18/G6T4!38

service-analysis/README.md
service-reporting/Models/Term.cs
service-reporting/README.md
service-twitter/README.md

index a4d4cc4e353fb4f1c5096c55508c5167e4c4d627..aa0e4c0772c79291ce555724e6d964b9738404eb 100644 (file)
@@ -39,6 +39,9 @@ JSON string may contain more value-key pairs than 'text', but 'text' is needed f
 - pip
   -> indicoio
   -> flask
-  -> flask_restfut
+  -> flask_restful
+
 ### commands
 - `python3.7 sentiment_analysis.py`
+- positive sentiment test example: `curl -vs -H 'content-type: application/json' -X POST http://localhost:8081 -d '[{"text":"happy birthday, i love you"}]'`
+- negative sentiment test example: `curl -vs -H 'content-type: application/json' -X POST http://localhost:8081 -d '[{"text":"i hate you, please die"}]'`
index bb6289036aa49bfa77c966bd8bc63d8120de2461..a2c4c8d5b907b3968023b71162eb8452a180f750 100644 (file)
@@ -1,4 +1,4 @@
-
+using System.ComponentModel.DataAnnotations;
 namespace PdfService.Models
 {
     // represents the data got from sentiment analysis.
@@ -9,7 +9,10 @@ namespace PdfService.Models
             this.Name = Name;
             this.Sentiment = Sentiment;
         }
+        [Required]
         public string Name { get; set; }
+        [Range(0.0,1.0)]
+        [Required]
         public double Sentiment { get; set; }
     }
 }
\ No newline at end of file
index 49640ff5533c2410012dd38bf6f42f4d2a7463fc..cc0a95af51f9c75a74a886936479064816d3f0f4 100644 (file)
@@ -41,4 +41,10 @@ Term(string `Name`, double `Sentiment`)
 - .net core 2.2
 - download [libwkhtml library](https://github.com/rdvojmoc/DinkToPdf/tree/master/v0.12.4) depending on your operating system and put it into `service-reporting` root folder
 ### commands
-- `dotnet run`
\ No newline at end of file
+- `dotnet run`
+
+## Tests
+- successfull pdf as application/json: `curl -X POST  http://localhost:8083/generatePDF  -H 'Content-Type: application/json'  -d '[ { "name": "A bad term", "sentiment": 0.1 }, { "name": "Another bad term", "sentiment": 0.3 }, { "name": "A neutral term", "sentiment": 0.5 }, { "name": "A good term", "sentiment": 0.65 }, { "name": "Another good term", "sentiment": 0.9 } ] ' -vs > test1.pdf`
+- successfull pdf as application/base64: `curl -X POST http://localhost:8083/generatePDF -H 'Accept: application/base64' -H 'Content-Type: application/json' -d '[ { "name": "A bad term", "sentiment": 0.1 }, { "name": "Another bad term", "sentiment": 0.3 }, { "name": "A neutral term", "sentiment": 0.5 }, { "name": "A good term", "sentiment": 0.65 }, { "name": "Another good term", "sentiment": 0.9 } ] ' -vs | base64 -d > test2.pdf`
+- invalid sentiment value: `curl -X POST http://localhost:8083/generatePDF -H 'Content-Type: application/json' -d '[ { "name": "Term with invalid sentiment value", "sentiment": 12 } ] ' -vs && echo`
+- invalid json structure: `curl -X POST http://localhost:8083/generatePDF -H 'Content-Type: application/json' -d '[ { "name1": "A term with invalid json format", "sentiment": 0.5 } ] ' -vs && echo`
\ No newline at end of file
index a2f641be631efbb33897bf85a1fc2d3e8075bfc2..79630d0cfc7c5f3905d53be74da11ca4e624addf 100644 (file)
@@ -1,15 +1,24 @@
 # Twitter Service
 
 
+
 ## API
 
-You can use the search under: [http://localhost:8084/search/tweets.json?q=Google](http://localhost:8080/search/tweets.json?q=Google)
+You can use the search under [http://localhost:8084/search/tweets.json?q=Google](http://localhost:8080/search/tweets.json?q=Google)
 where `q` is your search string.
 
 It mainly mirrors the search API from Twitter. My implementation contains some basic fields with the same names as in
 the official API. If you need more, please let me know.
 
 
+### Example
+
+`curl -vs http://localhost:8084/search/tweets.json?q=Google `
+
+Pipe it into e.g. `jq` for a more readable output.
+
+
+
 ## API Keys
 
 Unfortunately you have to provide your own API Keys, as sharing them is forbidden. In the worst case there would be five