長い文字列で単語を見つける関数があります。
間の文字列を含む変数 "v" の場合、行は一致します。<vocab></vocab>
if(p.matches("\\W"+v+"\\W"))
この行は、v が \n または \t またはスペースの間の完全な単語であり、別の単語に含まれていないことに一致する必要があります。
これは私の文字列です:
<meta>
<vocab>called</vocab>
</meta>
<para>
called to-VP,Reid-NP,television cameras-NP
called to-VP,Reid-NP,one of-NP
one of-VP,Reid-NP,ornate rooms-NP
called to-VP,Reid-NP,Capitol-NP
called to-VP,Reid-NP,ceremony-NP
passed on-VP,last week-NP,spending bill-NP
passed on-VP,last week-NP,House-NP
passed on-VP,last week-NP,Senate-NP
officially complete-VP,ceremony-VP/NP,action-NP
called to-VP,television cameras-NP,one-NP
called in-VP,television cameras-NP,Capitol-NP
called for-VP,television cameras-NP,ceremony-NP
called-VP,Reid-NP,television cameras-NP
age-NP,last week-NP,event-num
</para>