Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

value foldLeft is not a member of (String, Seq[String]) #23

Closed
Deepak-Vohra opened this issue Feb 27, 2015 · 4 comments
Closed

value foldLeft is not a member of (String, Seq[String]) #23

Deepak-Vohra opened this issue Feb 27, 2015 · 4 comments

Comments

@Deepak-Vohra
Copy link

Ch 6, the following code snippet generates an error.

import scala.collection.mutable.HashMap
val docTermFreqs = lemmatized.map(terms => {
val termFreqs = terms.foldLeft(new HashMap[String, Int]()) {
(map, term) => {
map += term -> (map.getOrElse(term, 0) + 1)
map
}
}
termFreqs
})

The error is

<console>:64: error: value foldLeft is not a member of (String, Seq[String])
       val termFreqs = terms.foldLeft(new HashMap[String, Int]()) {
@srowen
Copy link
Collaborator

srowen commented Feb 27, 2015

You should use back-ticks to format code; I edited it above. This is basically the same thing, you're using a lemmatized that was not also created according to the listing in the book.

@srowen srowen closed this as completed Feb 27, 2015
@Deepak-Vohra
Copy link
Author

The lemmatized is not from the repo either. The error is generated with the following lemmatized from repo.

val lemmatized = plainText.mapPartitions(iter => {
      val pipeline = createNLPPipeline()
      iter.map{ case(title, contents) => (title, plainTextToLemmas(contents, stopWords, pipeline))}
    })

@srowen
Copy link
Collaborator

srowen commented Feb 27, 2015

Same answer as before. I think you understand the issue right?

@Deepak-Vohra
Copy link
Author

Yes, the lemmatized is not defined properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants