文章相似性检测程序

上传人:F****n 文档编号:99254895 上传时间:2019-09-18 格式:DOCX 页数:10 大小:89.75KB
返回 下载 相关 举报
文章相似性检测程序_第1页
第1页 / 共10页
文章相似性检测程序_第2页
第2页 / 共10页
文章相似性检测程序_第3页
第3页 / 共10页
文章相似性检测程序_第4页
第4页 / 共10页
文章相似性检测程序_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《文章相似性检测程序》由会员分享,可在线阅读,更多相关《文章相似性检测程序(10页珍藏版)》请在金锄头文库上搜索。

1、这是我自己用C#写的一个程序,用来检测多篇文档之间是否具有相似性(篇数上限为50)。这个程序还有一些bug和未知的错误。注释也写的比较混乱,但是现在起码是可以基本运行的,所以我就上传过来了。注意:输入的文档必须是TXT 格式,且采用的是相同的编码方式。这个程序的一个优点是,除了可以检测文档之间的相关性之外,还可以用来识别图片,音乐,视频等任何文件的相似性。这部分的实现我将稍后完成,代码中的问题我也将进行优化,敬请关注。Program.cs中的代码是:using System;using System.Collections.Generic;using System.ComponentModel

2、;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Text;using System.Collections;namespace 文章相似度检测程序 static class Program / / 应用程序的主入口点。 / STAThread static void Main() Application.EnableVisualStyles(); Application.SetCo

3、mpatibleTextRenderingDefault(false); Application.Run(new Form1(); String, sx = new String0, 0; public class ceshi public static string file1 = 123; public static int cout = 0; /设置上传的文章数 public static string linshi = ; public static double M = 13; /设置检测连续字节数,默认为13 public static string jieguo = ; publ

4、ic static int cout2 = 0; /相似部分计数 Form.cs中的代码是:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.IO;using System.Text;using System.Collections;namespace 文章相似度检测程序

5、 public partial class Form1 : Form public Form1() InitializeComponent(); private void label1_Click(object sender, EventArgs e) private void label1_Click_1(object sender, EventArgs e) String, strp2 = new String60,6000 ; Double mm = new Double51; String, strp3 = new String6000, 6000; int, xiangsi = ne

6、w int100, 100; public void upFile_Click(object sender, EventArgs e) OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; fileDialog.Title = 请选择文件; fileDialog.Filter = 所有文件(*.*)|*.*; if (fileDialog.ShowDialog() = DialogResult.OK) string file = fileDialog.FileName; ceshi.fi

7、le1 = file; MessageBox.Show(上传成功: + file, 选择文件提示, MessageBoxButtons.OK, MessageBoxIcon.Information); sysm sysm1 = new sysm(); ceshi.cout+; /显示已上传文章数 string cout1 = ceshi.cout.ToString(); textBox1.Text = cout1; int i = 0; String path = ceshi.file1; string path1 = path.Replace(, ); int pi = ceshi.cout

8、; /第几篇文章 using (FileStream Fsread = new FileStream(path1, FileMode.OpenOrCreate, FileAccess.Read) byte b = new byteFsread.Length; string s = ; Double p = 0; ArrayList al = new ArrayList(); while (true) int r = Fsread.Read(b, 0, b.Length); if (r = 0) break; s += Encoding.UTF8.GetString(b, 0, b.Length

9、); String, strp = new String50, b.Length; for (i = 0; i b.Length; i+) strppi, i = bi.ToString(); mmpi+; for (i =0; i b.Length; i+) strp2pi, i = strppi, i; private void Form1_Load(object sender, EventArgs e) private void button3_Click(object sender, EventArgs e) sysm sysm1 = new sysm(); sysm1.ShowDialog(); private void button2_Click(object sender, EventArgs e) int kk = ceshi.cout; for (int i = 1; i kk+1; i+) shengcheng(i); /生成指定长度的字符串数组 int k = ceshi.cout; textBox1.Text = strp2k, 5; for (int i = 1; i k; i+) /对每一个文章调用f函数 for (int j = i+1; j k + 1; j+) f(i, j); j+; for (int i = 1; ikk +1; i+)

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 教学/培训

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号