빠른 시작: 클라이언트 라이브러리 및 REST API를 사용한 엔터티 링크 설정

참조 설명서 | 추가 샘플 | 패키지(NuGet) | 라이브러리 소스 코드

이 빠른 시작을 사용하여 .NET용 클라이언트 라이브러리와 애플리케이션을 연결하는 엔터티를 만듭니다. 다음 예제에서는 텍스트에서 찾은 엔터티를 식별하고 명확하게 할 수 있는 C# 애플리케이션을 만듭니다.

Language Studio를 사용하여 코드를 작성하지 않고도 Language Service 기능을 사용해 볼 수 있습니다.

필수 조건

  • Azure 구독 - 무료로 만들기
  • Visual Studio IDE
  • Azure 구독 이 있으면 Azure Portal에서 언어 리소스 를 만들어 키와 엔드포인트를 가져옵니다. 배포한 후 리소스로 이동을 선택합니다.
    • 애플리케이션을 API에 연결하려면 만든 리소스의 키와 엔드포인트가 필요합니다. 빠른 시작의 뒷부분에서 아래 코드에 키와 엔드포인트를 붙여넣습니다.
    • 무료 가격 책정 계층(Free F0)을 사용하여 서비스를 사용해 볼 수 있으며 나중에 프로덕션용 유료 계층으로 업그레이드할 수 있습니다.
  • 분석 기능을 사용하려면 표준(S) 가격 책정 계층을 사용하는 언어 리소스가 필요합니다.

설정

새 .NET Core 애플리케이션 만들기

Visual Studio IDE를 사용하여 새 .NET Core 콘솔 앱을 만듭니다. 이렇게 하면 program.cs라는 단일 C# 원본 파일이 포함된 "Hello World" 프로젝트가 생성됩니다.

솔루션 탐색기에서 솔루션을 마우스 오른쪽 단추로 클릭하고 NuGet 패키지 관리를 선택하여 클라이언트 라이브러리를 설치합니다. 열리는 패키지 관리자에서 찾아보기를 선택하고 Azure.AI.TextAnalytics를 검색합니다. 버전을 5.2.0선택한 다음 설치합니다. 패키지 관리자 콘솔사용할 수도 있습니다.

코드 예

program.cs 파일에 다음 코드를 복사합니다. key 변수를 리소스의 키로 바꾸고 endpoint 변수를 리소스의 엔드포인트로 바꾸어야 합니다. 그런 다음 코드를 실행합니다.

Important

Azure Portal로 이동합니다. 필수 구성 요소 섹션에서 만든 언어 리소스가 성공적으로 배포된 경우 다음 단계 아래에서 리소스로 이동 단추를 클릭합니다. 리소스 관리에서 리소스의 키 및 엔드포인트 페이지로 이동하여 키와 엔드포인트를 찾을 수 있습니다.

Important

완료되면 코드에서 키를 제거하고 공개적으로 게시하지 마세요. 프로덕션의 경우 Azure Key Vault와 같은 자격 증명을 안전하게 저장하고 액세스하는 방법을 사용합니다. 자세한 내용은 Azure AI 서비스 보안 문서를 참조하세요.

using Azure;
using System;
using System.Globalization;
using Azure.AI.TextAnalytics;

namespace EntityLinkingExample
{
    class Program
    {
        private static readonly Uri endpoint = new Uri("replace-with-your-endpoint-here");
        private static readonly AzureKeyCredential credentials = new AzureKeyCredential("replace-with-your-key-here");
        
        // Example method for recognizing entities and providing a link to an online data source.
        static void EntityLinkingExample(TextAnalyticsClient client)
        {
            var response = client.RecognizeLinkedEntities(
                "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975, " +
                "to develop and sell BASIC interpreters for the Altair 8800. " +
                "During his career at Microsoft, Gates held the positions of chairman, " +
                "chief executive officer, president and chief software architect, " +
                "while also being the largest individual shareholder until May 2014.");
            Console.WriteLine("Linked Entities:");
            foreach (var entity in response.Value)
            {
                Console.WriteLine($"\tName: {entity.Name},\tID: {entity.DataSourceEntityId},\tURL: {entity.Url}\tData Source: {entity.DataSource}");
                Console.WriteLine("\tMatches:");
                foreach (var match in entity.Matches)
                {
                    Console.WriteLine($"\t\tText: {match.Text}");
                    Console.WriteLine($"\t\tScore: {match.ConfidenceScore:F2}\n");
                }
            }
        }

