Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Synonym-Given String Expand / Collapse
Author
Message
Posted Monday, March 30, 2009 11:58 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 5, 2009 9:28 PM
Points: 9, Visits: 46
Hi All,


i need to find list of synonyms for a given string using sql server,is there a query to retrive list of synonyms for a given word ?
Post #686744
Posted Tuesday, March 31, 2009 5:16 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Thursday, April 19, 2012 10:25 PM
Points: 1,231, Visits: 3,483

HI,

Possible, when you create the table and store all the synonyms for the words

ARUN SAS
Post #686881
Posted Tuesday, March 31, 2009 5:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 5, 2009 9:28 PM
Points: 9, Visits: 46
Hi Arun ,

Thanks for ur reply, i need to find for (1000s of words) its not possible to find synonym for word by word and store it in a table ???? is it possible dynamically?

for example like built in Function) if we give the word it should generate its list of synonym... guide the query for this???
Post #686887
Posted Tuesday, March 31, 2009 8:12 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:24 PM
Points: 3,997, Visits: 6,049
Kavi, could you give us an example of what you are trying to do? Some sample inputs and expected output would be most helpful.

__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #687079
Posted Tuesday, March 31, 2009 9:29 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 5, 2009 9:28 PM
Points: 9, Visits: 46
Hi,

i have tried synonyms search with full text serach Thesaurus file, but it is needed to predefine the thesaurus file for each word, it is not feasible for me.So, i am looking for alternative option to find the synonyms search for the word.

For example: i need to find synonyms for any word for eg: the word "check" using sql query then the output should display all synonyms like the list below,

Try out
test
confirm
ensure
verify
prove
try


kindly help me with the query to execute this result...
Post #687603
Posted Tuesday, March 31, 2009 10:20 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:24 PM
Points: 3,997, Visits: 6,049
Kavi, such a query is simple, but you will still have to define the synonyms. You may be able to search the internet and find some sort of thesaurus file that you could download to populate a synonyms table in your database.

How do you plan to use this?

declare @synonyms table 
(rowID int identity (1,1), searchword varchar(20), synonymWord varchar(20)
primary key (searchword,rowid)
)
insert into @synonyms
select 'check','try out' union all
select 'check','test' union all
select 'check','confirm' union all
select 'check','ensure' union all
select 'check','verify' union all
select 'check','try' union all
select 'check','prove'

---------------------------------
select synonymWord
from @synonyms
where searchword = 'check'



__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #687614
Posted Tuesday, March 31, 2009 10:30 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, April 5, 2009 9:28 PM
Points: 9, Visits: 46
Thanks Bob,

Still i am trying to search for an pre-filled thesaurus file that defined synonym for all english words...so far not found,

so wat i tried with some alternate solution,but the query wic u gave doesnt suits me because for word by word i need to insert synonyms its very tedious to insert for whole dictionary ,is there any other way????
Post #687620
Posted Tuesday, March 31, 2009 10:33 PM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 4:12 PM
Points: 958, Visits: 1,031
kavi (3/30/2009)
Hi All,
i need to find list of synonyms for a given string using sql server,is there a query to retrive list of synonyms for a given word ?

Kavi,

This is not a feature built into SQL Server. It's one you would have to create programmatically. I suggest you go grab a copy of an English Language Thesaurus from your library. If you really want to sit down and encode all of that, then feel free.

So no, there is no query to retrieve a list of synonyms for a given word. Not unless you build one.
Post #687623
Posted Tuesday, March 31, 2009 10:47 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 10:24 PM
Points: 3,997, Visits: 6,049
Kavi, if you are looking to build your own thesaurus file, you can certainly parse a string of synonyms this way, to make the population easier. This technique could be modified to translate an entire table. If you have questions about this, there are some good articles and forum posts already written under the headings PARSE and TALLY TABLE.

I hate to leave you now, but it's midnight here and I have to get some sleep. I'll check back in about nine hours.

I hope this helps.

declare @synonyms table (rowID int identity (1,1), searchword varchar(20), synonymWord varchar(20)
primary key (searchword,rowid))

--------------------------------------------------------------
declare @synonym_list varchar(7900)
declare @sepChar varchar(50)
declare @element varchar(4)
declare @searchword varchar(20)
--------------------------------------------------------------
set @searchword = 'check'
set @synonym_list = 'try out, test, examine, confirm, verify'
set @sepchar = ','
set @synonym_list = @sepChar+@synonym_list+@sepChar
--------------------------------------------------------------
;WITH
L0 AS (SELECT 1 AS C UNION ALL SELECT 1), --2 rows
L1 AS (SELECT 1 AS C FROM L0 AS A, L0 AS B),--4 rows "L0 as A, L0 as B" is just shorthand way to code a cross join
L2 AS (SELECT 1 AS C FROM L1 AS A, L1 AS B),--16 rows
L3 AS (SELECT 1 AS C FROM L2 AS A, L2 AS B),--256 rows
L4 AS (SELECT 1 AS C FROM L3 AS A, L3 AS B),--65536 rows
Tally AS (SELECT TOP 1000 ROW_NUMBER() OVER(ORDER BY C) AS N FROM L4),
syns AS
(select Row_Number() over (order by N) as E,
ltrim(rtrim(substring(@synonym_list,N+1,charindex(@sepChar,@synonym_list,N+1)-(N+1)))) as synWord
from tally
where substring(@synonym_list,N,1) = @sepChar
and N < len(@synonym_list)
)
--
insert into @synonyms
select @searchword,synword from syns
----------------------------------------------
select *
from @synonyms
where searchword = 'check'






__________________________________________________

Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
Stop, children, what's that sound? -- Stephen Stills
Post #687626
Posted Thursday, April 2, 2009 2:43 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Tuesday, April 22, 2014 5:40 PM
Points: 209, Visits: 302
This is a multiple post. Some discussion has occured at http://www.sqlservercentral.com/Forums/Topic685529-145-1.aspx.

However, this discussion has developed further.
Post #689378
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse