Giter Club home page Giter Club logo

Comments (5)

trinker avatar trinker commented on August 18, 2024

Dump everything out to temp rds and read back to the clusters...add a library arg

from sentimentr.

trinker avatar trinker commented on August 18, 2024

Initial attempts leads to error on Windows (parallel seems to be using an old version of R and throws an error with regard to Rcpp being the wrong version fixed this by using newer version of R on path but now an error related to sentimentr indicating still an old version???). Maybe need to remove all R from path??

if (!require("pacman")) install.packages("pacman")
pacman::p_load(sentimentr, parallel, textshape, dplyr)


chunk_size <- 1e5
dir.create('data')

dat <- combine_data() %>%
    {.[rep(seq_len(nrow(.)), 100),]} %>%
    sample_n(nrow(.)) %>%
    split_index({inds <- chunk_size * 1:round(nrow(.)/chunk_size, 0); inds[inds < nrow(.)]})

tic <- Sys.time()

cl <- makeCluster(mc <- getOption("cl.cores", detectCores() - 2))

clusterEvalQ(cl, {
    library(sentimentr)
    library(lexicon)
})


parLapply(cl, dat, function(x){

    gc()

    senti_dat <- sentimentr::get_sentences(x)
    senti_dat <- sentimentr::sentiment_by(senti_dat)

    outfile <- sprintf('data/file_%s.rds', sample(1:100000))
    saveRDS(senti_dat, outfile)

}) %>%
    invisible()

stopCluster(cl)

Sys.time() - tic

Results in:

Error in checkForRemoteErrors(val) : 
  6 nodes produced errors; first error: 'get_sentences' is not an exported object from 'namespace:sentimentr'

from sentimentr.

trinker avatar trinker commented on August 18, 2024

http://appliedpredictivemodeling.com/blog/2018/1/17/parallel-processing

Is either of the following a better way to run parallel code:

https://github.com/r-lib/callr
https://github.com/r-lib/processx

A OS independent solution is needed. Re investigate available solutions and reach out to the R community for current best practices.

from sentimentr.

trinker avatar trinker commented on August 18, 2024

Here's where I ask the R community: https://twitter.com/tylerrinker/status/1044364197797265408

from sentimentr.

bkmgit avatar bkmgit commented on August 18, 2024

Some other packages:

from sentimentr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.