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 866863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:52:46+00:00 2026-05-15T09:52:46+00:00

I am working on a small project which involves a dictionary based text searching

  • 0

I am working on a small project which involves a dictionary based text searching within a collection of documents. My dictionary has positive signal words (a.k.a good words) but in the document collection just finding a word does not guarantee a positive result as there may be negative words for example (not, not significant) that may be in the proximity of these positive words. I want to construct a matrix such that it contains the document number,positive word and its proximity to negative words.

Can anyone please suggest a way to do that. My project is at a very very early stage so I am giving a basic example of my text.

No significant drug interactions have been reported in studies of candesartan cilexetil given with other drugs such as glyburide, nifedipine, digoxin, warfarin, hydrochlorothiazide.   

This is my example document in which candesartan cilexetil, glyburide, nifedipine, digoxin, warfarin, hydrochlorothiazide are my positive words and no significant is my negative word. I want to do a proximity (word based) mapping between my positive and nevative words.

Can anyone give some helpful pointers?

  • 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-05-15T09:52:47+00:00Added an answer on May 15, 2026 at 9:52 am

    First of all I would suggest not to use R for this task. R is great for many things, but text manipulation is not one of those. Python could be a good alternative.

    That said, if I were to implement this in R, I would probably do something like (very very rough):

    # You will probably read these from an external file or a database
    goodWords <- c("candesartan cilexetil", "glyburide", "nifedipine", "digoxin", "blabla", "warfarin", "hydrochlorothiazide")
    badWords <- c("no significant", "other drugs")
    
    mytext <- "no significant drug interactions have been reported in studies of candesartan cilexetil given with other drugs such as glyburide, nifedipine, digoxin, warfarin, hydrochlorothiazide."
    mytext <- tolower(mytext) # Let's make life a little bit easier...
    
    goodPos <- NULL
    badPos <- NULL
    
    # First we find the good words
    for (w in goodWords)
        {
        pos <- regexpr(w, mytext)
        if (pos != -1)
            {
            cat(paste(w, "found at position", pos, "\n"))
            }
        else    
            {
            pos <- NA
            cat(paste(w, "not found\n"))
            }
    
        goodPos <- c(goodPos, pos)
        }
    
    # And then the bad words
    for (w in badWords)
        {
        pos <- regexpr(w, mytext)
        if (pos != -1)
            {
            cat(paste(w, "found at position", pos, "\n"))
            }
        else    
            {
            pos <- NA
            cat(paste(w, "not found\n"))
            }
    
        badPos <- c(badPos, pos)
        }
    
    # Note that we use -badPos so that when can calculate the distance with rowSums
    comb <- expand.grid(goodPos, -badPos)
    wordcomb <- expand.grid(goodWords, badWords)
    dst <- cbind(wordcomb, abs(rowSums(comb)))
    
    mn <- which.min(dst[,3])
    cat(paste("The closest good-bad word pair is: ", dst[mn, 1],"-", dst[mn, 2],"\n"))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a small design project, part of which involved writing out text
I'm working on a project which will deliver small pieces of text to a
I'm working on a small project that involves grabbing a list of contacts which
Im working on a small project which has a textarea and i need help
I have been working with a small project recently which involves Struts 2 and
I'm working on a small C++ project which involves a launcher application that does
I am working on a small project for learning PHP better. This project has
I'm working on a small project that involves me loading an image into a
Im working on a small project which I need to send a couple of
I have a small project I am working on which is WPF c# that

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.