Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
- String texto = txt.getText();
- String impresion = "Palabras clave: ";
- String anadir = "";
- String anadir1 = "";
- ArrayList<String> palabras = new ArrayList();
- ArrayList<String> palabrasclave = new ArrayList();
- int n = 0;
- int longitudtexto = texto.length() - 1;
- if (texto.charAt(longitudtexto) != '.' || texto.charAt(longitudtexto) != ' ' || texto.charAt(longitudtexto) != ',') {
- texto += ".";
- }
- for (int x = 0; x < texto.length(); x++) {
- if (texto.charAt(x) == ' ' || texto.charAt(x) == '.' || texto.charAt(x) == ',') {
- palabras.add(anadir);
- anadir = "";
- } else {
- anadir += texto.charAt(x);
- }
- }
- for (int i = 0; i < palabras.size(); i++) {
- String palabraencuestion = palabras.get(i);
- for (int y = 0; y < palabras.size(); y++) {
- if (palabrasclave.contains(palabraencuestion)) {
- contiene = true;
- } else {
- contiene = false;
- }
- String palabra = palabras.get(y);
- if (palabraencuestion.equals(palabra) && i != y && contiene == false) {
- palabrasclave.add(palabraencuestion);
- }
- }
- }
- for (int y = 0; y < palabrasclave.size(); y++) {
- anadir1 += palabrasclave.get(y);
- if (y != 0 || y != palabrasclave.size()) {
- anadir1 += " - ";
- }
- }
- lbl.setText("Las palabras clave son: " + anadir1);
- }
Add Comment
Please, Sign In to add comment