        static void Main(string[] args)
        {
            var client = new TextAnalyticsClient(endpoint, credentials);
            EntityLinkingExample(client);

            Console.Write("Press any key to exit.");
            Console.ReadKey();
        }

    }
}

출력

Linked Entities:
    Name: Microsoft,        ID: Microsoft,  URL: https://en.wikipedia.org/wiki/Microsoft    Data Source: Wikipedia
    Matches:
            Text: Microsoft
            Score: 0.55

            Text: Microsoft
            Score: 0.55

    Name: Bill Gates,       ID: Bill Gates, URL: https://en.wikipedia.org/wiki/Bill_Gates   Data Source: Wikipedia
    Matches:
            Text: Bill Gates
            Score: 0.63

            Text: Gates
            Score: 0.63

    Name: Paul Allen,       ID: Paul Allen, URL: https://en.wikipedia.org/wiki/Paul_Allen   Data Source: Wikipedia
    Matches:
            Text: Paul Allen
            Score: 0.60

    Name: April 4,  ID: April 4,    URL: https://en.wikipedia.org/wiki/April_4      Data Source: Wikipedia
    Matches:
            Text: April 4
            Score: 0.32

    Name: BASIC,    ID: BASIC,      URL: https://en.wikipedia.org/wiki/BASIC        Data Source: Wikipedia
    Matches:
            Text: BASIC
            Score: 0.33

    Name: Altair 8800,      ID: Altair 8800,        URL: https://en.wikipedia.org/wiki/Altair_8800  Data Source: Wikipedia
    Matches:
            Text: Altair 8800
            Score: 0.88

리소스 정리

Azure AI 서비스 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제할 수 있습니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다.

다음 단계

참조 설명서 | 추가 샘플 | 패키지(Maven) | 라이브러리 소스 코드

이 빠른 시작을 사용하여 Java용 클라이언트 라이브러리와 애플리케이션을 연결하는 엔터티를 만듭니다. 다음 예제에서는 텍스트에서 찾은 엔터티를 식별하고 명확하게 할 수 있는 Java 애플리케이션을 만듭니다.

Language Studio를 사용하여 코드를 작성하지 않고도 Language Service 기능을 사용해 볼 수 있습니다.

필수 조건

  • Azure 구독 - 무료로 만들기
  • 버전 8 이상이 있는 JDK(Java Development Kit )
  • Azure 구독 이 있으면 Azure Portal에서 언어 리소스 를 만들어 키와 엔드포인트를 가져옵니다. 배포한 후 리소스로 이동을 선택합니다.
    • 애플리케이션을 API에 연결하려면 만든 리소스의 키와 엔드포인트가 필요합니다. 빠른 시작의 뒷부분에서 아래 코드에 키와 엔드포인트를 붙여넣습니다.
    • 무료 가격 책정 계층(Free F0)을 사용하여 서비스를 사용해 볼 수 있으며 나중에 프로덕션용 유료 계층으로 업그레이드할 수 있습니다.
  • 분석 기능을 사용하려면 표준(S) 가격 책정 계층을 사용하는 언어 리소스가 필요합니다.

설정

클라이언트 라이브러리 추가

선호하는 IDE 또는 개발 환경에서 Maven 프로젝트를 만듭니다. 그런 다음, 프로젝트의 pom.xml 파일에 다음 종속성을 추가합니다. 다른 빌드 도구에 대한 구현 구문을 온라인으로 찾을 수 있습니다.

<dependencies>
     <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-ai-textanalytics</artifactId>
        <version>5.2.0</version>
    </dependency>
</dependencies>

코드 예

라는 Java 파일을 만듭니다 Example.java. 파일을 열고 아래 코드를 복사합니다. key 변수를 리소스의 키로 바꾸고 endpoint 변수를 리소스의 엔드포인트로 바꾸어야 합니다. 그런 다음 코드를 실행합니다.

