Re: Overcoming Initcap Function limitations?
От | Greg Sabino Mullane |
---|---|
Тема | Re: Overcoming Initcap Function limitations? |
Дата | |
Msg-id | CAKAnmmKhepxPzLWiU2JMNWsNiwLmQAyKCgV-f2dMot1hKVa-hA@mail.gmail.com обсуждение исходный текст |
Ответ на | Overcoming Initcap Function limitations? (Bo Guo <bo.guo@gisticinc.com>) |
Ответы |
Re: Overcoming Initcap Function limitations?
|
Список | pgsql-sql |
It's not clear exactly what you are trying to achieve, but you can use Postgres' built-in text searching system to exclude stopwords. For example:
CREATE FUNCTION initcap_realword(myword TEXT)
returns TEXT language SQL AS
$$
SELECT CASE WHEN length(to_tsvector(myword)) < 1
THEN myword ELSE initcap(myword) END;
$$;
You could extend that to multi-word strings with a little effort. However, knowing that macdonald should be MacDonald requires a lot more intelligence than is provided by any Postgres built-in system or extension that I know of. What you are looking at is the field of science known as Natural Language Processing, which can get very complex very quickly. But for a Postgres answer, you might combine plpython3u with spacy (https://spacy.io/usage/spacy-101).
Cheers,
Greg
В списке pgsql-sql по дате отправления: