java 分句_JAVA按文字,标点符号和引号分割句子
一句話:
"Hallo, I'm a dog. The end. Someone said: \"Earth is Earth\". Is it good? I like it! 'He is right' said I."
當前正則表達式:
\\s+|(?<=[\\p{Punct}&&[^']])|(?=[\\p{Punct}&&[^']])
當前的結果:
{"Hallo", ",", "I'm", "a", "dog", ".", "The", "end", ".", "Someone",
"said", ":", **""**, """ , "Earth", "is", "Earth", """, ".", "Is", "it",
"good", "?", "I", "like", "it", "!", **"'He"**, "is", **"right'"**,
"said", "I", "."}
我有多余的""一次報價符號前,它不會分裂“從單詞。
結果,我想:
{"Hallo", ",", "I'm", "a", "dog", ".", "The", "end", ".", "Someone",
"said", ":", """ , "Earth", "is", "Earth", """, ".", "Is", "it",
"good", "?", "I", "like", "it", "!", "'" , "He", "is", "right", "'",
"said", "I", "."}
編輯: 對不起!更多的代碼,然后:
String toTest = "Hallo, I'm a dog. The end. Someone said: \"Earth is Earth\". Is it good? I like it! 'He is right' said I.";
String [] words = toTest.split("\\s+|(?<=[\\p{Punct}&&[^']])|(?=[\\p{Punct}&&[^']])");
,并產生單詞列表: “ ”
話= { “你好”,“”, “我”, “一”, “狗”, “The”,“end”,“。”,“Someone”, “said”,“:”,“”“”,“”,“Earth”,“is”,“Earth” “”,“Is”,“it”, “好”,“?”,“我”,“like”,“它”,“!”,“'他”,“is”,“ right'“, ”said“,”I“,”。“}
+0
我在您的問題中看不到任何Java代碼。 –
2014-11-21 13:04:29
+0
@LutzHorn正則表達式是一個Java代碼。 –
2014-11-21 13:05:46
+0
@RealSkeptic為什么不是Perl,Python或Ruby? –
2014-11-21 13:10:21
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的java 分句_JAVA按文字,标点符号和引号分割句子的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java 包权限_Java基础(十二)之
- 下一篇: 移动宽带怎么连接两个路由器一个宽带怎么连