|
|
|
![]() |
|
Strumenti |
![]() |
#1 |
Senior Member
Iscritto dal: Nov 2003
Città: Bari
Messaggi: 388
|
[Java]accenno di controllo ortografico
sto cercando di fare una specie di controllo ortografico:
dato il testo "a" e il testo "b" devo controntare che il testo "b" contenga tutte parole esistenti nel testo "b". Ho crecato di lavorare con vettori, ma non riescoa capire perchè non funziona! Vi allego il codice che ho scritto import java.io.*; import java.util.*; public class provolone { public static void main(String[] args) throws IOException { String nextStr = null; BufferedReader filebuf = new BufferedReader(new FileReader("c:\\ortografia.txt")); nextStr = filebuf.readLine(); StringTokenizer st = new StringTokenizer(nextStr); int numero = st.countTokens(); String[] vett_orto = new String[numero]; int i = 0; while (st.hasMoreTokens()) { vett_orto[i] = st.nextToken(); i++; } String nextStr2 = null; BufferedReader filebuf2 = new BufferedReader(new FileReader("c:\\scrivimi.txt")); nextStr2 = filebuf2.readLine(); StringTokenizer st2 = new StringTokenizer(nextStr2); int numeros = st2.countTokens(); String[] vett_sorg = new String[numeros]; int j = 0; while (st2.hasMoreTokens()) { vett_sorg[j] = st2.nextToken(); j++; } int s = 0; String[] vett = new String[vett_sorg.length]; /*boolean non_trovata = true; for (int k = 0; k < vett_sorg.length; ++k) { for (int t=0; t < vett_orto.length; ++t) { non_trovata = true; if (vett_sorg[k].compareToIgnoreCase(vett_orto[t])==0) { non_trovata = false; break; } } if (non_trovata = true) { vett[s] = vett_sorg[k]; ++s; } }*/ int k=0; boolean consentita = false; for( k=0; k<vett_sorg.length; k++) { for(int t=0; t<vett_orto.length; t++) if(vett_sorg[k].compareToIgnoreCase(vett_orto[t])==0) { consentita = true; break; } } if(consentita = false) { System.out.println("La parola " + vett_sorg[k] + " non è consentita!"); } consentita = false; } }
__________________
|Prescott 630@3900(260x15)|Gigabyte 915p duo|2X512 v-data ddr400@430 |Ati radeon x800 @ x850xt|Ali 500w| |Ho concluso con --> Sebyweb, ciccillover, scriba,anttrs,HARDCANO| |
![]() |
![]() |
![]() |
Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 22:47.