Click to See Complete Forum and Search --> : urgent vbscript code
rajivg
Nov 16th, 2001, 10:20 AM
how do i compare names from a text file to the names from the database for a given id.
3. for eg JURY is in the text file = JURIES which is in the database, CATASTROPHE = CATASTROPHES
4. If found, output to “found but needs changing” list showing: “original term = Jury”, thesaurus term = “juries”
5. If not found, output to second list showing “not found in thesaurus”.
Please give me the code. it has to be written in vbscript.
thankyou in advance
rajiv
mlewis
Nov 16th, 2001, 04:52 PM
yeesh; that's a big job. You should probably have an extra field in the database so it looks like this:
TERM ALTERNATE
Jury juries
You can use LCase to make the comparison ignore capital/small letters.
rajivg
Nov 19th, 2001, 09:01 AM
thanks MLewis, this is the code i have written inorder to get the comparasions. from the text file and databse. but one slight problem . i dont know how to get the closest word for. in the text file the name can be Account and in the database it can be Accounts.
i am getting
accounts date
accounts periods which is not equal to accounts.
const ForReading = 1
function opentextfile(name, mode)
dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
Set opentextfile = fso.OpenTextFile(name, mode, false)
end function
'term searching
dim thesname
if wscript.arguments.count<>1 then
wscript.echo "USAGE listpolyterms <thesaurus name>"
wscript.quit(-1)
end if
dim api
set api = createobject("GCHierAPI.HierAPI")
dim ts
Set ts = api.TermSearch
dim strterm
dim strtermdb
dim x, y
set x = nothing
set mytextfile = opentextfile("d:\g_c\Freshfields Indexing Terms\termname.txt", ForReading)
dim rs
dim mystr1, mystr2, mycomp
dim bFound, szSimilar
do while mytextfile.atendofstream <> true
strterm = mytextfile.readline
wscript.echo "Original word """ & strterm & """"
bFound = false
szSimilar = ""
set rs = ts.ExpandedSearch (174,strterm,"","","",0,1)
while not rs.eof and not bFound
if strComp(strTerm, rs("name"), 0) = 0 then
wscript.echo " Exact match found in thesaurus."
bFound = true
elseif strComp(strTerm, rs("name"), 1) = 0 then
wscript.echo " Match found in thesaurus, but difference in case."
wscript.echo " Thesaurus term: """ + rs("name") + """"
bFound = true
end if
szSimilar = szSimilar + " " + rs("name") + vbcrlf
rs.movenext
wend
if not bFound then
wscript.echo " No match found in thesaurus."
wscript.echo " Similar terms in thesaurus are..."
if szSimilar = "" then
wscript.echo " [none]"
else
wscript.echo szSimilar
end if
end if
wscript.echo vbcrlf
set rs = nothing
mlewis
Nov 19th, 2001, 09:07 AM
Getting the closest matching word is a long and complex process. It takes a good bit of math and some strange ideas for it to work; wouldn't it be easier to have a list in the database that will do this for you?
If you only use a few words (less than about 10,000) that you have to have multiple forms of, just make a table like I said above. Its less work to do that than to write a dictionary; but if you use more than 10,000 words for this or if you need to recognize ANY word or its forms, than you will have to either write a dictionary of all words or you will have to write a mathematical algorithm to do a comparison.
The problem is that not all plurals end in "s" for example Mouse; the plural of Mouse is Mice, so you can't just see if the last letter is S to see if its plural or not.
Please let me know if this explains the situation clearly.
rajivg
Nov 19th, 2001, 09:32 AM
Thanks MLewis,
I have the understand. It will be a quiet a bit of mathemathical code in it which i am not good init.
I have spoken to my boss and he said ok how it is now.
I guess he understand the problem.
Appreciate your time.
Regards
rajiv
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.