Esempio n. 1
0
        public IHttpActionResult PostsBySubject([FromUri] int SubjectId)
        {
            var Posts = PostAuxiliar.PostsBySubject(SubjectId);

            Posts = PostAuxiliar.UpdateOwner(Posts, SQLContext);

            return(Ok(Posts));
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> OpinionOnSubject([FromUri] int SubjectId)
        {
            var Subject      = SQLContext.Subjects.Find(SubjectId);
            var SubjectPosts = PostAuxiliar.PostsBySubject(SubjectId);

            double Opinion = 0;

            foreach (var Post in SubjectPosts)
            {
                var Response = await MakeRequest(Post.Text.Replace("#", "")).ConfigureAwait(false);

                var Analysis = (Response as JArray).ToObject <List <SentimentalAnalysis> >();

                Opinion += CalculateMeanScore(new List <string>()
                {
                    Subject.Hashtag.Replace("#", "")
                }, Analysis);
            }

            return(Ok(new { Topic = Subject.Hashtag, Score = Opinion, Opinion = ScoreTranslator(Opinion) }));
        }