Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Yesterday we introduced you to U-SQL Advanced Analytics and showed how Python can be used with U-SQL. Today, we'll show U-SQL's built-in support for Cognitive scenarios for images and text.
Currently U-SQL Supports these cognitive scenarios:
Over time, we'll add more support and enhance the integration in many ways.
Here's an example of how U-SQL can be used to detect objects in images:
REFERENCE ASSEMBLY ImageCommon;
REFERENCE ASSEMBLY FaceSdk;
REFERENCE ASSEMBLY ImageEmotion;
REFERENCE ASSEMBLY ImageTagging;
REFERENCE ASSEMBLY ImageOcr;
@imgs =
EXTRACT FileName string, ImgData byte[]
FROM @"/images/{FileName}.jpg"
USING new Cognition.Vision.ImageExtractor();
// Extract the number of objects on each image and tag them
@objects =
PROCESS @imgs
PRODUCE FileName,
NumObjects int,
Tags string
READONLY FileName
USING new Cognition.Vision.ImageTagger();
OUTPUT @objects
TO "/objects.tsv"
USING Outputters.Tsv();
In this sample the Cognition.Vision.ImageTagger() processor is used to detect objects and place a text description of them in the Tags column.
Here's an example of how U-SQL can be used to understand text:
REFERENCE ASSEMBLY [TextCommon];
REFERENCE ASSEMBLY [TextSentiment];
REFERENCE ASSEMBLY [TextKeyPhrase];
@WarAndPeace =
EXTRACT No int,
Year string,
Book string,
Chapter string,
Text string
FROM @"/usqlext/samples/cognition/war_and_peace.csv"
USING Extractors.Csv();
@sentiment =
PROCESS @WarAndPeace
PRODUCE No,
Year,
Book,
Chapter,
Text,
Sentiment string,
Conf double
READONLY No,
Year,
Book,
Chapter,
Text
USING new Cognition.Text.SentimentAnalyzer(true);
OUTPUT @sentiment
TO "/sentiment.tsv"
USING Outputters.Tsv();
In this sample the Cognition.Text.SentimentAnalyzer() processor is used to detect objects and place a text description of them in the Sentiment column.
To learn more about our support for U-SQL Advanced Analytics and how to enable it in your Data Lake Analytics Accounts, see our Getting Started guide .
Please sign in to use this experience.
Sign in