Important

Azure Portal로 이동합니다. 필수 구성 요소 섹션에서 만든 언어 리소스가 성공적으로 배포된 경우 다음 단계 아래에서 리소스로 이동 단추를 클릭합니다. 리소스 관리에서 리소스의 키 및 엔드포인트 페이지로 이동하여 키와 엔드포인트를 찾을 수 있습니다.

Important

완료되면 코드에서 키를 제거하고 공개적으로 게시하지 마세요. 프로덕션의 경우 Azure Key Vault와 같은 자격 증명을 안전하게 저장하고 액세스하는 방법을 사용합니다. 자세한 내용은 Azure AI 서비스 보안 문서를 참조하세요.

import com.azure.core.credential.AzureKeyCredential;
import com.azure.ai.textanalytics.models.*;
import com.azure.ai.textanalytics.TextAnalyticsClientBuilder;
import com.azure.ai.textanalytics.TextAnalyticsClient;

public class Example {

    private static String KEY = "replace-with-your-key-here";
    private static String ENDPOINT = "replace-with-your-endpoint-here";

    public static void main(String[] args) {
        TextAnalyticsClient client = authenticateClient(KEY, ENDPOINT);
        recognizeLinkedEntitiesExample(client);
    }
    // Method to authenticate the client object with your key and endpoint
    static TextAnalyticsClient authenticateClient(String key, String endpoint) {
        return new TextAnalyticsClientBuilder()
                .credential(new AzureKeyCredential(key))
                .endpoint(endpoint)
                .buildClient();
    }
    // Example method for recognizing entities and providing a link to an online data source
    static void recognizeLinkedEntitiesExample(TextAnalyticsClient client)
    {
        // The text that need be analyzed.
        String text = "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975, " +
                "to develop and sell BASIC interpreters for the Altair 8800. " +
                "During his career at Microsoft, Gates held the positions of chairman, " +
                "chief executive officer, president and chief software architect, " +
                "while also being the largest individual shareholder until May 2014.";

        System.out.printf("Linked Entities:%n");
        for (LinkedEntity linkedEntity : client.recognizeLinkedEntities(text)) {
            System.out.printf("Name: %s, ID: %s, URL: %s, Data Source: %s.%n",
                    linkedEntity.getName(),
                    linkedEntity.getDataSourceEntityId(),
                    linkedEntity.getUrl(),
                    linkedEntity.getDataSource());
            System.out.printf("Matches:%n");
            for (LinkedEntityMatch linkedEntityMatch : linkedEntity.getMatches()) {
                System.out.printf("Text: %s, Score: %.2f, Offset: %s, Length: %s%n",
                        linkedEntityMatch.getText(),
                        linkedEntityMatch.getConfidenceScore(),
                        linkedEntityMatch.getOffset(),
                        linkedEntityMatch.getLength());
            }
        }
    }
}

출력

Linked Entities:

Name: Microsoft, ID: Microsoft, URL: https://en.wikipedia.org/wiki/Microsoft, Data Source: Wikipedia.
Matches:
Text: Microsoft, Score: 0.55, Offset: 0, Length: 9
Text: Microsoft, Score: 0.55, Offset: 150, Length: 9
Name: Bill Gates, ID: Bill Gates, URL: https://en.wikipedia.org/wiki/Bill_Gates, Data Source: Wikipedia.
Matches:
Text: Bill Gates, Score: 0.63, Offset: 25, Length: 10
Text: Gates, Score: 0.63, Offset: 161, Length: 5
Name: Paul Allen, ID: Paul Allen, URL: https://en.wikipedia.org/wiki/Paul_Allen, Data Source: Wikipedia.
Matches:
Text: Paul Allen, Score: 0.60, Offset: 40, Length: 10
Name: April 4, ID: April 4, URL: https://en.wikipedia.org/wiki/April_4, Data Source: Wikipedia.
Matches:
Text: April 4, Score: 0.32, Offset: 54, Length: 7
Name: BASIC, ID: BASIC, URL: https://en.wikipedia.org/wiki/BASIC, Data Source: Wikipedia.
Matches:
Text: BASIC, Score: 0.33, Offset: 89, Length: 5
Name: Altair 8800, ID: Altair 8800, URL: https://en.wikipedia.org/wiki/Altair_8800, Data Source: Wikipedia.
Matches:
Text: Altair 8800, Score: 0.88, Offset: 116, Length: 11

