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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:48:46+00:00 2026-05-24T10:48:46+00:00

We have a large document of text (stored in a MSSQL database) and we

  • 0

We have a large document of text (stored in a MSSQL database) and we need to provide dictionary like lookups for words when they are hovered over.

For instance if there was the following sentence:
“The quick dog jumped over the brown fox” our users could create a “definition” for any of those words such as “quick”, “dog”, “jumped over” etc and we need to highlight such text and when they mouseover provide the text that has been set in the definition.

Currently we have an implementation that does the job however it suffers from incredible bad performance, the current implementation uses Regex to parse the text and insert a snippet of Javascript right after the word in the text if it matches a definition. Now seeings as we can have anywhere up to 400 or more definitions and the text can be several paragraphs long or more this hangs the entire server and makes the app non-repsonsive.

I have tried to optimise the code by fiddling with compiled regex but it doesn’t help the problem much, the request still times out before returning anything.

I’m curious as to what other options I have to achieve this.

I have considered:

  • Writing a service that sits in the background and polls the
    definitions and updates the text at idle times
  • Some form of caching, however this isn’t really going to fix the root
    cause of the problem and beings as the site wont load at all the page
    probably wont get cached
  • Implementing the regex client side, I think the page would load then
    but I doubt doing this client side would be any better than doing it
    server side it may even lock up the browser

The app is an ASP.NET website (.net 3.5 currently moving to 4 soonish), using SQL Server 2005/8 (depending on client site) and NHibernate.

  • 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-24T10:48:47+00:00Added an answer on May 24, 2026 at 10:48 am

    Just throwing out ideas:

    • Regex would require each word to be scanned for, which would take too long.
    • Compound words would require insane processing, unless it was handled in tiers.

    Possible algorithm:

    • Split the text into an array of strings: text[]
    • Store the defined words in memory (just the words): words[]
      • Use System.Collections.Generic.HashSet since it has a really fast lookup
    • Go through each text[] and tag it with a <span class='known'> if it is in words[]
    • On the front end, use AJAX when the mouseover occurs

    To handle compound words:

    • Use regex for this. There shouldn’t be too many compound words. If there are, then you can see which words[] exist before doing a regex search for the compound word.

    AJAX mouseover event:

    • After the tagging logic is complete, you may have span tags that are nested: <span class='known'><span class='known'>house</span> plan</span>, which is fine. Your jQuery will send the outermost span tag to the server and the server can return all the words that are matched.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some document stored as a large String. In the String I have
I have a v. large text document (no file extension) that has information about
I have two very large(30000+ documents) collections, one contains words extracted from a text
I have a large document with code samples in. I want to know the
I have a large xml document that needs to be processed 100 records at
I have quite a large XSL document for an assignment that does a number
I have a Flex application that calls a function which searches a large document
I have a large table I want to include in a LaTeX document. It
I am constructing a large HTML document from fragments supplied by users that have
I have a fairly large script and am trying to find out, why $(document).on(

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.