?
Solved

I need to find commonly used phrases in a text field in a SQL table (SQL 2008 R2)

Posted on 2014-11-12
6
Medium Priority
?
152 Views
Last Modified: 2014-11-13
I need to find commonly used phrases in a text field in a SQL table (SQL 2008 R2).  The text contain reports written by medical professionals. The output I would like is a listing of phrases in the text and how often they are used. For example, I would want the output to look something like this:
# of Occurrences  Phrase
120 - Continue with plan of care
119 - The patient complained of pain located
100 - Restrict lifting to a maximum of
..
...

I can run loops to find all of the length of phrases and dump phrases into a table and then query for a count of each one, but I know that will take a lot of time. Is there any way to do this more efficiently and faster?
0
Comment
Question by:loneieagle2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 40439689
Did you try? A pass-through should be quite fast:

    Select Count(*) From TheTable Where TheField Like '%Continue with plan of care%'

/gustav
0
 
LVL 1

Author Comment

by:loneieagle2
ID: 40439723
Gustav,

I guess my question wasn't clear. I don't know what the phrases are yet. So I have to analyze the text and determine what the phrases are and how often they are used. My idea was to find individual words (by parsing based on the spaces between words) and storing those in a table. Then go through and find two word phrases and drop them in the table, etc until I have the longest phrases. Then I can run the query you suggest. So since the average text field contains about 200 words and there are about a million records in the table, I would be making 200 million passes thru whatever method I use to extract the phrases.

Bob
0
 
LVL 51

Assisted Solution

by:Gustav Brock
Gustav Brock earned 750 total points
ID: 40439746
I see. I don't think there is a smart way doing this other than the method you describe.

If it is a one-time operation, you could write some loops and let them run overnight.

/gustav
0
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 
LVL 48

Accepted Solution

by:
Dale Fye earned 750 total points
ID: 40439899
I would agree with Gustav, if you knew what phrases were in use, you could save those phrases to a table, and then do a query against those specific phrases, but without first knowing what phrases, you would have to parse each record into 2, 3, 4, 5, .... word phrases, and save those to a table.  

This would be a very time consuming task involving loops through all of the records, and then loops for the length of the phrase (# of words), and the start point within each record, which would overlap.  A single record of only 10 words would have 45 possible "phrases" of 2-10 words in length.
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 40439909
@loneieagle2

Oops, I forgot to refresh the thread and didn't see your first response to Gustav before posting.
0
 
LVL 1

Author Closing Comment

by:loneieagle2
ID: 40439938
Thanks, I was hoping for something better, but it looks like what I call the "Sledge Hammer" method is going to be the best.

Dale,

I can use what you told me to find out pretty close to how many phrases I will be creating to see if it is even feasible.

Bob
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question