Reputation: 25457
I don't understand what it wants from me. The assignment to sentence
is working:
val sentences : java.util.List[CoreMap] = document.get(classOf[SentencesAnnotation])
but I can't run a forEach
loop on this:
sentences.forEach( (s : CoreMap) => println("") )
since I am getting:
Error:(39, 38) type mismatch; found : edu.stanford.nlp.util.CoreMap => Unit required: java.util.function.Consumer[_ >: edu.stanford.nlp.util.CoreMap]
sentences.forEach( (s : CoreMap) => println("") )
^
What is the problem here? s
has a type given already.
Upvotes: 4
Views: 895
Reputation: 37852
You're using Java's forEach
(which indeed expects a java.util.function.Consumer
), did you mean Scala's foreach
? foreach
would work (if you import JavaConversions
):
import scala.collection.JavaConversions._
sentences.foreach( (s : CoreMap) => println("") )
Upvotes: 5