Skip to main content

This documentation is for an older version of this product. See the latest version of this content.Opens in a new tab

InterSystems IRIS 自然言語処理 (NLP) ツール

ドメインを作成してデータを入力するためのプライマリ NLP インタフェースは、ドメイン・アーキテクトです。NLP データを分析するための主要なインタフェースには、ObjectScript プログラムから呼び出すことが可能なクラス・オブジェクト・メソッドとプロパティを含む API を使用します。この章で説明する NLP ツールは、NLP 機能の管理や NLP データのテストと検証を支援するためのものです。ここで説明するすべての NLP 機能は、iKnow API を使用して利用することもできます。

この章で説明する NLP ツールは、以下のとおりです。

NLP シェル・インタフェース

InterSystems IRIS 自然言語処理シェルを使用して、既存のドメインおよびインデックスが作成されているソースに関する情報を返すことができます。

すべての NLP 処理は、ネームスペース内で行われます。したがって、NLP シェルを呼び出す前に、$namespace 変数を使用して目的のネームスペースを指定する必要があります。

ターミナルから、次のようにして NLP シェル・インタフェースを有効にできます。

USER>DO $System.iKnow.Shell()

NLP シェル・プロンプトが返されます。NLP シェル・プロンプトで ? を入力すると、NLP シェル・コマンドのリストが表示されます。NLP シェル・コマンドの後に空白と ? を入力すると、そのコマンドに関する情報が表示されます。

NLP シェル・コマンドとオプションは、大文字と小文字が区別されるため、すべて小文字で指定する必要があります。

ソースのリスト、表示、および要約

次の NLP シェルの例では、現在のネームスペースにある “mydomain“ という名前の既存のドメインを利用します。ドメイン “mydomain“ には 100 個のソースが含まれています。use domain mydomain コマンドは、“mydomain“ を NLP シェルの現在のドメインにすることを指定します。list source コマンドは、現在のドメイン内のソースをリストします。既定により、list コマンドは 10 項目のページ・サイズにて、最初のページをリストします。追加のページをリストするには、以下の例で示すように、> コマンドを指定することができます。20 項目のページ・サイズに変更するには、use pagesize 20 を指定します。

show source 92 コマンドは、ソース 92 のコンテンツを文に分割してリストします。これは最初のページに 10 個の文をリストします。> コマンドを使用すれば、文の追加ページをリストすることができます。各文のテキストの前後には、文 ID と、表示される文テキストを切り詰める必要があったかどうかを示すブーリアン値が表示されます。(この例では、文のテキストに行の折り返しを追加しています。)show summary 92 6 コマンドは、ソース 92 ~ 6 の文の内容を要約し、これら 6 つの文を表示します。要約番号がソース内の文の数より大きい場合、show summary はソース内のすべての文を表示します。

USER>DO $System.iKnow.Shell()
 
Welcome to the iKnow shell
Type '?' for help
Type 'quit' to exit
 
iKnow> use domain mydomain
Current domain: mydomain (1)
iKnow> list source
 srcId          externalId
   100    :SQL:Accident:96
    99    :SQL:Accident:98
    98    :SQL:Accident:94
    97   :SQL:Accident:100
    96    :SQL:Accident:80
    95    :SQL:Accident:99
    94    :SQL:Accident:95
    93    :SQL:Accident:88
    92    :SQL:Accident:97
    91    :SQL:Incident:90
iKnow> >
 srcId         externalId
    90   :SQL:Accident:93
    89   :SQL:Accident:92
    88   :SQL:Accident:91
    87   :SQL:Accident:85
    86   :SQL:Accident:86
    85   :SQL:Accident:89
    84   :SQL:Accident:87
    83   :SQL:Accident:83
    82   :SQL:Accident:78
    81   :SQL:Accident:82
iKnow> show source 92
 sentId       sentenceValue                                                                  sentenceIsTruncated
   5090       On March 7, 2001, about 1500 Alaska standard time, a wheel/ski equipped 
              Cessna 180 airplane, N9383C, sustained substantial damage during takeoff from 
              a snow-covered area at Ophir, Alaska.                                          0
   5091       The airplane was being operated as a visual flight rules (VFR) cross-country
              personal flight to McGrath, Alaska, when the accident occurred.                0
   5092       The airplane was operated by the pilot.                                        0
   5093       The commercial certificated pilot, and the sole passenger, were not injured.   0
   5094       Visual meteorological conditions prevailed.                                    0
   5095       During a telephone conversation with the National Transportation Safety Board
              (NTSB) investigator-in-charge (IIC), on March 8, 2001, the pilot reported he
              landed near Ophir earlier in the day.                                          0
   5096       When he was planning to depart, the surface of the snow had become crusty.     0
   5097       The pilot said he began a takeoff run toward the south, but the airplane 
              did not become airborne until it was within about 50 yards from several trees. 0
   5098       During the initial climb, the left horizontal stabilizer collided with a 
              spruce tree about 25 feet above the ground.                                    0
   5099       The airplane began a descending left turn toward the ground, and collided
              with several trees while the pilot was making an emergency landing.            0
iKnow> show summary 92 6
 sentId       sentenceValue                                                                  sentenceIsTruncated
   5090       On March 7, 2001, about 1500 Alaska standard time, a wheel/ski equipped 
              Cessna 180 airplane, N9383C, sustained substantial damage during takeoff from 
              a snow-covered area at Ophir, Alaska.                                          0
   5091       The airplane was being operated as a visual flight rules (VFR) cross-country
              personal flight to McGrath, Alaska, when the accident occurred.                0
   5095       During a telephone conversation with the National Transportation Safety Board
              (NTSB) investigator-in-charge (IIC), on March 8, 2001, the pilot reported he
              landed near Ophir earlier in the day.
   5097       The pilot said he began a takeoff run toward the south, but the airplane 
              did not become airborne until it was within about 50 yards from several trees. 0
   5099       The airplane began a descending left turn toward the ground, and collided
              with several trees while the pilot was making an emergency landing.            0
   5100       The airplane received damage to the left main landing gear, the wings, 
              and the left stabilizer.                                                       0
iKnow> quit
Bye bye
 
USER>

ソースのフィルタ処理

次の NLP シェルの例では、現在のネームスペースにある “mydomain“ という名前の既存のドメインを利用します。ドメイン “mydomain“ には 100 個のソースが含まれています。use domain mydomain コマンドは、“mydomain“ を NLP シェルの現在のドメインにすることを指定します。list source コマンドは、現在のドメインで最初の 10 個のソースをリストします。filter source 92 94 97 as myfilter コマンドは、ソース ID で指定されたソース以外のすべてのソースを除外する “myfilter” という名前のフィルタを定義します。use filter myfilter コマンドは、“myfilter” を現在のフィルタに設定します。ここで、NLP シェルから list source コマンドを発行すると、“myfilter“ が適用され、“myfilter“ で指定された 3 つのソースだけがリストされます。

USER>DO $System.iKnow.Shell()
 
Welcome to the iKnow shell
Type '?' for help
Type 'quit' to exit
 
iKnow> use domain mydomain
Current domain: mydomain (1)
iKnow> list source
 srcId          externalId
   100    :SQL:Accident:96
    99    :SQL:Accident:98
    98    :SQL:Accident:94
    97   :SQL:Accident:100
    96    :SQL:Accident:80
    95    :SQL:Accident:99
    94    :SQL:Accident:95
    93    :SQL:Accident:88
    92    :SQL:Accident:97
    91    :SQL:Incident:90
iKnow> filter source 92 94 97 as myfilter
iKnow> use filter myfilter
Current filter: myfilter
 
iKnow> list source
 srcId          externalId
    97   :SQL:Accident:100
    94    :SQL:Accident:95
    92    :SQL:Accident:97
iKnow> quit
Bye bye
 
USER>

フィルタが適用されると、後続の use filter filtername によって、現在のフィルタが新しいフィルタに置き換えられます。フィルタを無効にするには、use filter 0 を指定します。

NLP データ・アップグレード・ユーティリティ

NLP データ構造の各バージョンには、システム・バージョン番号が割り当てられています。各 NLP ドメインには、VersionOpens in a new tab プロパティの値が割り当てられます。すべての新規ドメインは、現在のシステム・バージョンとして同じ Version プロパティを使用して作成されます。したがって、通常これら 2 つの整数値は同じになります。

  • InterSystems IRIS® Data Platform を新しいバージョンに更新したときに、NLP データ構造のシステム・バージョンがインクリメントされるのは、NLP インデックス作成が変更された場合です。したがって、InterSystems IRIS を新しいバージョンに更新しても、必ずしも NLP データ構造のシステム・バージョンがインクリメントされるとは限りません。

  • ドメインを作成すると、そのドメインは現在のデータ構造のシステム・バージョンを Version プロパティの値として取得します。したがって、以前のシステム・バージョンで作成された既存のドメインは、その以前のシステム・バージョンを Version プロパティの値として持っています。

最初の InterSystems IRIS のバージョン番号は 5 です。既存のドメインを InterSystems IRIS に移植すると、これより前のバージョン番号が表示される場合があります。

%iKnow.DomainOpens in a new tab クラスの GetCurrentSystemVersion()Opens in a new tab メソッドを使用して、現在の InterSystems IRIS インスタンスの NLP データ構造のシステム・バージョンを判定できます。“NLP 環境の設定” の章の "全ドメインのリスト" で説明したとおり、GetAllDomains クエリを使用して、すべてのドメインのドメイン・バージョン番号をリストできます。

NLP データ構造のシステム・バージョンがドメイン・バージョンと一致しない場合、それらの古い NLP ドメインでは、この新しいシステム・バージョンで導入された NLP の新機能やパフォーマンスの改善を利用できません。古いドメインは引き続き操作可能ですが、ドメインをアップグレードするまでは NLP データ構造の新機能を利用できません。ドメインをアップグレードすると、ドメインの Version プロパティがインクリメントされます。このアップグレード処理では、ドメイン・データのインデックスを自動的に再作成する必要があります。元のソース・テキストにアクセスする必要はありません。各ドメインは個々にアップグレードする必要があります。

ドメインをアップグレードするには、%iKnow.Utils.UpgradeUtilsOpens in a new tab クラスの UpgradeDomain()Opens in a new tab メソッドを使用します。詳細は、"インターシステムズ・クラス・リファレンス" ドキュメントを参照してください。

ドメインのアップグレード時に行われるインデックス再作成により、ドメイン ID は変更されますが、ドメイン名は変更されません。したがって、ドメインをアップグレードすると、特定のドメイン ID の整数値によってドメインを参照するプログラムに対しては変更が必要な場合があります。このため、ドメインを常にその ID プロパティ (またはドメイン名) で参照することをお勧めします。リテラルの整数 ID 値でドメインを参照するコーディング方法は避けてください。

FeedbackOpens in a new tab