我有一个单词列表和一个句子列表。我想知道在which 中可以找到哪些句子。
下面是我的代码:
List<string> sentences = new List<string>();
List<string> words = new List<string>();
sentences.Add("Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae, aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.");
sentences.Add("Alea iacta est.");
sentences.Add("Libenter homines id, quod volunt, credunt.");
words.Add("est");
words.Add("homines");
List<string> myResults = sentences
.Where(sentence => words
.Any(word => sentence.Contains(word)))
.ToList();
我需要的是一个元组列表。在句子中找到的句子和单词。
https://stackoverflow.com/questions/56426412
复制相似问题