accent and index server : one solution
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Web Servers reviews > IIS server support > IIS Index Server > accent and index server : one solution




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    accent and index server : one solution  
darrieu


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
07-22-04 07: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
%>





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:15 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register