0
SentiWordメソッドは文字列引数をとり、動詞または名詞としてタグ付けするためにタグ付けメソッドを使用します....その他このコードを実行すると、 get "java.lang.StringIndexOutOfBoundsException:文字列インデックスが範囲外にあります-3"このような質問がありますが、例外を取り除くためには適用できません。"java.lang.StringIndexOutOfBoundsException:文字列インデックスが範囲外です-3"
私がしようとしています何public static String SentiWord(String stri) {
MaxentTagger tagger = new MaxentTagger("taggers/english-left3words-distsim.tagger");
String sample=stri;
sample = sample.replaceAll("([^a-zA-Z\\s])", "");
String[] words = sample.split("\\s+");
String taggedSample = tagger.tagString(sample);
String[] taggedWords = taggedSample.split("\\s+");
double totalScore = 0;
SWN3 test = new SWN3();
for (int i=0; i<taggedWords.length;i++) {
String tail = taggedWords[i].substring(words[i].length() + 1);
....
...
}
:
if (words[i].length()>0) // This line
tail = taggedWords[i].substring(words[i].length() + 1);
しかし、例外doesntのは、助けをgo.Pleaseているように見えます。
'taggedWords'と' words'は異なる長さの異なる配列です –
あなたの条件を変更します - if(taggedWords [i] .length()> = words [i] .length) ' –
例外を投稿するときは、 stacktraceをインクルードすると便利です。 –