From: Rob Sargent <robjsargent@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Counting the number of repeated phrases in a column
Date: Wed, 26 Jan 2022 14:40:07 -0700
Message-ID: <7f204b3c-3224-f8cb-a841-879f57ebf120@gmail.com> (raw)
In-Reply-To: <CA+i5JwYRPVhZcpEJ2r2WQEL7t8tPE_4zVeTckU+gDgnrt_9wyw@mail.gmail.com>
References: <CA+i5Jwa5j2m4q6ARt_1U=bWz5=cRqPqqSJ38mYwaP2XF0k_WNg@mail.gmail.com>
<CA+i5JwYRPVhZcpEJ2r2WQEL7t8tPE_4zVeTckU+gDgnrt_9wyw@mail.gmail.com>
On 1/26/22 13:35, Shaozhong SHI wrote:
>
>
> On Tue, 25 Jan 2022 at 17:10, Shaozhong SHI <shishaozhong@gmail.com>
> wrote:
>
> There is a short of a function in the standard Postgres to do the
> following:
>
> It is easy to count the number of occurrence of words, but it is
> rather difficult to count the number of occurrence of phrases.
>
> For instance:
>
> A cell of value: 'Hello World' means 1 occurrence a phrase.
>
> A cell of value: 'Hello World World Hello' means no occurrence of
> any repeated phrase.
>
> But, A cell of value: 'Hello World World Hello Hello World' means
> 2 occurrences of 'Hello World'.
>
> 'The City of London, London' also has no occurrences of any
> repeated phrase.
>
> Anyone has got such a function to check out the number of
> occurrence of any repeated phrases?
>
> Regards,
>
> David
>
>
> Hi, All Friends,
>
> Whatever. Can we try to build a regex for 'The City of London
> London Great London UK ' ?
>
> It could be something like '[\w\s]+[\s-]+[a-z]+[\s-][\s\w]+'.
> [\s-]+[a-z]+[\s-] is catered for some people think that 'City of
> London' is 'City-of-London' or 'City-of-London'.
>
> Regards,
>
> David
Do you really want "The City of", by itself, to be one of the detected
phrases? eg 'The City of London London Great London UK The City of
Liverpool'.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: robjsargent@gmail.com
Subject: Re: Counting the number of repeated phrases in a column
In-Reply-To: <7f204b3c-3224-f8cb-a841-879f57ebf120@gmail.com>
References: <CA+i5Jwa5j2m4q6ARt_1U=bWz5=cRqPqqSJ38mYwaP2XF0k_WNg@mail.gmail.com> <CA+i5JwYRPVhZcpEJ2r2WQEL7t8tPE_4zVeTckU+gDgnrt_9wyw@mail.gmail.com> <7f204b3c-3224-f8cb-a841-879f57ebf120@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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