Results 1 to 5 of 5

Thread: urgent vbscript code

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    17

    urgent vbscript code

    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
    Regards
    Rajiv

  2. #2
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    yeesh; that's a big job. You should probably have an extra field in the database so it looks like this:

    Code:
    TERM          ALTERNATE
    Jury          juries
    You can use LCase to make the comparison ignore capital/small letters.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    17
    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
    Regards
    Rajiv

  4. #4
    Frenzied Member mlewis's Avatar
    Join Date
    Sep 2000
    Posts
    1,226
    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.
    M. Lewis
    Pi-Q Software
    How many mouse clicks does it take to cook breakfast?

    Blargh! I am dead!

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Nov 2001
    Posts
    17
    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
    Regards
    Rajiv

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width