Currently, users express their wishes and preferences in relation to an object, content or event through social networks; therefore analyze the sentiments of a person in the digital world about what surrounds the person has been increasingly used in order to know the preferences of this person. The study proposes new metrics of sentiments and affection, improving the sentiment analysis. The sentiment analysis metric associated with a corresponding correction factor for n-grams, tenses, expressions and personal characteristics such as age, gender and education is developed in this work. Negative, neutral and positive sentiments are extracted from social networks phrases. The sentences are ranked in positive, neutral or negative sentiment intensity or polarity by a new dictionary of words in Portuguese language and is extracted the sentiments. The calculation of sentiments has specific rules for verb tenses (present and past) and adverbs. The sentiments are extracted by means of adjectives, nouns, unigrams and associated words (bigrams and trigrams) that have a different meaning of single words. To validate the dictionary performance and new sentiments calculation mechanisms, the results are compared with an analysis tool of sentiments named of SentiStrength and are validated by subjective tests, with remote evaluators, with a technique named of crowdsourcing and machine learning. The study also analyzes the affection of sentences and proposes a metric called Brazillian Affective Metric (AFM-Br), that extracts emotions of anger, joy, sadness, surprise and disgust. The sentiment analysis solution and affection is applied in a music recommendation system, as a case study, which suggests content according to the emotional state of the person.