たとえば副詞を数えたいのですが、「_ RB」、「_ RBR」、「_RBS」などの種類ごとに異なるタグがあります。3つのシーケンスでサブストリングを使用してみましたが、これにより、「_RB」と「_RBS」の長いタグを見つけることができなくなります。JavaでStanfordPOSタガーを使用していますが、各タイプのタグをカウントする方法がわかりません。これが私がこれまでに持っているものです:
int pos = 0;
int end = tagged.length() - 1;
int nouns = 0;
int adjectives = 0;
int adverbs = 0;
while (pos < (end - 1)){
pos++;
String sequence = tagged.substring(pos - 1, pos + 2);
//System.out.println(sequence);
if (sequence.equals("_NN")){
nouns++;
}
if (sequence.equals("_JJ")){
adjectives++;
}
if (sequence.equals("_RB")){
adverbs++;
}
}
タグ付きはタグ付き文字列です。
タグ付けされた文字列の例を次に示します。
This_DT is_VBZ a_DT good_JJ sample_NN sentence_NN ._. Here_RB is_VBZ another_DT good_JJ sample_NN sentence_NN ._.