从Wos文本数据中获取摘要进行分析的一种方法

namespace 清理数据
{
    class Program
    {
        static void Main(string[] args)
        {
            string strDirName = "File";
            int iWriteFlag = 0;
            if (Directory.Exists(strDirName))
            {
                string[] strFiles = Directory.GetFiles(strDirName);

                foreach (var item in strFiles)
                {
                    using (var streamReader = File.OpenText(Path.Combine(Directory.GetCurrentDirectory(), item)))
                    {
                        var lines = streamReader.ReadToEnd().Split("\r\n".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < lines.Length; i++)
                        {
                            if (lines[i].StartsWith("AB "))
                            {
                                iWriteFlag = 1;
                            }
                            if (iWriteFlag == 1)
                            {
                                File.AppendAllText("abstractFile.txt", Regex.Replace(lines[i], "[ ]{2,}", " ", RegexOptions.None));
                            }
                            if (lines[i].StartsWith("ZR "))
                            {
                                iWriteFlag = 0;
                                File.AppendAllText("abstractFile.txt", "\r\n");
                            }
                            Console.WriteLine(Math.Round(i*1.0 / lines.Length,2));
                        }
                    }

                }
            }

            Console.Write("Done");
            Console.ReadKey();
        }
    }
}

转载于:https://www.cnblogs.com/zhulinmails/p/9209314.html

你可能感兴趣的:(从Wos文本数据中获取摘要进行分析的一种方法)