Extract key phrases using Text Analytics Docker container

Introduction

Some of the Azure Cognitive Services are provided with Docker images. Try using Text Analytics keyphrase extraction according to Documentation.

Get container image

Text Analytics is in public preview as of December 2020, and anyone can try it.

docker pull mcr.microsoft.com/azure-cognitive-services/keyphrase

Ready to run

To run the Cognitive Service container, you need to be able to connect to Azure and send billing information. Therefore, first create a Text Analytics in Azure and get the endpoint and API key. image.png

Start container

Launch the container with Eula approval and Azure Text Analytics endpoint, API key.

docker run -it --rm -p 5000:5000 \
--mount type=bind,src=$HOME/output,target=/output \
mcr.microsoft.com/azure-cognitive-services/keyphrase:latest \
Eula=accept \
Billing=https://<your_app_name>.cognitiveservices.azure.com/ \
ApiKey=<your_api_key>

Running the Text Analytics API

You can see the swagger API specification by visiting http: //localhost: 5000/swagger/index.html. Execute it appropriately referring to the sample.

curl -X POST \
-H 'Content-Type: application/json' \
http://localhost:5000/text/analytics/v3.0/keyPhrases \
--data '{"documents":[{"language":"ja","id":"1","text":"Today is New Year's Eve, so I drink until I spit out beer."}]}'

result.

{
  "documents": [
    {
      "id": "1",
      "keyPhrases": [
        "Beer",
        "New Year's Eve",
        "Drink"
      ],
      "warnings": []
    }
  ],
  "errors": [],
  "modelVersion": "2019-10-01"
}

The keywords "beer," "New Year's Eve," and "drinking" were extracted from the phrase "Today is New Year's Eve, so I'll drink until I spit out beer."

in conclusion

I ran the Text Analytics container on localhost. The sentiment analysis API etc. can be executed in the same way. I think that it is effective in cases where data cannot be sent to the public cloud from the viewpoint of compliance, or when you want to process data close to the data in terms of performance.

reference

--Azure Cognitive Services Container --Docs --Text Analytics docker container configuration --Docs

Recommended Posts

Extract key phrases using Text Analytics Docker container
Quick build maven project using maven docker container
Build a Kotlin app using OpenJDK's Docker container
Send emails using Docker container on Raspberry Pi 3
Try using another Servlet container Jetty with Docker
Small Docker container
Run the Android emulator on Docker using Android Emulator Container Scripts
[Docker] Build an Apache container on EC2 using dockerfile