IIS Index Server - accent and index server : one solution

This is Interesting: Free IT Magazines  
Home > Archive > IIS Index Server > July 2004 > accent and index server : one solution





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author accent and index server : one solution
darrieu

2004-07-22, 2:49 am

Hi,

I'm french (sorry for that and sorry for my english) and i'm using
index server but having a problem with accents in query. For example a
query "teste" doesn't return "testé". I know we are a lot in this case
and microsoft ignores us, that's why i'm a posting a code that works
for me.
This function takes a word in entry and returns its combinaisons. For
example : for the word "teste" it returns :
teste,téste,tèste,tëste,têste,
testé,tésté,tèsté,tësté,têsté,
testè,téstè,tèstè,tëstè,têstè,
testë,téstë,tèstë,tëstë,têstë,
testê,téstê,tèstê,tëstê,têstê,
Then you can search for all these words and be sure that you will
return all the results you expect.

You can easily adapt to other language (spanish with ~ or german with
umlaut,...).

The combinaisons are returned in array (tabret) but you can use a
string if you want ! And the word " OR " may be a separator (you know
wwhat i mean).

<%
'-----------------------------here it is---------------------
dim tabret()
dim taba(3)
dim tabe(4)
dim tabi(2)
dim tabo(2)
dim tabu(3)
dim tabc(1)
dim i
i=0
taba(0)="a"
taba(1)="à"
taba(2)="â"
taba(3)="ä"

tabe(0)="e"
tabe(1)="é"
tabe(2)="è"
tabe(3)="ê"
tabe(4)="ë"

tabi(0)="i"
tabi(1)="ï"
tabi(2)="î"

tabo(0)="o"
tabo(1)="ô"
tabo(2)="Ö"

tabu(0)="u"
tabu(1)="ù"
tabu(2)="ü"
tabu(3)="û"

tabc(0)="c"
tabc(1)="ç"

sub rempAcc(chaine,pos)
dim letab
dim pos1,posa,pose,posi,poso,posu,posc
dim modif,modif1,modif2

Dim regEx, Match, Matches ' Create variable.
Set regEx = New RegExp ' Create a regular expression.
regEx.Pattern = "[aàâä]|[eéèêë]|[iîï]|[oôö]|[uùûü]|[cç]"
regEx.IgnoreCase = True ' Set case insensitivity.
regEx.Global = True ' Set global applicability.
Set Matches = regEx.Execute(chaine) ' Execute search.
j=0
For Each Match in Matches ' Iterate Matches collection.
if pos=j then
pos1=Match.FirstIndex
gauche=left(chaine,pos1)
droite=right(chaine,len(chaine)-pos1-1)

'what do we find ? use the right replacement
select case match.value
case "a","à","â","ä" : letab=taba
case "e","é","è","â","ä" : letab=tabe
case "i","î","ï" : letab=tabi
case "o","î","ï" : letab=tabo
case "u","ù","û","ü" : letab=tabu
case "c","ç" : letab=tabc
end select

'decline all the possibilities
for m=0 to ubound(letab)
modif2 = gauche + letab(m) + droite
call rempAcc(modif2,pos+1)
next
end if
j=j+1
Next

'at the end we save the form (no other possibility)
if pos=j then
redim preserve tabret(i)
tabret(i)=chaine
i=i+1
end if
end sub
%>
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com