从sql数据库中读取文件并比较字符串以获得两个字符串的百分比相似性 [英] read file from sql database and compare string to get percentage similarity of two string
本文介绍了从sql数据库中读取文件并比较字符串以获得两个字符串的百分比相似性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道如何在vb6中读取sql数据库然后比较两个字符串来获取文件之间的百分比相似度?我是vb6的新手,所以我不知道如何开始编码。有人可以帮帮我吗?
解决方案
你可能想要这个: http://en.wikipedia.org/wiki/Levenshtein_distance [ ^ ]
这里有很多关于从数据库中读取的文章,只是环顾四周。
您好b $ b
您应该阅读并学习这篇文章。
http://www.dreamincode.net/论坛/主题/ 24677-connecting-to-a-sql-server-database-using-adodb / [ ^ ]
然后实现你的代码o连接vb6应用程序和Sql服务器。
和两个字符串之间的百分比相似性代码如下。
dim numMatch as 整数 = 0
dim numNotMatch as integer = 0
dim numCharLargestString as integer = 0
dim strFirstLength as integer
dim strSecondLength as integer
dim cou nter as integer
dim 百分比 as double
dim LoopControl as integer
dim str1 as string
dim str2 as string
strFirstLength = str1.Length()
strSecondLength = str2.Length()
if strFirstLength> strSecondLength
loopControl = strSecondLength - 1
numCharLargestString = strFirstLength
else LoopControl = strFirstLength - 1
numCharLargestString = strSecondLength
endif
for counter = 0 到 LoopControl
if (string1(counter).compareTo(string2(i)= 0
numMatch ++
else numNotMatch ++
end 如果
next
percentage = numMatch / numCharLargestString
hi, i want to know how to read sql database in vb6 and then compare two string to get the percentage similarity between the file? i am new to vb6 so i dont know how to start the coding..could someone please help me?
解决方案
You might want this: http://en.wikipedia.org/wiki/Levenshtein_distance[^]
And there are plenty or articles about reading from a database on here, just look around.
Hi
You should read and learn this article.
http://www.dreamincode.net/forums/topic/24677-connecting-to-a-sql-server-database-using-adodb/[^]
Then implement your code to connect vb6 application and Sql server.
And code for percentage similarity between two strings as below.
dim numMatch as integer = 0 dim numNotMatch as integer = 0 dim numCharLargestString as integer = 0 dim strFirstLength as integer dim strSecondLength as integer dim counter as integer dim percentage as double dim LoopControl as integer dim str1 as string dim str2 as string strFirstLength = str1.Length() strSecondLength = str2.Length() if strFirstLength > strSecondLength loopControl = strSecondLength - 1 numCharLargestString= strFirstLength else LoopControl = strFirstLength - 1 numCharLargestString= strSecondLength endif for counter = 0 to LoopControl if (string1(counter).compareTo(string2(i) = 0 numMatch ++ else numNotMatch ++ end if next percentage = numMatch/numCharLargestString
这篇关于从sql数据库中读取文件并比较字符串以获得两个字符串的百分比相似性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文