commit d0f145070fcf5bb8467831b76e3f5a336d8f5d09 Author: structix Date: Mon May 16 15:22:44 2016 +0200 Initial commit diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..96cc43e --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..e7bedf3 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/description.html b/.idea/description.html new file mode 100644 index 0000000..db5f129 --- /dev/null +++ b/.idea/description.html @@ -0,0 +1 @@ +Simple Java application that includes a class with main() method \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..ee12254 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..11a2cd1 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/project-template.xml b/.idea/project-template.xml new file mode 100644 index 0000000..1f08b88 --- /dev/null +++ b/.idea/project-template.xml @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 0000000..814571d --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,737 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + DEFINITION_ORDER + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + project + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1463223891566 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Beispieltext.txt b/Beispieltext.txt new file mode 100644 index 0000000..6df0b25 --- /dev/null +++ b/Beispieltext.txt @@ -0,0 +1,3 @@ +Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. + +Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, diff --git a/Test.txt b/Test.txt new file mode 100644 index 0000000..b011f24 --- /dev/null +++ b/Test.txt @@ -0,0 +1,7 @@ +Hallo Welt +Test +asd +asd +asd +asd +asdf diff --git a/Textanalyse.iml b/Textanalyse.iml new file mode 100644 index 0000000..d5c0743 --- /dev/null +++ b/Textanalyse.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/out/production/Textanalyse/com/structix/Analyse.class b/out/production/Textanalyse/com/structix/Analyse.class new file mode 100644 index 0000000..4b47a6f Binary files /dev/null and b/out/production/Textanalyse/com/structix/Analyse.class differ diff --git a/out/production/Textanalyse/com/structix/Main.class b/out/production/Textanalyse/com/structix/Main.class new file mode 100644 index 0000000..76b53ad Binary files /dev/null and b/out/production/Textanalyse/com/structix/Main.class differ diff --git a/out/production/Textanalyse/com/structix/Menu.class b/out/production/Textanalyse/com/structix/Menu.class new file mode 100644 index 0000000..e29bef8 Binary files /dev/null and b/out/production/Textanalyse/com/structix/Menu.class differ diff --git a/out/production/Textanalyse/com/structix/Menubuilder.class b/out/production/Textanalyse/com/structix/Menubuilder.class new file mode 100644 index 0000000..161c6ec Binary files /dev/null and b/out/production/Textanalyse/com/structix/Menubuilder.class differ diff --git a/src/com/structix/Analyse.java b/src/com/structix/Analyse.java new file mode 100644 index 0000000..0843a99 --- /dev/null +++ b/src/com/structix/Analyse.java @@ -0,0 +1,100 @@ +package com.structix; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Scanner; + +/** + * Created by structix on 14.05.16. + */ + + +public class Analyse { + + private String inhalt = ""; + private String woerterGesamt[]; + private String einzelneWoerter[]; + + public Analyse(String dateipfad) { + inhalt = dateilesen(dateipfad); + textAnpassen(); + } + + + private String dateilesen(String dateipfad) { + Scanner datei; + String text = ""; + + try { + datei = new Scanner(new File(dateipfad)); + text = datei.useDelimiter("\\Z").next(); + datei.close(); + } catch (FileNotFoundException ex) { + ex.getLocalizedMessage(); + } + + return text; + } + + + public void textAnpassen() { + String verarbeitung; + verarbeitung = inhalt.replace("\n\n", ""); + verarbeitung = verarbeitung.replace("\n", " "); + woerterGesamt = verarbeitung.split(" "); + } + + public int laenge() { + return woerterGesamt.length; + } + + + public int verschiedenWoerter() { + String tempArray[] = new String[woerterGesamt.length]; + boolean vorhanden; + int tempbelegt = 0; + for (int i = 0; i < woerterGesamt.length; i++) { + vorhanden = false; + for (int z = 0; z < tempArray.length; z++) { + if (woerterGesamt[i].equals(tempArray[z])) { + vorhanden = true; + } + } + if (!vorhanden) { + tempArray[tempbelegt] = woerterGesamt[i]; + tempbelegt++; + } + } + einzelneWoerter = new String[tempbelegt]; + for (int i = 0; i < tempbelegt; i++) { + einzelneWoerter[i] = tempArray[i]; + + } + return tempbelegt; + } + + public String haeufigkeit() { + int anzahl[] = new int[einzelneWoerter.length]; + for (int i = 0; i < anzahl.length; i++) { + anzahl[i] = 0; + } + + for (int i = 0; i < woerterGesamt.length; i++) { + for (int z = 0; z < einzelneWoerter.length; z++) { + if (woerterGesamt[i].equals(einzelneWoerter[z])) { + anzahl[z] += 1; + } + } + } + String ausgabe = ""; + for (int i = 0; i < anzahl.length; i++) { + ausgabe += einzelneWoerter[i] + ": " + anzahl[i] + "\n"; + } + return ausgabe; + } + + public String textausgabe() { + return inhalt; + } + +} diff --git a/src/com/structix/Main.java b/src/com/structix/Main.java new file mode 100644 index 0000000..2a0f0d8 --- /dev/null +++ b/src/com/structix/Main.java @@ -0,0 +1,24 @@ +package com.structix; + + +/* Funktionen: + * Einen Text aus einer Datei lesen und nach folgenden Kriterien analysieren: + * - Wörter zählen + * - Anzahl der verschiedenen Wörter im Text + * - Die häufigst verwendeten Wörter + * + */ + +/* Bearbeitungszeit + * 14.05.16: 13:04 - 14:08 Uhr + * 15.05.16: 20:41 - 21:38 Uhr + */ + +public class Main { + + public static void main(String[] args) { + Menu m = new Menu(); + m.dateipfad(); + while (!m.hauptmenu()); + } +} diff --git a/src/com/structix/Menu.java b/src/com/structix/Menu.java new file mode 100644 index 0000000..0dd0bb4 --- /dev/null +++ b/src/com/structix/Menu.java @@ -0,0 +1,45 @@ +package com.structix; + +import java.util.Scanner; + +/** + * Created by structix on 15.05.16. + */ +public class Menu { + + Menubuilder mbuilder = new Menubuilder("Textanalyse"); + Analyse an; + + + public void dateipfad() { + System.out.println("Geben Sie einen Dateipfad an (relativ sowie absolut erlaubt): "); + Scanner eingabe = new Scanner(System.in); + an = new Analyse(eingabe.nextLine()); + } + + public boolean hauptmenu() { + boolean exit = false; + int auswahl = 0; + auswahl = mbuilder.menuAnzeigen(new String[]{"Anzahl der Wörter", "Anzahl der verschiedenen Wörter", "Häufigkeit der verschiedene Wörter"}); + switch (auswahl) { + case 1: + ausgabe("Anzahl der Wörter: " + an.laenge()); + break; + case 2: + ausgabe("Verschiedene Wörter: " + an.verschiedenWoerter()); + break; + case 3: + ausgabe(an.haeufigkeit()); + break; + default: + exit = true; + break; + } + return exit; + } + + private void ausgabe(String eing) { + System.out.println(eing); + } + +} diff --git a/src/com/structix/Menubuilder.java b/src/com/structix/Menubuilder.java new file mode 100644 index 0000000..d132e8b --- /dev/null +++ b/src/com/structix/Menubuilder.java @@ -0,0 +1,50 @@ +package com.structix; + +import java.util.InputMismatchException; +import java.util.Scanner; + +/** + * Created by structix on 15.05.16. + */ +public class Menubuilder { + + private String ueberschrift; + private Scanner eingabe = new Scanner(System.in); + + public Menubuilder(String title) { + ueberschrift = title; + } + + public int menuAnzeigen(String items[]) { + + String ausgabe = ""; + ausgabe += ueberschrift + "\n"; + int eing = 0; + for (int i = 0; i < items.length; i++) { + ausgabe += items[i] + ": (" + (i + 1) + ")\n"; + } + ausgabe += "Exit (" + (items.length + 1) + ")\n"; + do { + System.out.print(ausgabe + "\nEingabe: "); + eing = eingabeInt(); + } while (eing <= 0 || eing > items.length + 1); + return eing; + } + + private String eingabeString() { + return eingabe.nextLine(); + } + + private int eingabeInt() { + int input = 0; + try { + input = eingabe.nextInt(); + } catch (Exception ex) { + ex.getLocalizedMessage(); + input = 0; + } + return input; + } + + +}