カスタム エンティティのオプションの設定

ここでは、トレーニング オプション ファイルを作成する必要があります。このファイルには、モデルに関する情報と、モデルのトレーニングに適用するオプションが含まれます。このファイルは、UFT-8 エンコーディングの XML 形式で、以下に示すヘッダと必須トレーニング機能を含む必要があります。

トレーニング オプション ファイル内のヘッダ

ヘッダには、モデルの詳細情報、テストおよび入力ファイルのパス、そしてカスタム エンティティに注釈を付けるためのキーワードが記述されます。

  • modelName: カスタム モデルの名前
  • modelType: カスタム モデルのタイプ (CustomEntity)
  • modelDescription: カスタム モデルの説明
  • inputFilePath: モデルのトレーニングに使用するタグ付きファイル (入力ファイル) のパス
  • testFilePath: モデルのテストに使用するファイルのパス
  • magicWord: カスタム エンティティの注釈付けに使用するキーワード
  • language: テキストに使用される言語。
    注: 英語がサポートされています。オランダ語、フランス語、ドイツ語、スペイン語がベータ版の段階にあります。

トレーニング機能

以下のトレーニング機能を使用して、カスタム エンティティを作成できます。

  • 言語機能: 言語プロパティを指定します。
    • POSTagger: 名詞、代名詞、形容詞、動詞など、言語の部分を識別するためのタグ付けを行います。
      <trainingFeature>             
         <featureName>POSTagger</featureName>
      </trainingFeature>
  • 表記機能: 構造的プロパティを指定します。
    • CaseIdentifier: カスタム エンティティがすべて大文字か、すべて小文字か、大文字と小文字が混合しているかを識別します。
      <trainingFeature>
      	<featureName>CaseIdentifier</featureName>
      </trainingFeature>
    • NumericIdentifier: カスタム エンティティが数字か英数字かを識別します。
      <trainingFeature>
      	<featureName>NumericIdentifier</featureName>
      </trainingFeature>
    • 1st2ndIdentifier: カスタム エンティティが 1st、2nd、3rd などの序数かどうかを識別します。
      <trainingFeature>
      	<featureName>1st2ndIdentifier</featureName>
      </trainingFeature>
    • PatternMatcher: 正規表現を用いて 1 つ以上のパターンに対して単語をマッチングします。複数の正規表現を指定する場合は、AND か、いずれかが成立すればよい OR (デフォルト) を含めます。
      <trainingFeature>
      	<featureName>PatternMatcher</featureName>
      		<featureParams>
      			<entry>
      				<key>RegEx1</key>
      				<value>b[aeiou]t</value>
      			</entry>
      			<entry>
      				<key>RegEx2</key>
      				<value>b[xyz]t</value>
      			</entry>
      			<entry>
      				<key>JoinCondition</key>
      				<value>AND</value>
      			</entry>
      		</featureParams>
      </trainingFeature>
  • キーワード機能: キーワードのリストを定義します。
    • CategoryKeywords: 複数のカスタム リストに属するキーワードのリストのカテゴリを識別します。例えば、CategoryKeywords リストの Weekdays には、Monday、Tuesday、Wednesday、Thursday、および Friday という Keywords が含まれます。

      この機能では、マッチングで大文字と小文字を区別するかどうかも指定できます。デフォルトは true (大文字と小文字を区別) です。

      <trainingFeature>
      	<featureName>CategoryKeywords</featureName>
      	<featureParams>
      		<entry>
      			<key>Weekdays</key> 
                          <!-- List of weekdays -->
      			<value>Monday,Tuesday,Wednesday,Thursday,Friday</value>
      		</entry>
      		<entry>
      			<key>WeekendDays</key>
                          <!-- List of weekend days -->
      			<value>Saturday,Sunday</value>
      		</entry>
      		<entry>
      			<key>CaseSensitive</key>
                          <value>True</value>
      		</entry>
      	</featureParams>
      </trainingFeature>
    • KeyWords: DaysOfWeekMonth など、ユーザが指定したカスタム リストに属する単語を検索します。大文字と小文字を区別して検索するかどうかも指定できます。デフォルトは "true" (大文字と小文字を区別) です。
      <trainingFeature>
      	<featureName>KeyWords</featureName>
      	<featureParams>
      		<entry>
      			<key>KeyWordList</key>
      			<value>Monday,Tuesday</value>
      		</entry>
      		<entry>
      			<key>CaseSensitive</key>
      			<value>False</value>
      		</entry>
      	</featureParams>
      </trainingFeature>
    • Substring: パラメータで指定された部分文字列を抽出します。接頭語と接尾語の抽出にも使用できます。
      • StartLocation: Left (左) または Right (右)。文字列を抽出する位置。デフォルトは Left です。
      • StartPosition: 部分文字列の開始位置。デフォルトは 0 です。
      • EndPosition: 部分文字列の終了位置。デフォルトは 3 です。
      • MinLength: この機能を適用する単語の最小の長さ。デフォルトは 3 です。
      <trainingFeature>
      	<featureName>Substring</featureName>
      		<featureParams>
      			<entry>
      				<key>StartLocation</key>
      			</entry>
      			<entry>
      				<key>StartPosition</key>
      				<value>1</value>
      			</entry>
      			<entry>
      				<key>EndPosition</key>
      				<value>4</value>
      			</entry>
      			<entry>
      				<key>MinLength</key>
      		</featureParams>
      </trainingFeature>
  • 語彙機能: 語彙プロパティを指定します。
    • FeatureWindow: 機能生成のウィンドウを指定します。
      <trainingFeature>
      	<featureName>FeatureWindow</featureName>
      	<!-- Number of preceding tokens used to create the feature set. Default is 3 -->
      		<entry>
      			<key>Before</key>
      			<value>1</value>
      		</entry>
      	<!-- Number of succeeding tokens used to create the feature set. Default is 3 -->
      		<entry>
      			<key>After</key>
      			<value>2</value>
      		</entry>
      </trainingFeature>
      
カスタム エンティティに対する、完全なサンプル トレーニング オプション ファイルのサンプルを以下に示します。
<trainingOptions>
	<modelName>CustomModel</modelName>
	<modelType>CustomEntity</modelType>
	<modelDescription>CustomDiagnosesModel</modelDescription>
	<inputFilePath>C:/SpectrumIE/custom_model/Custom_Input.csv</inputFilePath>
	<testFilePath>C:/SpectrumIE/custom_model/Custom_Test.txt</testFilePath>
       <magicWord>DIAGNOSIS</magicWord>
       <language>English</language>
	
      <trainingFeatures>
	
	<!-- Lexical features-->
	<trainingFeature>
		<featureName>FeatureWindow</featureName>
		<featureParams>
			<entry>
				<key>Before</key>
				<value>1</value>
			</entry>
			<entry>
				<key>After</key>
				<value>2</value>
			</entry>
		</featureParams>
	</trainingFeature>

	<!-- Orthographic features-->
	<trainingFeature>
		<featureName>CaseIdentifier</featureName>
      </trainingFeature>

	<trainingFeature>
		<featureName>NumericIdentifier</featureName>
	</trainingFeature>
	</trainingFeatures>
 </trainingOptions>