gpt4 book ai didi

java - 如何将 List 与 String 进行比较?

转载 作者:行者123 更新时间:2023-12-01 16:20:57 25 4
gpt4 key购买 nike

我目前有这个代码:

    private boolean checkWildcardFilter(String contentStripped, GuildTransformer guild) {
String words = contentStripped.toLowerCase();
List <String> badWordsList = replace(guild.getBadWordsWildcard());
System.out.println("UWords: " + words);
System.out.println("FWords: " + badWordsList);

return words.stream().anyMatch(badWordsList::equals);
}

在示例中,applehi 应该被过滤

我想要它做的是检查句子“我会和我的新hire一起去吃一个大苹果。”。无论“apple”和“hi”在句子中的哪个位置,它都需要找到单词“apple”和“hi”。如果找到它,它应该过滤

它是用 Java 编写的,这些单词来自数据库:database entry

它解码为:(一些脏话)

["***", "***", "***", "***"]

最佳答案

我认为您需要的是检查字符串是否包含任何字符序列。

如果来自数据库,您将需要使用适当的查询/数据库连接/等来检索您想要的数据。

如果关键字已加密,您将必须对其进行解密。有几个解密库,你只需要知道你在说“什么”语言

正如 @Clashsoft 提到的,您试图在这里解决很多问题。建议将它们分成 3 个,以便您提出非常客观的问题。

对于字符串位置,您可以使用此依赖项:

Apache Utils

可以在类似问题上找到更多详细信息:

How do I check if a string contains a list of characters?

关于java - 如何将 List<String> 与 String 进行比较?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62282598/

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