From d0f145070fcf5bb8467831b76e3f5a336d8f5d09 Mon Sep 17 00:00:00 2001 From: structix Date: Mon, 16 May 2016 15:22:44 +0200 Subject: [PATCH] Initial commit --- .idea/compiler.xml | 22 + .idea/copyright/profiles_settings.xml | 3 + .idea/description.html | 1 + .idea/misc.xml | 50 ++ .idea/modules.xml | 8 + .idea/project-template.xml | 3 + .idea/workspace.xml | 737 ++++++++++++++++++ Beispieltext.txt | 3 + Test.txt | 7 + Textanalyse.iml | 12 + .../Textanalyse/com/structix/Analyse.class | Bin 0 -> 2708 bytes .../Textanalyse/com/structix/Main.class | Bin 0 -> 563 bytes .../Textanalyse/com/structix/Menu.class | Bin 0 -> 1910 bytes .../com/structix/Menubuilder.class | Bin 0 -> 1765 bytes src/com/structix/Analyse.java | 100 +++ src/com/structix/Main.java | 24 + src/com/structix/Menu.java | 45 ++ src/com/structix/Menubuilder.java | 50 ++ 18 files changed, 1065 insertions(+) create mode 100644 .idea/compiler.xml create mode 100644 .idea/copyright/profiles_settings.xml create mode 100644 .idea/description.html create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/project-template.xml create mode 100644 .idea/workspace.xml create mode 100644 Beispieltext.txt create mode 100644 Test.txt create mode 100644 Textanalyse.iml create mode 100644 out/production/Textanalyse/com/structix/Analyse.class create mode 100644 out/production/Textanalyse/com/structix/Main.class create mode 100644 out/production/Textanalyse/com/structix/Menu.class create mode 100644 out/production/Textanalyse/com/structix/Menubuilder.class create mode 100644 src/com/structix/Analyse.java create mode 100644 src/com/structix/Main.java create mode 100644 src/com/structix/Menu.java create mode 100644 src/com/structix/Menubuilder.java 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 0000000000000000000000000000000000000000..4b47a6feaaff1588427c4953e42f67a3f04d0e60 GIT binary patch literal 2708 zcmaJ?NpllN6#hmdY2@(`8`%N_76!s%EMv2U#Rh{}%;tq4HZKH^uv{fomq>xSqhM+{ffHE|&=dH%xql&l0$4Vhtt}uoIY) zWKQ~;HX!8TmOSJQ%$Qh*i*j)ixGncPa&ZmJ8t^p49dE{V0}aW++xDE@?b=?xI~(|p zm+#fE>Rv(kf$-0Wl08eMrty`u8ieC52-g$Ws@n8=#POV8loo)(?UbT zpyP?*^6ZrGFWXZtImy97&UUZbz9Y{eGaAe|B@Jr^bA{RNQs9?!fivIT@7eDCl3<#3 z({>=7;w^hxgQ;j&lmu_LeWmcrGtv-KR=i+USPmSwJDamTPx$m75%U__sv@V*J>a-v zxDX5!%HH(p`J5;QPQjyEG!XLyX;n6`b9aX9qRL(YEm$=TmX!B*fmnjO|gx^BBJld4ZTM_WQnl zpHN78O1L5)7}%O*?W&R<9 z-m`_WpA!-c-XbhUmuw;n+tH%|7B*vxg)VekI4n7ZTKE4C?5@9Wf zKx_NC{}U&ILe&YouZ^!Ppd%tXkyJ!>f!bMc?gscqUC)%X;x5Qfi>J&!K%lo?}@I9R?u*5*ArUnyvbHZ)gklPf&|y~ zJf)e#My_q@rdxUM?W8)XD|6br7HvUV2l$|@#2GF1@&{581x8$PcPl?uRU`DH zq3@lwHpR$s+RQ8K7yMDt`}70RR8*ZG;h26@KM+gBGA|#YRq|5Ny_r;OZv|_=Lo9mq zVN83x_($vaXw0NTarU9EJ&cn5q9aX*Ptl?rrXQi18ZD`4hCZ@NLt>GpF;(;dXhd6{uRNuz;G3EBL|1fjglIor{9T#8N=AlgBK_@oj&-BYu%1J+ z;hoWjWGhdZbXNuGWRheB8;6wnZ=Fw;>d=P<(nB1jVKicdJvU4QFYz}a%YnH}9Ip`N zEG3snjp91SFo|(|&HWqPSi;|=wM00=2c=zALPslWTIG##s3fIJEJFMf^l=X7iPUx0 z_5wRSqK0l8>fXXMFi12T-VlEY>}CSa|F;tGgB0we+0Z+f)yu*PAjZ4v@@};=Vb{z= LY-uKjmDb2VM>8#_ literal 0 HcmV?d00001 diff --git a/out/production/Textanalyse/com/structix/Main.class b/out/production/Textanalyse/com/structix/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..76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R|vj!X8Y%FU12u#9{QJbQEik37B%wT{m uBv`acH$iL5hFQWjoc$N3uXs`b literal 0 HcmV?d00001 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; + } + + +}