Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Alessancost

sistema tradutor Inglês/Português

Recommended Posts

Olá pessoal;

 

Eu tenho um sistema tradutor Inglês/Português. Quando eu digito day ele tras todas as palavras que contem day ( everyday, nowadays, birthday... ) Eu quero que somente apareça a palavra exata. Também gostaria de ter um campo com todas as vogais e consoantes que quando uma é selecionada, aparece uma lista com todas as palavras com a inicial selecionada

 

ex: site

 

O meu código tradutor

 

ASP

[*]<% Dim strURL  

 

[*]  Dim cnnSearch 

 

[*]  Dim rstSearch

 

[*]  Dim strDBPath

 

[*]  Dim strSQL

 

[*]  Dim strSearch

 

[*]

 

[*]  '#Função que tira todos os acentos das palavras

 

[*]  function TiraAcento(StrAcento)

 

[*]  for i = 1 to len(StrAcento) 

 

[*] Letra mid(StrAcento, i, 1)

 

[*]  Select Case Letra

 

[*]  Case "á","Á","à","À","ã","Ã","â","Â","â","ä","Ä"

 

[*] Letra "A"

 

[*]  Case "é","É","ê","Ê","Ë","ë","È","è"

 

[*] Letra "E"

 

[*]  Case "í","Í","ï","Ï","Ì","ì"

 

[*] Letra "I"

 

[*]  Case "ó","Ó","ô","Ô","õ","Õ","ö","Ö","ò","Ò"

 

[*] Letra "O"

 

[*]  Case "ú","Ú","Ù","ù","ú","û","ü","Ü","Û"

 

[*] Letra "U"

 

[*]  Case "ç","Ç"

 

[*] Letra "C"

 

[*]  Case "ñ"

 

[*] Letra "N"

 

[*] End Select

 

[*] texto = texto & Letra

 

[*] next

 

[*] TiraAcento = texto

 

[*] end function 

 

[*]

 

[*] strURL Request.ServerVariables("URL")

 

[*] strSearch Request.QueryString("search"%>

 

[*]

 

[*]

 

[*]<table width="43%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#F2FFF2">

 

[*]<tr>

 

[*] <td><table width="100%" border="0" cellspacing="2" cellpadding="2">

 

[*]<tr>

 

[*] <td bgcolor="#FFFFFF"><p align="center"><FONT color=royalblue face=Tahoma size=2><STRONG><font color="#000033">:: 

 

[*] Tradutor Inglês/Português/Português/Inglês 

 

[*] ::</font></STRONG></FONT></p>

 

[*] <form action="<%= strURL %>" method="get">

 

[*] <div align="center"

 

[*] <input name="search" value="<%= strSearch %>" />

 

[*] <input name="submit" type="submit" value="Pesquisar" />

 

[*] </div>

 

[*] </form>

 

[*]

 

[*] <p align="center"

 

[*] <% If strSearch <> "" Then

 

[*] strDBPath Server.MapPath("dic.mdb")

 

[*]  Const adUseClient = 3

 

[*]  Set cnnSearch Server.CreateObject("ADODB.Connection")

 

[*] cnnSearch.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"

 

[*] cnnSearch.CursorLocation = adUseClient

 

[*]

 

[*]

 

[*] strSQL "SELECT PALAVRA, TRADUCAO " _

 

[*] & "FROM dic_English " _

 

[*] & "WHERE PALAVRA LIKE '%" & TiraAcento(Replace(strSearch, "'""''")) & "%' " _

 

[*] & "OR TRADUCAO LIKE '%" & TiraAcento(Replace(strSearch, "'""''")) & "%' " _

 

[*] & "ORDER BY TRADUCAO;"

 

[*]

 

[*]  Set rstSearch cnnSearch.Execute(strSQL)

 

[*] intContador rstSearch.RecordCount %>

 

[*]

 

[*] </p></td>

 

[*] </tr>

 

[*] </table>

 

[*] <p align="center"><br>

 

[*] <font size="1" face="Verdana, Arial, Helvetica, sans-serif">[ Foram encontradas <b><%=intContador%></b> 

 

[*] ocorrências ] </font> </p>

 

[*] <div align="center">

 

[*] <table width="312" border="0" cellpadding="4" cellspacing="1" bgcolor="#F3F3F3">

 

[*]<tr><th width="79" bgcolor="#FF6600"> <FONT color=royalblue face=Tahoma size=2><STRONG> <font color="#FFFFFF">:: 

 

[*]  Inglês ::</font></STRONG></FONT></th><th width="157" bgcolor="#FF6600"> <div align="center"> <FONT color=royalblue face=Tahoma size=2><STRONG>

 

[*]<font color="#FFFFFF"> ::Português ::</font></STRONG> </FONT></div> </th></tr>

 

[*] <% Do While Not rstSearch.EOF %>

 

[*] <tr> 

 

[*] <td bgcolor="#FFFFE6"> <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%rstSearch.Fields("PALAVRA").Value %> </font></td>

 

[*] <td bgcolor="#FFFFE6">

 

[*] <div align="center"> <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><%rstSearch.Fields("TRADUCAO").Value %></font></div></td>

 

[*] </tr>

 

[*]

 

[*] <% rstSearch.MoveNext

 

[*]  Loop %>

 

[*]  

 

[*] </table>

 

[*]

 

[*] <%  rstSearch.Close

 

[*]  Set rstSearch = Nothing

 

[*]  cnnSearch.Close

 

[*]  Set cnnSearch = Nothing

 

[*]  End If %>

 

[*]  

 

[*] </div></td>

 

[*] </tr>

 

[*]</table>

 

Obrigado

Compartilhar este post


Link para o post
Compartilhar em outros sites

Se quer a palavra exata, não use o Like %% em sua SQL, ficaria assim:

ASP
  1. strSQL "SELECT PALAVRA, TRADUCAO " _
     
  2. "FROM dic_English " _
     
  3. "WHERE PALAVRA = '" & TiraAcento(Replace(strSearch, "'""''")) & "' " _
     
  4. "OR TRADUCAO = '" & TiraAcento(Replace(strSearch, "'""''")) & "' " _
     
  5. "ORDER BY TRADUCAO;"

Já para selecionar pela 1ª você pode passar por parâmetro e usar na SQL: Left(campo,1)

Compartilhar este post


Link para o post
Compartilhar em outros sites

se for para pegar o que começa com o texto

 

ASP

    [*]strSQL "SELECT PALAVRA, TRADUCAO " _

     

    [*] & "FROM dic_English " _

     

    [*] & "WHERE PALAVRA LIKE '" & TiraAcento(Replace(strSearch, "'""''")) & "%' " _

     

    [*] & "OR TRADUCAO LIKE '" & TiraAcento(Replace(strSearch, "'""''")) & "%' " _

     

    [*] & "ORDER BY TRADUCAO;"

     

    [*]

 

é só tirar os % da frente da palavra buscada e deixar o de tras...

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.