gpt4 book ai didi

c# - 我如何逐字搜索(或获取)句子?

转载 作者:太空宇宙 更新时间:2023-11-03 22:06:22 27 4
gpt4 key购买 nike

我有一个词和文本。我必须找到所有包含该词的提案。你有什么想法吗?

piblic List<string> GetSnetences(string word)
{
// search all proposals that have the word
{

最佳答案

尝试做这样的事情:

var text =
"Here is some text. It has some sentences. There are a few sentences.";
var word = "SOME";

public List<String> GetSentences(String text, String word) {
var sentences =
text.Split(new[] { ". " }, StringSplitOptions.RemoveEmptyEntries);

var matches = from sentence in sentences
where sentence.ToLower().Contains(word.ToLower())
select sentence;

return matches.ToList();
}

最后,匹配项将是一个枚举,其中包含包含您要搜索的词的所有句子。

关于c# - 我如何逐字搜索(或获取)句子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8314944/

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