Azure AI Language – Key Phrase Extraction in Optimizely CMS

In this article, I demonstrate how the key phrase extraction feature, offered by the Azure AI Language service, can be used to generate a list of key phrases within Optimizely CMS as part of the content publishing process.

Key phrase extraction is a feature provided by Azure AI Language, a set of machine learning and AI algorithms in the cloud designed for creating intelligent applications involving written language. The feature can be used to quickly identify the main ideas in the text. It works best when used with larger amounts of text.

Key phrase extraction can be used in Optimizely CMS to identify the main keywords from content which can then be used for meta keywords on a webpage. This can help search engines to understand the topics associated with the webpages.

This feature can be implemented by downloading the “Patel.AzureAILanguage.Optimizely” NuGet package. You can get this package from the Optimizely NuGet Feed or the NuGet Feed.

Once the NuGet Package has been downloaded and required setup has been done, a boolean property with the [TextAnalyticsAllowed] attribute needs to be added to the Start Page in Optimizely to activate this functionality. This is detailed here TextAnalyticsAllowed Documentation.

After doing this, an IList<string> property, with the [KeyPhraseExtractionList] attribute also needs to be added. This can be added to any Optimizely CMS Content type that derives from IContent. More information can be found here KeyPhraseExtractionList Documentation. The purpose of this IList<string> property is to be populated with key phrases generated from the Azure AI Language API.

The final step consists of creating one or multiple string properties with a [KeyPhraseExtraction] attribute. This needs to be added to the same content type, the IList<string> property with a [KeyPhraseExtractionList] attribute was added to. Additional details are available via the following link: KeyPhraseExtraction Documentation.

After adding these properties, the key phrase extraction feature can be performed when publishing content in the CMS.

There is a screenshot below which demonstrates the code used to generate the list of Key Phrases from the Azure AI Language API

Response from the API via the Console

Key Phrase Extraction operation of text field has completed
Number of Key Phrases detected is: 20
Key Phrase: London commuter belt
Key Phrase: 561-year-old gatehouse
Key Phrase: castellated roof
Key Phrase: flag pole
Key Phrase: Penny Rainbow
Key Phrase: Henry VIII
Key Phrase: Edward VI
Key Phrase: Elizabeth I
Key Phrase: 19th century
Key Phrase: Wayneflete Tower
Key Phrase: four-storey property
Key Phrase: people
Key Phrase: owner
Key Phrase: guardian
Key Phrase: Esher
Key Phrase: Surrey
Key Phrase: 31 years
Key Phrase: monarchs
Key Phrase: remnant
Key Phrase: Palace

After publishing the content, the key phrase extraction operation has been carried out which has generated 20 key phrases. These key phrases have been populated in the IList<string> property with the attribute [KeyPhraseExtractionList], as mentioned earlier in the article. The resulting list is provided below.