我有一堆明文形式的推文,如下所示.我期待仅提取文本部分.
文件中的样本数据 -
Fri Nov 13 20:27:16 +0000 2015 4181010297 rt we're treating one of you lads to this d'struct denim shirt! simply follow & rt to enter
Fri Nov 13 20:27:16 +0000 2015 2891325562 this album is wonderful, i'm so proud of you, i loved this album, it really is the best. -273
Fri Nov 13 20:27:19 +0000 2015 2347993701 international break is garbage smh. it's boring and your players get injured
Fri Nov 13 20:27:20 +0000 …Run Code Online (Sandbox Code Playgroud) 最近开始在 Scala 中编码,我尝试编写一些基于属性的测试用例。在这里,我试图生成模仿我正在测试的系统的原始数据。目标是首先生成基本元素(ctrl和idz),然后使用这些值生成两个类(A1和B1),最后检查它们的属性。我首先尝试了以下方法 -
import org.scalatest._
import prop._
import scala.collection.immutable._
import org.scalacheck.{Gen, Arbitrary}
case class A(
controller: String,
id: Double,
x: Double
)
case class B(
controller: String,
id: Double,
y: Double
)
object BaseGenerators {
val ctrl = Gen.const("ABC")
val idz = Arbitrary.arbitrary[Double]
}
trait Generators {
val obj = BaseGenerators
val A1 = for {
controller <- obj.ctrl
id <- obj.idz
x <- Arbitrary.arbitrary[Double]
} yield A(controller, id, x)
val …Run Code Online (Sandbox Code Playgroud)