gpt4 book ai didi

c# - 使用数组 c# 删除停用词

转载 作者:太空宇宙 更新时间:2023-11-03 21:20:47 24 4
gpt4 key购买 nike

我有一个停用词字符串数组和输入文本字符串数组,即

string[] stopWords = File.ReadAllLines(@"C:\stopWords.txt");

con.Open();
SqlCommand query = con.CreateCommand();
query.CommandText = "select p_abstract from aminer_paper where pid between 1 and 500 and DATALENGTH(p_abstract) != 0";

SqlDataReader reader = query.ExecuteReader();

var summary = new List<string>();
while(reader.Read())
{
summary.Add(reader["p_abstract"].ToString());
}

reader.Close();

string[] input_Texts = summary.ToArray();

现在,我必须使用这些 stopWords 数组从 input_Texts 数组中删除。我使用了以下技术但没有工作,在访问两个数组索引时很奇怪。例如,在 input_Texts 数组的索引 0 处获取第一个文本,即

input_Texts[0]

然后匹配stopWords数组中的所有词串即

// have to match all the indexes of stopWords[] with input_Texts[0]
stopWords[]

然后在从 input_Texts 数组的索引 0 文本中删除所有 stopWords 之后,必须对 input_Texts 数组中的所有文本重复它。

任何建议和经过修改的代码示例都将受到高度赞赏并予以确认。

谢谢。

最佳答案

试试这个:

string[] result = input_Texts.Except(stopWords).ToArray();

关于c# - 使用数组 c# 删除停用词,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30930153/

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