리소스 정리

Azure AI 서비스 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제할 수 있습니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다.

다음 단계

참조 설명서 | 추가 샘플 | 패키지(npm) | 라이브러리 소스 코드

이 빠른 시작을 사용하여 Node.js용 클라이언트 라이브러리와 애플리케이션을 연결하는 엔터티를 만듭니다. 다음 예제에서는 텍스트에서 찾은 엔터티를 식별하고 명확하게 할 수 있는 JavaScript 애플리케이션을 만듭니다.

Language Studio를 사용하여 코드를 작성하지 않고도 Language Service 기능을 사용해 볼 수 있습니다.

필수 조건

  • Azure 구독 - 무료로 만들기
  • Node.js v14 LTS 이상
  • Azure 구독 이 있으면 Azure Portal에서 언어 리소스 를 만들어 키와 엔드포인트를 가져옵니다. 배포한 후 리소스로 이동을 선택합니다.
    • 애플리케이션을 API에 연결하려면 만든 리소스의 키와 엔드포인트가 필요합니다. 빠른 시작의 뒷부분에서 아래 코드에 키와 엔드포인트를 붙여넣습니다.
    • 무료 가격 책정 계층(Free F0)을 사용하여 서비스를 사용해 볼 수 있으며 나중에 프로덕션용 유료 계층으로 업그레이드할 수 있습니다.
  • 분석 기능을 사용하려면 표준(S) 가격 책정 계층을 사용하는 언어 리소스가 필요합니다.

설정

새 Node.js 애플리케이션 만들기

콘솔 창(예: cmd, PowerShell 또는 Bash)에서 앱에 대한 새 디렉터리를 만들고 해당 디렉터리로 이동합니다.

mkdir myapp 

cd myapp

package.json 파일을 사용하여 노드 애플리케이션을 만들려면 npm init 명령을 실행합니다.

npm init

클라이언트 라이브러리 설치

npm 패키지를 설치합니다.

npm install @azure/ai-language-text

코드 예

파일을 열고 아래 코드를 복사합니다. key 변수를 리소스의 키로 바꾸고 endpoint 변수를 리소스의 엔드포인트로 바꾸어야 합니다. 그런 다음 코드를 실행합니다.

Important

Azure Portal로 이동합니다. 필수 구성 요소 섹션에서 만든 언어 리소스가 성공적으로 배포된 경우 다음 단계 아래에서 리소스로 이동 단추를 클릭합니다. 리소스 관리에서 리소스의 키 및 엔드포인트 페이지로 이동하여 키와 엔드포인트를 찾을 수 있습니다.

Important

완료되면 코드에서 키를 제거하고 공개적으로 게시하지 마세요. 프로덕션의 경우 Azure Key Vault와 같은 자격 증명을 안전하게 저장하고 액세스하는 방법을 사용합니다. 자세한 내용은 Azure AI 서비스 보안 문서를 참조하세요.

"use strict";

const { TextAnalysisClient, AzureKeyCredential } = require("@azure/ai-language-text");
const endpoint = '<paste-your-endpoint-here>';
const key = '<paste-your-key-here>';
//example sentence for recognizing entities
const documents = ["Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975."];

//example of how to use the client to perform entity linking on a document
async function main() {
    console.log("== Entity linking sample ==");
  
    const client = new TextAnalysisClient(endpoint, new AzureKeyCredential(key));
  
    const results = await client.analyze("EntityLinking", documents);
  
    for (const result of results) {
      console.log(`- Document ${result.id}`);
      if (!result.error) {
        console.log("\tEntities:");
        for (const entity of result.entities) {
          console.log(
            `\t- Entity ${entity.name}; link ${entity.url}; datasource: ${entity.dataSource}`
          );
          console.log("\t\tMatches:");
          for (const match of entity.matches) {
            console.log(
              `\t\t- Entity appears as "${match.text}" (confidence: ${match.confidenceScore}`
            );
          }
        }
      } else {
        console.error("  Error:", result.error);
      }
    }
  }

