キー フレーズを抽出する

完了

キー フレーズ抽出は、Azure 言語によって提供される機能です。 テキスト内のキー フレーズ (主要な概念) を識別します。

キー フレーズ抽出 API を呼び出すには、いくつかの方法があります。 ここでは、 azure_ai 拡張機能を使用して、SQL クエリでキー フレーズを抽出します。

[前提条件]

azure_ai拡張機能を有効にして構成した Azure Database for PostgreSQL フレキシブル サーバーが必要です。 また、言語リソースのキーとエンドポイントを設定して、Azure Cognitive Services で 承認 する必要があります。

シナリオ

キー フレーズ抽出は、さまざまなタスクに適用されます。

  • 要約: キー フレーズを使用して、音声トランスクリプトや会議ノートで説明されているトピックの識別など、重要なトピックに長いドキュメントを減らします。
  • コンテンツの分類: キー フレーズを使用して、検索と参照のためにドキュメントのインデックスを作成します。 キー フレーズを使用して、ワード クラウド内のドキュメントを視覚化することもできます。
  • ドキュメント クラスタリング: サポート チケット、製品レビュー、およびその他の非構造化入力の広範なコレクションを、キー フレーズを使用してクラスター化および分析できます。

Azure Cognitive Services でのキー フレーズ抽出 SQL の使用

Azure Database for PostgreSQL フレキシブル サーバーの azure_ai拡張機能 には、SQL 内から直接 AI 機能にアクセスするためのユーザー定義関数 (UDF) が用意されています。 キー フレーズ抽出 API には、 azure_cognitive.extract_key_phrases 関数を使用してアクセスします。

azure_cognitive.extract_key_phrases(
 text TEXT,
 language TEXT,
 timeout_ms INTEGER DEFAULT 3600000,
 throw_on_error BOOLEAN DEFAULT TRUE,
 disable_service_logs BOOLEAN DEFAULT FALSE
)

必要なパラメーターは、textが書き込まれる言語language、入力、およびtextです。 たとえば、 en-us は米国英語で、 fr はフランス語です。 使用可能な 言語 の完全な一覧については、言語サポートを参照してください。

既定では、キー フレーズの抽出が 3,600,000 ミリ秒 (1 時間) で終了しない場合は停止されます。 この遅延をカスタマイズするには、 timeout_msを変更します。

エラーが発生した場合、既定の動作では例外がスローされ、トランザクションがロールバックされます。 この動作を無効にするには、 throw_on_error を false に設定します。

パラメーターの完全なドキュメントについては、 Azure Cognitive Services 拡張機能のドキュメント を参照してください。

たとえば、次のクエリを呼び出します。

SELECT azure_cognitive.extract_key_phrases('The food was delicious and the staff were wonderful.', 'en-us');

次の結果が得られます。

 extract_key_phrases 
---------------------
 {food,staff}

入力テキストにはテーブル列を使用できます。

SELECT description, azure_cognitive.extract_key_phrases(description, 'en-us')
FROM listings LIMIT 1;

次の値が返されます (拡張ディスプレイの場合は \x オン)。

description    | Welcome! If you stay here you will be living in a light filled two bedroom upper and ground level apartment (in a two apartment home). During your stay you will be welcome to share in our fresh eggs from the chickens and garden produce in season! Welcome! Come enjoy your time in Seattle at a lovely urban farmstead. There are two bedrooms each with a queen bed, full bath, living room and kitchen with wood floors throughout. During your stay you will be welcome to eat fresh eggs from the chickens and possibly fruit/veggies from the garden if you are in luck! We are family friendly and have a down to earth atmosphere. There is a large covered back porch and grill for hanging out especially in summer and a treehouse for up in the trees hammock time! Walking distance to Othello Light Rail Station for easy access to downtown. Also nearby is the fantastic Seward Park and the Kubota Gardens for outdoorsy loveliness. New last year is out beautiful Rainier Beach indoor swimming pool comp
extract_key_phrases | {"beautiful Rainier Beach indoor swimming pool","large covered back porch","Othello Light Rail Station","ground level apartment","lovely urban farmstead","fantastic Seward Park","two bedroom upper","two apartment home","two bedrooms","fresh eggs","queen bed","full bath","living room","wood floors","earth atmosphere","Walking distance","easy access","Kubota Gardens","outdoorsy loveliness","garden produce","hammock time",stay,chickens,season,Seattle,kitchen,fruit/veggies,luck,grill,summer,treehouse,trees,downtown,last}

概要

キー フレーズ抽出では、テキストから主要な概念が選択されます。 Azure Cognitive Services 言語モデルは、自然言語をキーワードまたはフレーズに分割する役割を担います。 Azure Database for PostgreSQL の azure_ai 拡張機能は、SQL クエリ内でキー フレーズ抽出に直接アクセスするための azure_cognitive.extract_key_phrases API を提供します。