pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: Improving docs for strict_word_similarity()
4+ messages / 2 participants
[nested] [flat]

* Re: Improving docs for strict_word_similarity()
@ 2018-06-01 15:39  Alexander Korotkov <aekorotkov@gmail.com>
  0 siblings, 2 replies; 4+ messages in thread

From: Alexander Korotkov @ 2018-06-01 15:39 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-docs@postgresql.org, Teodor Sigaev <teodor@sigaev.ru>

Hi, Bruce!

On Sat, May 26, 2018 at 7:56 PM Bruce Momjian <bruce@momjian.us> wrote:

> While creating the release notes, I was confused by the description for
> strict_word_similarity(), particularly "extent boundaries".  The
> attached patch clarifies, at least for me, how word_similarity() and
> strict_word_similarity() differ.
>

Thank you for your efforts on improving documentation of pg_trgm.
However, I don't find all of them correct.  I've following notes regarding
the edits you propose.

--- 112,119 ----
        </entry>
        <entry><type>real</type></entry>
        <entry>
!        Same as <function>word_similarity(text, text)</function>, but
!        considers the set of trigrams to be of the same length.
        </entry>
       </row>
       <row>

This doesn't look a correct description.  In
short, strict_word_similarity() is searching
for extent of words in the second string, which is best match for the first
string.
So, this function takes care about using whole words from the second
strings,
not parts of words.  However, this is not matter of length of trigrams sets.

--- 164,182 ----
     This function returns a value that can be approximately understood as
the
     greatest similarity between the first string and any substring of the
second
     string.  However, this function does not add padding to the boundaries
of
!    the extent.  Thus, the number of additional characters present in the
!    second string is not considered, except for the mismatched word
boundry.
    </para>

This looks correct for me.

