gpt4 book ai didi

postgresql - 在 postgresql 中删除停用词而不阻止

转载 作者:行者123 更新时间:2023-11-29 11:23:58 25 4
gpt4 key购买 nike

我想从我的数据中删除停用词,但我不想阻止这些词,因为确切的词对我很重要。我使用了这个查询。

SELECT to_tsvector('english',colName)from tblName order by lower asc;

有什么方法可以在不阻止单词的情况下删除停用词?

谢谢

最佳答案

创建您自己的文本搜索字典和配置:

CREATE TEXT SEARCH DICTIONARY simple_english
(TEMPLATE = pg_catalog.simple, STOPWORDS = english);

CREATE TEXT SEARCH CONFIGURATION simple_english
(copy = english);
ALTER TEXT SEARCH CONFIGURATION simple_english
ALTER MAPPING FOR asciihword, asciiword, hword, hword_asciipart, hword_part, word
WITH simple_english;

它是这样工作的:

SELECT to_tsvector('simple_english', 'many an ox eats the houses');
┌─────────────────────────────────────┐
│ to_tsvector │
├─────────────────────────────────────┤
│ 'eats':4 'houses':5 'many':1 'ox':3 │
└─────────────────────────────────────┘
(1 row)

您可以将参数 default_text_search_config 设置为 simple_english 以使其成为您的默认文本搜索配置。

关于postgresql - 在 postgresql 中删除停用词而不阻止,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42052173/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com