次の方法で共有


Azure Database for PostgreSQL - フレキシブル サーバーと Azure Cognitive Services の統合

Azure AI 拡張機能を使用すると、感情分析などのAzure AI Language サービスをデータベース内から直接呼び出すことができます。

前提条件

  1. azure_ai 拡張機能を有効にして構成します
  2. Azure portal で言語リソースを作成し、キーとエンドポイントを取得します。
  3. デプロイされたら、 [リソースに移動] を選択します。

Note

API に拡張機能を接続するには、作成したリソースのキー、エンドポイント、リージョンが必要です。

Azure Cognitive Services で azure_ai 拡張機能を構成する

言語リソースの [リソース管理]>[キーとエンドポイント] で、言語リソースのエンドポイント、キー、場所/リージョンを見つけることができます。 このエンドポイントとキーを使用して、モデル デプロイを呼び出す azure_ai 拡張機能を有効にします。 場所/リージョンの設定は変換関数にのみ必要です。

select azure_ai.set_setting('azure_cognitive.endpoint','https://<endpoint>.cognitiveservices.azure.com');
select azure_ai.set_setting('azure_cognitive.subscription_key', '<API Key>');
-- the region setting is only required for the translate function
select azure_ai.set_setting('azure_cognitive.region', '<Region>');

感情分析

感情分析を行うと、モデルに渡したテキストの感情ラベル (negativepositiveneutral) と信頼度スコアを確認できます。

azure_cognitive.analyze_sentiment

azure_cognitive.analyze_sentiment(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.analyze_sentiment(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.analyze_sentiment(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

batch_size

integer DEFAULT 10 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能が感情分析のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能が感情分析のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.sentiment_analysis_result または TABLE(result azure_cognitive.sentiment_analysis_result) は、使用される関数のオーバーロードに応じて、入力テキストのセンチメント予測を含む、単一の要素または単一列のテーブルです。 これには、positivenegativeneutralmixed のいずれかのセンチメントが含まれます。テキストに含まれる positive (肯定的)、neutral (中立)、negative (否定的) のセンチメントは、0 から 1 の間の実数として表されます。 たとえば (neutral,0.26,0.64,0.09) の場合、センチメントは neutral で、positive スコアは 0.26、中立は 0.64、否定的は 0.09 です。

言語検出

Azure AI の言語検出では、ドキュメントの言語が自動的に検出されます。

azure_cognitive.detect_language

azure_cognitive.detect_language(text text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.detect_language(text text[], batch_size integer DEFAULT 1000, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

batch_size

integer DEFAULT 1000 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能が言語検出のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能が言語検出のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.language_detection_result または TABLE(result azure_cognitive.language_detection_result) は、使用される関数のオーバーロードに応じて、検出された言語名、その言語の 2 文字の ISO 639-1 表現、検出の信頼度スコアを含む、単一の要素または単一列のテーブルです。 たとえば、(Portuguese,pt,0.97) では、言語は Portuguese、検出の信頼度は 0.97 です。

キー フレーズ抽出

Azure AI のキー フレーズ抽出を使用すると、テキスト内の主要な概念を抽出します。

azure_cognitive.extract_key_phrases

azure_cognitive.extract_key_phrases(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.extract_key_phrases(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.extract_key_phrases(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

batch_size

integer DEFAULT 10 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がキー フレーズ抽出のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がキー フレーズ抽出のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

text[] または TABLE(key_phrases text[]) は、テキスト内で識別されるキー フレーズを含む単一の要素または単一列のテーブルです。 たとえば、text'For more information, see Cognitive Services Compliance and Privacy notes.' に設定し、language'en' に設定して呼び出した場合、{"Cognitive Services Compliance","Privacy notes",information} が返される可能性があります。

エンティティ リンク設定

Azure AI のエンティティ リンクは、テキストで見つかったエンティティの ID を識別し、あいまいさを解消して既知のナレッジ ベースにリンクさせます。

azure_cognitive.linked_entities

azure_cognitive.linked_entities(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.linked_entities(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.linked_entities(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

batch_size

integer DEFAULT 5 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.linked_entity[] または TABLE(entities azure_cognitive.linked_entity[]) は、テキスト内で識別されるキー フレーズを含む配列または単一列のテーブルで、リンクされたエンティティのコレクションです。各エンティティが名前、データ ソース エンティティ識別子、言語、データ ソース、URL、azure_cognitive.linked_entity_match のコレクション (テキストと信頼度スコアを定義する)、Bing エンティティ検索 API 識別子を定義します。 たとえば、text'For more information, see Cognitive Services Compliance and Privacy notes.' に設定し、language'en' に設定して呼び出した場合、{"(\"Cognitive computing\",\"Cognitive computing\",en,Wikipedia,https://en.wikipedia.org/wiki/Cognitive_computing,\"{\"\"(\\\\\"\"Cognitive Services\\\\\"\",0.78)\ "\"}\",d73f7d5f-fddb-0908-27b0-74c7db81cd8d)","(\"Regulatory compliance\",\"Regulatory compliance\",en,Wikipedia,https://en.wikipedia.org/wiki/Regulatory_compliance ,\"{\"\"(Compliance,0.28)\"\"}\",89fefaf8-e730-23c4-b519-048f3c73cdbd)","(\"Information privacy\",\"Information privacy\",en,Wikipedia,https://en.wikipedia.org/wiki /Information_privacy,\"{\"\"(Privacy,0)\"\"}\",3d0f2e25-5829-4b93-4057-4a805f0b1043)"} が返される可能性があります。

azure_cognitive.recognize_entities

Azure AI の固有表現認識 (NER) 機能を使用すると、非構造化テキストのエンティティを識別および分類できます。

azure_cognitive.recognize_entities(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.recognize_entities(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.recognize_entities(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

batch_size

integer DEFAULT 5 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.entity[] または TABLE(entities azure_cognitive.entity[]) は、エンティティを含む配列または単一列のテーブルです。各エンティティが、エンティティを特定するテキスト、エンティティのカテゴリ、一致する信頼度スコアを識別します。 たとえば、text'For more information, see Cognitive Services Compliance and Privacy notes.' に設定し、language'en' に設定して呼び出した場合、{"(\"Cognitive Services\",Skill,\"\",0.94)"} が返される可能性があります。

個人を特定できるデータ (PII) の検出

入力したテキストで見つかった PII データを識別し、それらのエンティティを種類別に分類します。

azure_cognitive.recognize_pii_entities

azure_cognitive.recognize_pii_entities(text text, language text DEFAULT NULL::text, domain text DEFAULT 'none'::text, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.recognize_pii_entities(text text[], language text DEFAULT NULL::text, domain text DEFAULT 'none'::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.recognize_pii_entities(text text[], language text[] DEFAULT NULL::text[], domain text DEFAULT 'none'::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

domain

text DEFAULT 'none'::text は、個人データのエンティティ認識に使用される個人データ ドメインです。 有効な値は、ドメインが指定されていない場合は none で、個人の健康情報に関しては phi です。

batch_size

integer DEFAULT 5 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT true 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.pii_entity_recognition_result または TABLE(result azure_cognitive.pii_entity_recognition_result) は、編集されたテキストとエンティティを azure_cognitive.entity[] として含む単一の値または単一列のテーブルです。 各エンティティには信頼度スコアが含まれており、このスコアは、未編集のテキスト、個人データのカテゴリ、サブカテゴリ、エンティティが、識別された substring とどの程度正しく一致しているかを示します。 たとえば、text'My phone number is +1555555555, and the address of my office is 16255 NE 36th Way, Redmond, WA 98052.' に設定し、language'en' に設定して呼び出した場合、("My phone number is ***********, and the address of my office is ************************************.","{""(+1555555555,PhoneNumber,\\""\\"",0.8)"",""(\\""16255 NE 36th Way, Redmond, WA 98052\\"",Address,\\""\\"",1)""}") が返される可能性があります。

ドキュメントの概要作成

ドキュメント要約では、自然言語処理手法を使ってドキュメントの概要が生成されます。

azure_cognitive.summarize_abstractive

ドキュメントの抽象要約では、ドキュメント内で使われている単語とは異なる単語を一部使用しながら、そのドキュメントの主な内容を捉えた概要が生成されます。

azure_cognitive.summarize_abstractive(text text, language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.summarize_abstractive(text text[], language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.summarize_abstractive(text text[], language text[] DEFAULT NULL::text[], sentence_count integer DEFAULT 3, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

sentence_count

integer DEFAULT 3 は、要約に含める文の最大数です。

batch_size

integer DEFAULT 25 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

text[] または TABLE(summaries text[]) は、要約を示す配列または単一列のテーブルです。各要約は、定義した sentence_count の値を超えないものになっています。 たとえば、text'PostgreSQL features transactions with atomicity, consistency, isolation, durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures. It is designed to handle a range of workloads, from single machines to data warehouses or web services with many concurrent users. It was the default database for macOS Server and is also available for Linux, FreeBSD, OpenBSD, and Windows.' に設定し、language'en' に設定して呼び出した場合、{"PostgreSQL is a database system with advanced features such as atomicity, consistency, isolation, and durability (ACID) properties. It is designed to handle a range of workloads, from single machines to data warehouses or web services with many concurrent users. PostgreSQL was the default database for macOS Server and is available for Linux, BSD, OpenBSD, and Windows."} が返される可能性があります。

azure_cognitive.summarize_extractive

ドキュメントの抽出要約では、ドキュメント内の重要な文を抽出することにより概要が生成されます。

azure_cognitive.summarize_extractive(text text, language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.summarize_extractive(text text[], language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.summarize_extractive(text text[], language text[] DEFAULT NULL::text[], sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

引数

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

sentence_count

integer DEFAULT 3 は、抽出する文の最大数です。

sort_by

text DEFAULT ``offset``::text は、抽出された文の順序です。 有効値は rank または offset です。

batch_size

integer DEFAULT 25 は、一度に処理するレコードの数です (パラメーター input がタイプ text[] の関数のオーバーロードでのみ使用可能)。

disable_service_logs

boolean DEFAULT false 言語サービスでは、問題のトラブルシューティングのために、入力されたテキストを 48 時間ログに記録します。 このプロパティを true に設定すると入力のログ記録が無効になるため、問題が発生した際の調査手段が制限される可能性があります。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

詳細については、Cognitive Services のコンプライアンスとプライバシーに関する注意事項 (https://aka.ms/cs-compliance) および Microsoft の責任ある AI の原則 (https://www.microsoft.com/ai/responsible-ai) を参照してください。

返り値の種類

azure_cognitive.sentence[] または TABLE(sentences azure_cognitive.sentence[]) は、抽出された文とそのランク スコアを示す配列または単一列のテーブルです。
たとえば、text'PostgreSQL features transactions with atomicity, consistency, isolation, durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures. It is designed to handle a range of workloads, from single machines to data warehouses or web services with many concurrent users. It was the default database for macOS Server and is also available for Linux, FreeBSD, OpenBSD, and Windows.' に設定し、language'en' に設定して呼び出した場合、{"(\"PostgreSQL features transactions with atomicity, consistency, isolation, durability (ACID) properties, automatically updatable views, materialized views, triggers, foreign keys, and stored procedures.\",0.16)","(\"It is designed to handle a range of workloads, from single machines to data warehouses or web services with many concurrent users.\",0)","(\"It was the default database for macOS Server and is also available for Linux, FreeBSD, OpenBSD, and Windows.\",1)"} が返される可能性があります。

言語翻訳

Azure AI Text Translation を使用すると、ターゲット言語への迅速かつ正確な翻訳をリアルタイムで行うことができます。

azure_cognitive.translate

azure_cognitive.translate(text text, target_language text, source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text DEFAULT NULL::text, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.translate(text text, target_language text[], source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text[] DEFAULT NULL::text[], timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.translate(text text[], target_language text, source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text DEFAULT NULL::text, batch_size integer DEFAULT 1000, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
azure_cognitive.translate(text text[], target_language text[], source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text[] DEFAULT NULL::text[], batch_size integer DEFAULT 1000, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)

Note

翻訳は、バージョン 0.2.0 の azure_ai 拡張機能でのみ使用できます。 バージョンを確認するには、pg_available_extensions カタログ ビューを確認します。

select * from pg_available_extensions where name = 'azure_ai';

引数

パラメーターの詳細については、Translator API に関するページを参照してください。

text

text または text[] は、使用される関数のオーバーロードに応じて、処理される入力を含む、単一のテキストまたはテキストの配列です。

target_language

text または text[] は、使用される関数のオーバーロードに応じて、入力が書き込まれる言語の 2 文字の ISO 639-1 表現を使用する、単一の値または値の配列です。 使用可能な値については、言語サポートを確認してください。

source_language

text DEFAULT NULL 入力テキストの記述言語を ISO 639-1 の 2 文字コードで表したもの。 使用可能な値については、言語サポートを確認してください。 指定されていない場合は、自動言語検出が適用されてソース言語が特定されます。

text_type

boolean DEFAULT 'plain' 翻訳されるテキストの種類を定義します。 有効な値は 'plain' または 'html' です。 HTML はすべて整形式である必要があります。

profanity_action

boolean DEFAULT 'NoAction' 翻訳での不適切な表現の処理方法を指定します。 有効な値は、'NoAction'、'Marked'、または 'Deleted' です。 'NoAction' は既定の動作であり、不適切な表現はソースからターゲットに渡されます。 'Deleted' は、不適切な単語が置換されずに削除されることを示します。 'Marked' では、出力内のマークされた単語が profanity_marker パラメーターに置き換えられます。

profanity_marker

boolean DEFAULT 'Asterisk' 翻訳での不適切な表現のマーキング方法を指定します。 指定できる値は、'Asterisk' (不適切な単語を *** に置き換える) または 'Tag' (不適切な単語を '<profanity></profanity>' タグに置き換える) です。

suggested_source_language

text DEFAULT NULL 入力テキストの言語を識別できない場合のフォールバック言語を指定します。

source_script

text DEFAULT NULL 入力テキストの特定のスクリプト。

target_script

text DEFAULT NULL 入力テキストの特定のスクリプト。

batch_size

integer DEFAULT 1000 は、一度に処理するレコードの数です (パラメーター text がタイプ text[] の関数のオーバーロードでのみ使用可能)。

timeout_ms

integer DEFAULT 3600000 操作停止後のタイムアウト時間 (ミリ秒単位)。

throw_on_error

boolean DEFAULT true エラーが発生すると、関数から例外がスローされ、ラップしていたトランザクションがロールバックされます。

max_attempts

integer DEFAULT 1 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントの呼び出しを再試行する回数です。

retry_delay_ms

integer DEFAULT 1000 は、再試行可能なエラーで失敗した場合に、拡張機能がリンクされた ID のために Azure Language Service エンドポイントを再度呼び出す前に待機する時間 (ミリ秒) です。

返り値の種類

azure_cognitive.translated_text_result または TABLE(result azure_cognitive.translated_text_result) は、翻訳されたテキストを示す配列または単一列のテーブルです。 応答本文の詳細については、「応答本文」を参照してください。

センチメント分析の例

select b.*
from azure_cognitive.analyze_sentiment('The book  was not great, It is mediocre at best','en') b

概要作成の例

SELECT
    bill_id,
    unnest(azure_cognitive.summarize_abstractive(bill_text, 'en')) abstractive_summary
FROM bill_summaries
WHERE bill_id = '114_hr2499';

翻訳の例

-- Translate into Portuguese
select  a.*
from azure_cognitive.translate('Language Translation in real time in multiple languages is quite cool', 'pt') a;

-- Translate to multiple languages
select  (unnest(a.translations)).*
from azure_cognitive.translate('Language Translation in real time in multiple languages is quite cool', array['es', 'pt', 'zh-Hans']) a;

個人データ検出の例

select
    'Contoso employee with email Contoso@outlook.com is using our awesome API' as InputColumn,
    pii_entities.*
    from azure_cognitive.recognize_pii_entities('Contoso employee with email Contoso@outlook.com is using our awesome API', 'en') as pii_entities