!    The function <function>strict_word_similarity(text, text)</function>
!    does consider additional characters in the second string.  In the
!    example above, <function>strict_word_similarity(text, text)</function>
!    would use the full trigram for the second string when computing
!    similarity, not just the part of the trigram that matches the
!    first string. For example, it would use the <literal>{" w","
!    wo","wor","ord","rds","ds "}</literal>, which corresponds to the whole
!    word <literal>'words'</literal>.

After your edits, it looks like strict_word_similarity() matches full
set of first string trigrams to full set of second string trigrams.
However,
this is description of just similarity() function.  Actually,
strict_word_similarity() matches set of trigrams of first string to
set of trigrams of conjuncted subset of second string words.

--- 189,197 ----

    <para>
     Thus, the <function>strict_word_similarity(text, text)</function>
function
!    is useful for finding the similarity to whole words, while
     <function>word_similarity(text, text)</function> is more suitable for
!    finding the similarity for parts of words.
    </para>

This also looks correct to me.

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Improving docs for strict_word_similarity()
@ 2018-06-12 18:08  Alexander Korotkov <aekorotkov@gmail.com>
  parent: Alexander Korotkov <aekorotkov@gmail.com>
  1 sibling, 0 replies; 4+ messages in thread

From: Alexander Korotkov @ 2018-06-12 18:08 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-docs@postgresql.org, Teodor Sigaev <teodor@sigaev.ru>

On Fri, Jun 1, 2018 at 6:39 PM Alexander Korotkov <aekorotkov@gmail.com> wrote:
> On Sat, May 26, 2018 at 7:56 PM Bruce Momjian <bruce@momjian.us> wrote:
>>
>> While creating the release notes, I was confused by the description for
>> strict_word_similarity(), particularly "extent boundaries".  The
>> attached patch clarifies, at least for me, how word_similarity() and
>> strict_word_similarity() differ.
>
>
> Thank you for your efforts on improving documentation of pg_trgm.
> However, I don't find all of them correct.  I've following notes regarding
> the edits you propose.
>
> --- 112,119 ----
>         </entry>
>         <entry><type>real</type></entry>
>         <entry>
> !        Same as <function>word_similarity(text, text)</function>, but
> !        considers the set of trigrams to be of the same length.
>         </entry>
>        </row>
>        <row>
>
> This doesn't look a correct description.  In short, strict_word_similarity() is searching
> for extent of words in the second string, which is best match for the first string.
> So, this function takes care about using whole words from the second strings,
> not parts of words.  However, this is not matter of length of trigrams sets.
>
> --- 164,182 ----
>      This function returns a value that can be approximately understood as the
>      greatest similarity between the first string and any substring of the second
>      string.  However, this function does not add padding to the boundaries of
> !    the extent.  Thus, the number of additional characters present in the
> !    second string is not considered, except for the mismatched word boundry.
>     </para>
>
> This looks correct for me.
>
> !    The function <function>strict_word_similarity(text, text)</function>
> !    does consider additional characters in the second string.  In the
> !    example above, <function>strict_word_similarity(text, text)</function>
> !    would use the full trigram for the second string when computing
> !    similarity, not just the part of the trigram that matches the
> !    first string. For example, it would use the <literal>{" w","
> !    wo","wor","ord","rds","ds "}</literal>, which corresponds to the whole
> !    word <literal>'words'</literal>.
>
> After your edits, it looks like strict_word_similarity() matches full
> set of first string trigrams to full set of second string trigrams.  However,
> this is description of just similarity() function.  Actually,
> strict_word_similarity() matches set of trigrams of first string to
> set of trigrams of conjuncted subset of second string words.
>
> --- 189,197 ----
>
>     <para>
>      Thus, the <function>strict_word_similarity(text, text)</function> function
> !    is useful for finding the similarity to whole words, while
>      <function>word_similarity(text, text)</function> is more suitable for
> !    finding the similarity for parts of words.
>     </para>
>
> This also looks correct to me.

I've edited places, which looked incorrect for me.  I tried to do my
best in making them as clear as possible.  Bruce, could you please
take a look on them?

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

Attachments:

pg-trgm-doc-2.patch (application/octet-stream, 2.3K) download diff --git a/doc/src/sgml/pgtrgm.sgml b/doc/src/sgml/pgtrgm.sgml index be43cdf299..42e24268af 100644 --- a/doc/src/sgml/pgtrgm.sgml +++ b/doc/src/sgml/pgtrgm.sgml @@ -113,7 +113,10 @@ <entry><type>real</type></entry> <entry> Same as <function>word_similarity(text, text)</function>, but forces - extent boundaries to match word boundaries. + extent boundaries to match word boundaries. Since we don't have + cross-word trigrams, this function actually returns greatest similarity + between first string and any continuous extent of words of the second + string. </entry> </row> <row> @@ -164,16 +167,16 @@ This function returns a value that can be approximately understood as the greatest similarity between the first string and any substring of the second string. However, this function does not add padding to the boundaries of - the extent. Thus, a whole word match gets a higher score than a match with - a part of the word. + the extent. Thus, the number of additional characters present in the + second string is not considered, except for the mismatched word boundry. </para> <para> At the same time, <function>strict_word_similarity(text, text)</function> - has to select an extent that matches word boundaries. In the example above, + selects extent of words in the second string. In the example above, <function>strict_word_similarity(text, text)</function> would select the - extent <literal>{" w"," wo","wor","ord","rds","ds "}</literal>, which - corresponds to the whole word <literal>'words'</literal>. + extent of single word <literal>'words'</literal>, whose set of trigrams is + <literal>{" w"," wo","wor","ord","rds","ds "}</literal> <programlisting> # SELECT strict_word_similarity('word', 'two words'), similarity('word', 'words'); @@ -186,9 +189,9 @@ <para> Thus, the <function>strict_word_similarity(text, text)</function> function - is useful for finding similar subsets of whole words, while + is useful for finding the similarity to whole words, while <function>word_similarity(text, text)</function> is more suitable for - searching similar parts of words. + finding the similarity for parts of words. </para> <table id="pgtrgm-op-table">
^ permalink raw reply [nested|flat] 4+ messages in thread

* Re: Improving docs for strict_word_similarity()
@ 2018-06-13 14:57  Bruce Momjian <bruce@momjian.us>
  parent: Alexander Korotkov <aekorotkov@gmail.com>
  1 sibling, 1 reply; 4+ messages in thread

From: Bruce Momjian @ 2018-06-13 14:57 UTC (permalink / raw)
  To: Alexander Korotkov <aekorotkov@gmail.com>; +Cc: pgsql-docs@postgresql.org, Teodor Sigaev <teodor@sigaev.ru>

On Fri, Jun  1, 2018 at 06:39:11PM +0300, Alexander Korotkov wrote:
> Hi, Bruce!
> 
> On Sat, May 26, 2018 at 7:56 PM Bruce Momjian <bruce@momjian.us> wrote:
> 
>     While creating the release notes, I was confused by the description for
>     strict_word_similarity(), particularly "extent boundaries".  The
>     attached patch clarifies, at least for me, how word_similarity() and
>     strict_word_similarity() differ.
> 
> 
> Thank you for your efforts on improving documentation of pg_trgm.
> However, I don't find all of them correct.  I've following notes regarding
> the edits you propose.

Yes, I realize my version was wrong.  Yours looks much better and adds
what is needed.  Thanks.

-- 
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

+ As you are, so once was I.  As I am, so you will be. +
+                      Ancient Roman grave inscription +




^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Improving docs for strict_word_similarity()
@ 2018-06-13 15:36  Alexander Korotkov <aekorotkov@gmail.com>
  parent: Bruce Momjian <bruce@momjian.us>
  0 siblings, 0 replies; 4+ messages in thread

From: Alexander Korotkov @ 2018-06-13 15:36 UTC (permalink / raw)
  To: Bruce Momjian <bruce@momjian.us>; +Cc: pgsql-docs@postgresql.org, Teodor Sigaev <teodor@sigaev.ru>

On Wed, Jun 13, 2018 at 5:57 PM Bruce Momjian <bruce@momjian.us> wrote:
> On Fri, Jun  1, 2018 at 06:39:11PM +0300, Alexander Korotkov wrote:
> > On Sat, May 26, 2018 at 7:56 PM Bruce Momjian <bruce@momjian.us> wrote:
> >
> >     While creating the release notes, I was confused by the description for
> >     strict_word_similarity(), particularly "extent boundaries".  The
> >     attached patch clarifies, at least for me, how word_similarity() and
> >     strict_word_similarity() differ.
> >
> >
> > Thank you for your efforts on improving documentation of pg_trgm.
> > However, I don't find all of them correct.  I've following notes regarding
> > the edits you propose.
>
> Yes, I realize my version was wrong.  Yours looks much better and adds
> what is needed.  Thanks.

Pushed, thanks!

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2018-06-13 15:36 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-06-01 15:39 Re: Improving docs for strict_word_similarity() Alexander Korotkov <aekorotkov@gmail.com>
2018-06-12 18:08 ` Alexander Korotkov <aekorotkov@gmail.com>
2018-06-13 14:57 ` Bruce Momjian <bruce@momjian.us>
2018-06-13 15:36   ` Alexander Korotkov <aekorotkov@gmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox