Re: Counting the number of repeated phrases in a column

From: Shaozhong SHI <shishaozhong(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Counting the number of repeated phrases in a column
Date: 2022-01-26 20:35:06
Message-ID: CA+i5JwYRPVhZcpEJ2r2WQEL7t8tPE_4zVeTckU+gDgnrt_9wyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 25 Jan 2022 at 17:10, Shaozhong SHI <shishaozhong(at)gmail(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2022-01-26 20:55:06 Counting the number of repeated phrases in a column
Previous Message Mladen Gogala 2022-01-26 16:31:14 Could not serialize access due to concurrent update