>>> sentences=readwords.glom().map(lambda x:"".join(x)).flatMap(lambda y:y.split(".")).flatMap(lambda z:z.split( )).map(lambda a:(a,1)).reduceByKey(lambda a,b:a+b).map(lambda a:(a[1],a[0])).sortByKey(False)
>>> for row in sentences.collect():
... print(row)
...
(9, u'the')
(8, u'Spark')
(7, u'SQL')
(6, u'data')
(5, u'of')
(5, u'columnar')
其中定义了 trait Cohoist[F[_[_], _]] extends ComonadTrans[F] {
def cohoist[M[_], N[_]: Comonad](f: M ~> N): F[M, ?] ~> F[N, ?]
}
:
ComonadTrans
问题是如何治疗这种类型?有人可以用几个字解释一下还是举个例子?