Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7724391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:40:36+00:00 2026-06-01T04:40:36+00:00

I’m trying to make use of parallel processing with the wordnet package for R

  • 0

I’m trying to make use of parallel processing with the wordnet package for R on a Windows 7 computer. Specifically, I’m trying to find the synonyms for a list of nouns. I’ve made some sample code below to show what I’m trying to do, but it doesn’t seem to properly execute in parallel. It is starting up the workers, and it is calculating on one of the workers, but not the others.The list I’ve made below has a length of 4 with 4 words in each slot. I’m attempting to divide the list by the number of cores available and send a subset of the list to each core. Then the sapply function gets the synonyms for the 4 words (within the parallel loop). I’ve also tried doing this with Snowfall but I couldn’t get it to export the dictionary (sfExport didn’t seem to do it). I’m not using the “.export” within the foreach loop because it was also giving errors with the dictionary not being located, but putting it within the parallel loop seems to make it work. Any help would be much appreciated.

library(wordnet)
library(foreach)
library(doSMP)
library(rJava)

NbrOfCores <- 2

workers <- startWorkers(NbrOfCores) # number of cores
registerDoSMP(workers)
getDoParName() # check name of parallel backend
getDoParVersion() # check version of parallel backend
getDoParWorkers() # check number of workers
set.seed(1)

setDict<-setDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
initDict<-initDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
dict<-getDictInstance()

words <- list(c("cat", "dog", "bird"),c("mouse", "iguana", "fish"),c("car", "tree", "house"),c("shoe", "shirt", "hat"))

rows=length(words) #4
prow<-floor(rows/NbrOfCores) #2

nouns<-foreach(i=1:NbrOfCores, .combine = c, .packages ="wordnet","rJava") %dopar% {
setDict<-setDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
initDict<-initDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
dict<-getDictInstance()    
foreach(j=(prow*(i-1)+1):(prow*i)) %do% sapply(words[[j]],synonyms,"NOUN")}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:40:37+00:00Added an answer on June 1, 2026 at 4:40 am

    I think your problem is in how you setup the i variable in your foreach. What this should be looping through is the words object, not the number of cores. This code works:

    library(wordnet)
    library(foreach)
    # library(doSMP) # I don't think you want to use this package anymore.
    library(rJava)
    require(snow) # Add the snow packages
    require(doSNOW) 
    
    NbrOfCores <- 2
    cl.tmp = makeCluster(rep('localhost',NbrOfCores), type='SOCK')
    registerDoSNOW(cl.tmp)
    
    words <- list(c("cat", "dog", "bird"),c("mouse", "iguana", "fish"),c("car", "tree", "house"),c("shoe", "shirt", "hat"))
    
    foreach(words=iter(words), .packages='wordnet') %dopar% {
        setDict<-setDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
        initDict<-initDict("C:\\Program Files (x86)\\WordNet\\2.1\\dict\\")
        dict<-getDictInstance() 
        sapply(words,synonyms,pos='NOUN')
    }
    

    It looks like the doSMP packages isn’t available for my version of R, so I just switched it to snow, but you could use whatever backend you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
Specifically, suppose I start with the string string =hello \'i am \' me And
I am trying to render a haml file in a javascript response like so:
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.