小编use*_*203的帖子

如何将文本解析成句子

我试图将一个段落分解成句子.到目前为止,这是我的代码:

import java.util.*;

public class StringSplit {
 public static void main(String args[]) throws Exception{
     String testString = "The outcome of the negotiations is vital, because the current tax levels signed into law by President George W. Bush expire on Dec. 31. Unless Congress acts, tax rates on virtually all Americans who pay income taxes will rise on Jan. 1. That could affect economic growth and even holiday sales.";
     String[] sentences = testString.split("[\\.\\!\\?]");
     for (int i=0;i<sentences.length;i++){  
         System.out.println(i);
      System.out.println(sentences[i]);  
     }  
 }
} …
Run Code Online (Sandbox Code Playgroud)

java text-parsing

7
推荐指数
2
解决办法
1万
查看次数

标签 统计

java ×1

text-parsing ×1