Re: Counting the number of repeated phrases in a column

Поиск
Список
Период
Сортировка
Искать
От
benj.dev@laposte.net
Тема
Re: Counting the number of repeated phrases in a column
Дата
Msg-id
b1ab1a9f-bcd0-7630-ed2c-4d596bca3e19@laposte.net
Ответ на
Список
Дерево обсуждения
Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Re: Counting the number of repeated phrases in a column benj.dev@laposte.net
Re: Counting the number of repeated phrases in a column Ivan Panchenko <i.panchenko@postgrespro.ru>
Re: Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Re: Counting the number of repeated phrases in a column "Ivan E. Panchenko" <i.panchenko@postgrespro.ru>
Re: Counting the number of repeated phrases in a column Jian He <hejian.mark@gmail.com>
Re: Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Re: Counting the number of repeated phrases in a column Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Re: Counting the number of repeated phrases in a column Rob Sargent <robjsargent@gmail.com>
Counting the number of repeated phrases in a column "David G. Johnston" <david.g.johnston@gmail.com>
Re: Counting the number of repeated phrases in a column Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Counting the number of repeated phrases in a column Merlin Moncure <mmoncure@gmail.com>
Re: Counting the number of repeated phrases in a column Merlin Moncure <mmoncure@gmail.com>
Re: Counting the number of repeated phrases in a column Rob Sargent <robjsargent@gmail.com>
Re: Counting the number of repeated phrases in a column Merlin Moncure <mmoncure@gmail.com>
Re: Counting the number of repeated phrases in a column benj.dev@laposte.net
Re: Counting the number of repeated phrases in a column Merlin Moncure <mmoncure@gmail.com>
Re: Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Re: Counting the number of repeated phrases in a column "David G. Johnston" <david.g.johnston@gmail.com>
Aw: Counting the number of repeated phrases in a column Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Counting the number of repeated phrases in a column Shaozhong SHI <shishaozhong@gmail.com>
Aw: Re: Counting the number of repeated phrases in a column Karsten Hilbert <Karsten.Hilbert@gmx.net>
Re: Counting the number of repeated phrases in a column Laura Smith <n5d9xq3ti233xiyif2vp@protonmail.ch>
Le 25/01/2022 à 18:10, Shaozhong SHI a écrit :
> 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

Don't know if it's exactly what you want, but you can replace all 
occurence of the phrase in the text by empty string and compute the diff 
between the initial and the result and next divide by the length of your 
phrase.

Example :
WITH x AS (SELECT 'toto like tata and toto like titi and toto like tutu' 
, 'toto like' phrase)
SELECT (char_length(texte) - char_length(replace(texte, phrase, ''))) / 
char_length(phrase) AS nb_occurence
FROM x

В списке pgsql-general по дате отправления
От: Ben Chobot
Дата:
Сообщение: NIST 800-53v4 scanning?
От: Ivan Panchenko
Дата:
FAQ