for(CoreMap sentence : sentences)
{
for(CoreLabel token : sentence.get(TokensAnnotation.class))
{
String word = token.get(TextAnnotation.class);
String lemma = token.get(LemmaAnnotation.class);
// if(token 中间有“/”分割,则是两个单词)
if(word.indexOf("/") != -1)
{
String[] str = word.split("/");
String[] lem = lemma.split("/");
for(int i = 0; i < str.length; i++)
{
tokenList.add(str[i]);
lemmaList.add(lem[i]);
}
}else
{
tokenList.add(word);
lemmaList.add(lemma);
}
}
result.add(tokenList);
result.add(posList);
result.add(lemmaList);
}
"/" 分割形成两个词
最新推荐文章于 2023-08-02 00:40:27 发布