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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:53:27+00:00 2026-06-14T23:53:27+00:00

Thanks for amazingly quick response. Stackoverflow is awesome! I need to check if a

  • 0

Thanks for amazingly quick response. Stackoverflow is awesome!

I need to check if a word (or rather thousands of them) is matching a dict containing keywords.

For example, say I have a string: "The fluffy fox jumped the friggin fence." I need to check each word of the string against a dict of keywords, and if there’s a match, return all values.

I’ve created a dict filters: (uniqueid means ie. “lk2m3lk4m2”, rest is ‘static’.)

filters:
        { "fox" : [
                    { 'subscription' : 'uniqueid', 'link' : 'uniqueid' },
                    { 'subscription' : 'uniqueid', 'link' : 'uniqueid' }
                  ]},

        { "fence" : [
                      { 'subscription' : 'uniqueid', 'link' : 'uniqueid' }
                    ]}

…and plan to iterate over filters for each word in string (and I have to do this with perhaps 5000 words / second. In other words, performance is the issue ABOVE ALL.

The number of filter-keywords may grow to thousands, while the strings will never be more than a normal sentence long (ie. 5-20 words). I’ll therefore iterate over each word in the string and check if it’s contained in the filter-list. However, at 500 sentences / second, I’m still looking at a lot of computation.

Is it possible to sort the list (ie. the key of dict’s in list) and thus drastically improve performance, for example? And are there C-implementations I should use (like I’m using cjson with great performance gain)?

Sorry for the somewhat fluid question — but how should I go about this task?

Edit:

Expected input:
"The fluffy fox jumped the friggin fence."

Expected output:
{ 'subscription' : 'flskdmfslk32232', 'link' : 'sfdksmfls22323' },
{ 'subscription' : '3023940fsdf', 'link' : 'sdflsfm223' }

(ie. the subscriptions listed under each matching keyword.)

  • 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-14T23:53:29+00:00Added an answer on June 14, 2026 at 11:53 pm

    You can determine if a word is a key in filters by simply by doing filters.has_key(word) or by doing:

    subscriptions = filters.get(word)
    if subscriptions is not None:
        pass # TODO do something with subscriptions
    

    or:

    try:
        subscriptions = filters[word]
        # TODO do something with subscriptions
    except:
        pass # probably don't need to do anything if not present
    

    It isn’t necessary to iterate over each entry in filters. Rather you will want to split your input string, add each word to a Set (to eliminate duplicates), and then iterate over your set to look up each word in your filters dictionary.

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

Sidebar

Related Questions

Thanks in advance for your help. I have a need within an application to
First I want to say thanks to everyone that reads this. Stackoverflow is an
Thanks for the help on here with my query on here the other day
Thanks for stopping by. this static analyser warning is annoying me here is my
Thanks to the epic work of Dennis Williamson, I am now able to calculate
Thanks for reading this. I have no idea why this is throwing a NullReferenceException
Thanks in advance to anyone who can think of a more efficient or a
Thanks to some help I received yesterday I've got some dynamic summing working on
thanks for your reading. I am trying to modify Jquery Nivo Zoom plugin to
Thanks to the brilliant help on my XML parsing problem I got to a

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.