Exemplo n.º 1
0
    def test_categorize_msgs(self):
        """Test msgs categorization"""

        textblob_obj = TextBlob("Great")
        analyzed_msgs = sentiment_analysis.categorize_messages([textblob_obj])

        self.assertEqual(analyzed_msgs, [1, 0, 0])
    def test_categorize_msgs(self):
        """Test msgs categorization"""

        textblob_obj = TextBlob('Great')
        analyzed_msgs = sentiment_analysis.categorize_messages([textblob_obj])

        self.assertEqual(analyzed_msgs, [1, 0, 0])
Exemplo n.º 3
0
def messages_types_data(user_id):
    """Return data about messages emotions."""

    if 'user_id' not in session:
        return redirect("/")
    elif session['user_id'] != user_id:
        return redirect("/users/%s" % session['user_id'])

    messages = sentiment_analysis.get_messages(user_id) 

    sentiment_list = sentiment_analysis.analyze_messages(messages)

    arranged_list = sentiment_analysis.categorize_messages(sentiment_list)

    data_list_of_dicts = {
        'arranged_list': [
            {
                "value": arranged_list[0],
                "color": "#F7464A",
                "highlight": "#FF5A5E",
                "label": "Positive messages"
            },
            {
                "value": arranged_list[1],
                "color": "#46BFBD",
                "highlight": "#5AD3D1",
                "label": "Negative messages"
            },
            {
                "value": arranged_list[2],
                "color": "#FDB45C",
                "highlight": "#FFC870",
                "label": "Neutral messages"
            }
        ]
    }
    return jsonify(data_list_of_dicts)