Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
We'll add serialization logic and make our request to the Text Analytics API.
Parsing the Sentiment Score to a Double
If you're not located in the United States, you might need to call an overload of the double.TryParse
method that allows you to pass in the "en-US" culture info in order to successfully parse the string value.
double score;
if (double.TryParse(sentiment.Score, NumberStyles.Any,
CultureInfo.GetCultureInfo("en-US"), out score))
{
newsResult.SentimentScore = score;
}
For more information about how to get and set your current culture in .NET, see the MSDN documentation page for the CultureInfo.CurrentCulture
property.
Formatting Numbers
Standard Numeric Format Strings
Project Ideas
- Build an app that integrates with data from a public API.
- Check out this list of public APIs and find something you're interested in!
- Use other API services from Microsoft Cognitive Services
- Download CSV or JSON datasets from Data.gov and load it into your application
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up