在斯卡拉,我有一個由一組句子組成的文本。 我試圖分裂這個文本變成單獨的句子是這樣的:使用「。」不能正確分割文本。分隔符
val sentences: Array[String] = text.split(".")
然而,當我檢查sentences
陣列(如在下面的線),我觀察到數組爲空:
println("Sentences are: " + sentences.mkString(" "))
爲什麼拆分不正確?
對於文本:
A sword is a bladed weapon intended for both cutting and thrusting. The precise definition of the term varies with the historical epoch or the geographical region under consideration. A sword in the most narrow sense consists of a straight blade with two edges.
輸出是:
Sentences are:
您是否有一個最小示例在手?我是斯卡拉的初學者,但我想幫忙。 – gsamaras
我也在談論代碼。 :) – gsamaras
包含它的代碼有點複雜,我認爲這不會有幫助。 – octavian