//call the main function
main().catch((err) => {
  console.error("The sample encountered an error:", err);
});

출력

== Entity linking sample ==
- Document 0
    Entities:
    - Entity Microsoft; link https://en.wikipedia.org/wiki/Microsoft; datasource: Wikipedia
            Matches:
            - Entity appears as "Microsoft" (confidence: 0.48
    - Entity Bill Gates; link https://en.wikipedia.org/wiki/Bill_Gates; datasource: Wikipedia
            Matches:
            - Entity appears as "Bill Gates" (confidence: 0.52
    - Entity Paul Allen; link https://en.wikipedia.org/wiki/Paul_Allen; datasource: Wikipedia
            Matches:
            - Entity appears as "Paul Allen" (confidence: 0.54
    - Entity April 4; link https://en.wikipedia.org/wiki/April_4; datasource: Wikipedia
            Matches:
            - Entity appears as "April 4" (confidence: 0.38

리소스 정리

Azure AI 서비스 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제할 수 있습니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다.

다음 단계

참조 설명서 | 추가 샘플 | 패키지(PyPi) | 라이브러리 소스 코드

이 빠른 시작을 사용하여 Python용 클라이언트 라이브러리와 애플리케이션을 연결하는 엔터티를 만듭니다. 다음 예제에서는 텍스트에서 찾은 엔터티를 식별하고 명확하게 할 수 있는 Python 애플리케이션을 만듭니다.

Language Studio를 사용하여 코드를 작성하지 않고도 Language Service 기능을 사용해 볼 수 있습니다.

필수 조건

  • Azure 구독 - 무료로 만들기
  • Python 3.7 이상
  • Azure 구독 이 있으면 Azure Portal에서 언어 리소스 를 만들어 키와 엔드포인트를 가져옵니다. 배포한 후 리소스로 이동을 선택합니다.
    • 애플리케이션을 API에 연결하려면 만든 리소스의 키와 엔드포인트가 필요합니다. 빠른 시작의 뒷부분에서 아래 코드에 키와 엔드포인트를 붙여넣습니다.
    • 무료 가격 책정 계층(Free F0)을 사용하여 서비스를 사용해 볼 수 있으며 나중에 프로덕션용 유료 계층으로 업그레이드할 수 있습니다.
  • 분석 기능을 사용하려면 표준(S) 가격 책정 계층을 사용하는 언어 리소스가 필요합니다.

설정

클라이언트 라이브러리 설치

Python을 설치한 후, 다음을 사용하여 클라이언트 라이브러리를 설치할 수 있습니다.

pip install azure-ai-textanalytics==5.2.0

코드 예

새 Python 파일을 만들고 아래 코드를 복사합니다. key 변수를 리소스의 키로 바꾸고 endpoint 변수를 리소스의 엔드포인트로 바꾸어야 합니다. 그런 다음 코드를 실행합니다.

Important

Azure Portal로 이동합니다. 필수 구성 요소 섹션에서 만든 언어 리소스가 성공적으로 배포된 경우 다음 단계 아래에서 리소스로 이동 단추를 클릭합니다. 리소스 관리에서 리소스의 키 및 엔드포인트 페이지로 이동하여 키와 엔드포인트를 찾을 수 있습니다.

Important

완료되면 코드에서 키를 제거하고 공개적으로 게시하지 마세요. 프로덕션의 경우 Azure Key Vault와 같은 자격 증명을 안전하게 저장하고 액세스하는 방법을 사용합니다. 자세한 내용은 Azure AI 서비스 보안 문서를 참조하세요.

endpoint = "paste-your-endpoint-here"
key = "paste-your-key-here"

from azure.ai.textanalytics import TextAnalyticsClient
from azure.core.credentials import AzureKeyCredential

# Authenticate the client using your key and endpoint. 
def authenticate_client():
    ta_credential = AzureKeyCredential(key)
    text_analytics_client = TextAnalyticsClient(
            endpoint=endpoint, 
            credential=ta_credential)
    return text_analytics_client

client = authenticate_client()

# Example function for recognizing entities and providing a link to an online data source.
def entity_linking_example(client):

    try:
        documents = ["""Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975, 
        to develop and sell BASIC interpreters for the Altair 8800. 
        During his career at Microsoft, Gates held the positions of chairman,
        chief executive officer, president and chief software architect, 
        while also being the largest individual shareholder until May 2014."""]
        result = client.recognize_linked_entities(documents = documents)[0]

        print("Linked Entities:\n")
        for entity in result.entities:
            print("\tName: ", entity.name, "\tId: ", entity.data_source_entity_id, "\tUrl: ", entity.url,
            "\n\tData Source: ", entity.data_source)
            print("\tMatches:")
            for match in entity.matches:
                print("\t\tText:", match.text)
                print("\t\tConfidence Score: {0:.2f}".format(match.confidence_score))
                print("\t\tOffset: {}".format(match.offset))
                print("\t\tLength: {}".format(match.length))
            
    except Exception as err:
        print("Encountered exception. {}".format(err))
entity_linking_example(client)

출력

Linked Entities:
    
    Name:  Microsoft        Id:  Microsoft  Url:  https://en.wikipedia.org/wiki/Microsoft
    Data Source:  Wikipedia
    Matches:
            Text: Microsoft
            Confidence Score: 0.55
            Offset: 0
            Length: 9
            Text: Microsoft
            Confidence Score: 0.55
            Offset: 168
            Length: 9
    Name:  Bill Gates       Id:  Bill Gates         Url:  https://en.wikipedia.org/wiki/Bill_Gates
    Data Source:  Wikipedia
    Matches:
            Text: Bill Gates
            Confidence Score: 0.63
            Offset: 25
            Length: 10
            Text: Gates
            Confidence Score: 0.63
            Offset: 179
            Length: 5
    Name:  Paul Allen       Id:  Paul Allen         Url:  https://en.wikipedia.org/wiki/Paul_Allen
    Data Source:  Wikipedia
    Matches:
            Text: Paul Allen
            Confidence Score: 0.60
            Offset: 40
            Length: 10
    Name:  April 4  Id:  April 4    Url:  https://en.wikipedia.org/wiki/April_4
    Data Source:  Wikipedia
    Matches:
            Text: BASIC
            Confidence Score: 0.33
            Offset: 98
            Length: 5
    Name:  Altair 8800      Id:  Altair 8800        Url:  https://en.wikipedia.org/wiki/Altair_8800
    Data Source:  Wikipedia
    Matches:
            Text: Altair 8800
            Confidence Score: 0.88
            Offset: 125
            Length: 11

리소스 정리

Azure AI 서비스 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제할 수 있습니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다.

다음 단계

참조 설명서

이 빠른 시작을 통해 REST API를 사용하여 엔터티 연결 요청을 보냅니다. 다음 예제에서는 cURL을 사용하여 텍스트에 있는 엔터티를 식별하고 명확하게 합니다.

Language Studio를 사용하여 코드를 작성하지 않고도 Language Service 기능을 사용해 볼 수 있습니다.

필수 조건

  • cURL의 현재 버전입니다.
  • Azure 구독 이 있으면 Azure Portal에서 언어 리소스 를 만들어 키와 엔드포인트를 가져옵니다. 배포한 후 리소스로 이동을 선택합니다.
    • 애플리케이션을 API에 연결하려면 만든 리소스의 키와 엔드포인트가 필요합니다. 빠른 시작의 뒷부분에서 아래 코드에 키와 엔드포인트를 붙여넣습니다.
    • 무료 가격 책정 계층(Free F0)을 사용하여 서비스를 사용해 볼 수 있으며 나중에 프로덕션용 유료 계층으로 업그레이드할 수 있습니다.

참고 항목

  • 다음 BASH 예제에서는 \ 줄 연속 문자를 사용합니다. 콘솔 또는 터미널에서 다른 줄 연속 문자를 사용하는 경우 해당 문자를 사용합니다.
  • GitHub에서 언어별 샘플을 찾을 수 있습니다.
  • Azure Portal로 이동하여 필수 구성 요소에서 만든 언어 리소스에 대한 키와 엔드포인트를 찾습니다. 리소스의 키 및 엔드포인트 페이지에 리소스 관리 아래에 있습니다. 그런 다음, 아래 코드의 문자열을 키와 엔드포인트로 바꿉니다. API를 호출하려면 다음 정보가 필요합니다.
parameter 설명
-X POST <endpoint> API에 액세스하기 위한 엔드포인트를 지정합니다.
-H Content-Type: application/json JSON 데이터를 보내기 위한 콘텐츠 형식.
-H "Ocp-Apim-Subscription-Key:<key> API에 액세스하기 위한 키를 지정합니다.
-d <documents> 보낼 문서가 포함된 JSON입니다.

다음 cURL 명령은 BASH 셸에서 실행됩니다. 사용자 고유의 리소스 이름, 리소스 키 및 JSON 값을 사용하여 이러한 명령을 편집합니다.

엔터티 연결

  1. 명령을 텍스트 편집기에 복사합니다.
  2. 필요한 경우 명령에서 다음을 변경합니다.
    1. <your-language-resource-key> 값을 키로 바꿉니다.
    2. 요청 URL <your-language-resource-endpoint>의 첫 번째 부분을 고유한 엔드포인트 URL로 바꿉니다.
  3. 명령 프롬프트 창을 엽니다.
  4. 텍스트 편집기에서 명령을 명령 프롬프트 창에 붙여넣은 다음 명령을 실행합니다.
curl -i -X POST https://<your-language-resource-endpoint>/language/:analyze-text?api-version=2022-05-01 \
-H "Content-Type: application/json" \
-H "Ocp-Apim-Subscription-Key: <your-language-resource-key>" \
-d \
'
{
    "kind": "EntityLinking",
    "parameters": {
        "modelVersion": "latest"
    },
    "analysisInput":{
        "documents":[
            {
                "id":"1",
                "language":"en",
                "text": "Microsoft was founded by Bill Gates and Paul Allen on April 4, 1975."
            }
        ]
    }
}
'

JSON 응답

{
	"kind": "EntityLinkingResults",
	"results": {
		"documents": [{
			"id": "1",
			"entities": [{
				"bingId": "a093e9b9-90f5-a3d5-c4b8-5855e1b01f85",
				"name": "Microsoft",
				"matches": [{
					"text": "Microsoft",
					"offset": 0,
					"length": 9,
					"confidenceScore": 0.48
				}],
				"language": "en",
				"id": "Microsoft",
				"url": "https://en.wikipedia.org/wiki/Microsoft",
				"dataSource": "Wikipedia"
			}, {
				"bingId": "0d47c987-0042-5576-15e8-97af601614fa",
				"name": "Bill Gates",
				"matches": [{
					"text": "Bill Gates",
					"offset": 25,
					"length": 10,
					"confidenceScore": 0.52
				}],
				"language": "en",
				"id": "Bill Gates",
				"url": "https://en.wikipedia.org/wiki/Bill_Gates",
				"dataSource": "Wikipedia"
			}, {
				"bingId": "df2c4376-9923-6a54-893f-2ee5a5badbc7",
				"name": "Paul Allen",
				"matches": [{
					"text": "Paul Allen",
					"offset": 40,
					"length": 10,
					"confidenceScore": 0.54
				}],
				"language": "en",
				"id": "Paul Allen",
				"url": "https://en.wikipedia.org/wiki/Paul_Allen",
				"dataSource": "Wikipedia"
			}, {
				"bingId": "52535f87-235e-b513-54fe-c03e4233ac6e",
				"name": "April 4",
				"matches": [{
					"text": "April 4",
					"offset": 54,
					"length": 7,
					"confidenceScore": 0.38
				}],
				"language": "en",
				"id": "April 4",
				"url": "https://en.wikipedia.org/wiki/April_4",
				"dataSource": "Wikipedia"
			}],
			"warnings": []
		}],
		"errors": [],
		"modelVersion": "2021-06-01"
	}
}

리소스 정리

Azure AI 서비스 구독을 정리하고 제거하려면 리소스 또는 리소스 그룹을 삭제할 수 있습니다. 리소스 그룹을 삭제하면 해당 리소스 그룹에 연결된 다른 모든 리소스가 함께 삭제됩니다.

다음 단계