Thread: Compare strings which resembles each other

Compare strings which resembles each other

From
Gulshan Babajee
Date:
Hy, I have a table containing some rows. Each row contains a field name
which is of type String.

For example:
in row1 string1 is "Adieu Poulet",
in row2 string2 is "Adieu a Poulet",
in row3 string3 is "Adiue Poulet",
in row4 string4 is "Adieu Pouleet", etc..
(That is each string resembles each other a bit, they are somewhat similar
to each other)

What type of query should I make so as it return me all these string. That
is I watn a query which return me strings which are similar or somewhat
similar to each other.

thanks in advance
gulshan


Re: Compare strings which resembles each other

From
Christoph Haller
Date:
> 
> Hy, I have a table containing some rows. Each row contains a field name
> which is of type String.
> 
> For example:
> in row1 string1 is "Adieu Poulet",
> in row2 string2 is "Adieu a Poulet",
> in row3 string3 is "Adiue Poulet",
> in row4 string4 is "Adieu Pouleet", etc..
> (That is each string resembles each other a bit, they are somewhat similar
> to each other)
> 
> What type of query should I make so as it return me all these string. That
> is I watn a query which return me strings which are similar or somewhat
> similar to each other.
> 
> thanks in advance
> gulshan
> 
$PGSQLD/contrib/tsearch/README.tsearch 
is your friend. 

Regards, Christoph 



Re: Compare strings which resembles each other

From
Oleg Bartunov
Date:
On Fri, 21 Nov 2003, Christoph Haller wrote:

> >
> > Hy, I have a table containing some rows. Each row contains a field name
> > which is of type String.
> >
> > For example:
> > in row1 string1 is "Adieu Poulet",
> > in row2 string2 is "Adieu a Poulet",
> > in row3 string3 is "Adiue Poulet",
> > in row4 string4 is "Adieu Pouleet", etc..
> > (That is each string resembles each other a bit, they are somewhat similar
> > to each other)
> >
> > What type of query should I make so as it return me all these string. That
> > is I watn a query which return me strings which are similar or somewhat
> > similar to each other.
> >
> > thanks in advance
> > gulshan
> >
> $PGSQLD/contrib/tsearch/README.tsearch
> is your friend.

I think tsearch(2) isn't what Gulshan need. He needs fuzzy search,
there are several modules in contrib directory (metaphone, fuzzystrmatch).
Also, we have trgm module which uses trigram and has index support.


>
> Regards, Christoph
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
>       subscribe-nomail command to majordomo@postgresql.org so that your
>       message can get through to the mailing list cleanly
>
Regards,    Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83


cast varchar to numeric/money

From
"Yudie"
Date:
Hi guys,

I know it's impossible to just cast varchar to any numeric datatype,
but is there another function/ custom function or any way to force to do
that convertion.

please help

Thanks..

Yudie



Re: cast varchar to numeric/money

From
Bruno Wolff III
Date:
On Fri, Nov 21, 2003 at 11:47:42 -0600, Yudie <yudie@axiontech.com> wrote:
> Hi guys,
> 
> I know it's impossible to just cast varchar to any numeric datatype,
> but is there another function/ custom function or any way to force to do
> that convertion.

You can use to_number to go from text to numeric.


Re: cast varchar to numeric/money

From
"Yudie"
Date:
I don't have to_numeric function in my 7.2.2 postgre.
then it can resolve it with: 

cast(substr(varcharcolumn,0) as float4)

thanks.



----- Original Message ----- 
From: "Bruno Wolff III" <bruno@wolff.to>
To: "Yudie" <yudie@axiontech.com>
Cc: <pgsql-sql@postgresql.org>
Sent: Friday, November 21, 2003 11:55 AM
Subject: Re: [SQL] cast varchar to numeric/money


On Fri, Nov 21, 2003 at 11:47:42 -0600, Yudie <yudie@axiontech.com> wrote:
> Hi guys,
> 
> I know it's impossible to just cast varchar to any numeric datatype,
> but is there another function/ custom function or any way to force to do
> that convertion.

You can use to_number to go from text to numeric.



Re: cast varchar to numeric/money

From
Tomasz Myrta
Date:
Dnia 2003-11-21 19:26, Użytkownik Yudie napisał:
> I don't have to_numeric function in my 7.2.2 postgre.
> then it can resolve it with: 
> 
> cast(substr(varcharcolumn,0) as float4)

Read once again. The function is not "to_numeric", but "to_number".
You can read about this function in manual:
6.7. Data Type Formatting Functions

Regards,
Tomasz Myrta



Re: Compare strings which resembles each other

From
Ian Barwick
Date:
On Friday 21 November 2003 15:32, Oleg Bartunov wrote:
> On Fri, 21 Nov 2003, Christoph Haller wrote:

> > $PGSQLD/contrib/tsearch/README.tsearch
> > is your friend.
>
> I think tsearch(2) isn't what Gulshan need. He needs fuzzy search,
> there are several modules in contrib directory (metaphone, fuzzystrmatch).
> Also, we have trgm module which uses trigram and has index support.

Hi Oleg,

do you have any more information on trgm? According to your
website it isn't released. I am looking for something along those lines
and might be able to assist, at least with testing and documentation.

Ian Barwick
barwick@gmx.net



Re: Compare strings which resembles each other

From
Oleg Bartunov
Date:
On Fri, 21 Nov 2003, Ian Barwick wrote:

> On Friday 21 November 2003 15:32, Oleg Bartunov wrote:
> > On Fri, 21 Nov 2003, Christoph Haller wrote:
>
> > > $PGSQLD/contrib/tsearch/README.tsearch
> > > is your friend.
> >
> > I think tsearch(2) isn't what Gulshan need. He needs fuzzy search,
> > there are several modules in contrib directory (metaphone, fuzzystrmatch).
> > Also, we have trgm module which uses trigram and has index support.
>
> Hi Oleg,
>
> do you have any more information on trgm? According to your
> website it isn't released. I am looking for something along those lines
> and might be able to assist, at least with testing and documentation.

It's don't released because of lack of documentation :( It's tested and
used in production. I'll send you archive in separate message.


>
> Ian Barwick
> barwick@gmx.net
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
>
Regards,    Oleg
_____________________________________________________________
Oleg Bartunov, sci.researcher, hostmaster of AstroNet,
Sternberg Astronomical Institute, Moscow University (Russia)
Internet: oleg@sai.msu.su, http://www.sai.msu.su/~megera/
phone: +007(095)939-16-83, +007(095)939-23-83