Commit 32c7e09d authored by Maria Barbatei's avatar Maria Barbatei

Adding AbsatzSplitter erste Version

parent fd0008c1
package Ueb6;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class AbsatzSplitter {
public static final String PATH = "/Users/mariabarbatei/Desktop/Arztbrief1.txt";
public static void main(String[] args) throws IOException {
FileReader arztBrief = new FileReader(PATH);
StringBuilder arztBriefAsStringBuilder = new StringBuilder();
String zeile = "";
String arztBriefAsString = "";
BufferedReader buffer = new BufferedReader(arztBrief);
while((zeile = buffer.readLine()) != null) {
if(zeile.isEmpty()) {
} else {
//brief wird in einem String umgewandelt
arztBriefAsString = arztBriefAsStringBuilder.toString();
//patter fuer die Identifizierung der Diagnosen (key's im map)
Pattern pattern1 = Pattern.compile(".*[:]");
//pattern fuer die Identifizierung der entsprechenden Absatze (values's im map)
Pattern pattern2 = Pattern.compile("[:]+.*");
// [A-Z|a-z| |.|,|ä|ö|ü|Ä|Ü|Ö|ß|\\d|{|}|[|]|
//matcher fuer erste pattern
Matcher m1 = pattern1.matcher(arztBriefAsString);
//matcher fuer zweite pattern
Matcher m2 = pattern2.matcher(arztBriefAsString);
Map<String, String> map = new HashMap<String, String>();
while (m1.find() && m2.find()) {
System.out.println("Key: " +;
System.out.println("Value: " +;
for(Map.Entry<String, String> entry : map.entrySet()) {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment