[Schmitzm-commits] r2107 - in trunk/schmitzm-adresses/src: main/java/de/schmitzm/adresses test/java/de/schmitzm/adresses

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Tue Oct 9 20:51:53 CEST 2012


Author: alfonx
Date: 2012-10-09 20:51:53 +0200 (Tue, 09 Oct 2012)
New Revision: 2107

Modified:
   trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
   trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
Log:


Modified: trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java
===================================================================
--- trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2012-10-09 17:55:35 UTC (rev 2106)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java	2012-10-09 18:51:53 UTC (rev 2107)
@@ -36,7 +36,7 @@
 					"[^\\d,]+(?:\\d+\\.)++[^\\d,]+" +
 					")"
 					+ "\\s*"
-					+ "(\\d+ u\\. \\d+-\\d+|" +
+					+ "(\\d+\\s*u\\.\\s*\\d+\\s*-\\s*\\d+|" +
 					"\\d+\\s*/\\s*\\d+|\\d+\\s*-\\s*\\d+|\\d+|\\d+\\s*[,\\s*\\d+]+|\\d+\\s*[&]\\s*\\d+|\\d+\\s*bis\\s*\\d+|\\d+\\s*\\\\\\s*\\d+|\\d+\\s*[/\\s*\\d+]+)"
 					+ "\\s*+" + "([^\\d].*[0][\\d]+|[^\\d]*?)" + "\\s*$");
 
@@ -214,6 +214,7 @@
 		zusammen = trimQuotes(zusammen);
 		zusammen = removeKommataAfterStreetname(zusammen);
 		zusammen = removeTrailingHyphens(zusammen);
+//		zusammen = removeSpaces(zusammen);
 		zusammen = removeLeadingSpacesInfrontOfNumbers(zusammen);
 
 		zusammen = removeSpacesBetweenHiphenAndDotAndLetters(zusammen);
@@ -228,7 +229,7 @@
 			// + origStrasse + " " + origHn + " " + origZusatz);
 			// return new String[] { null, splitHn[0], splitHn[1] };
 
-			Pattern p = regexCache.getPattern("([^\\d]*)\\s([\\d]+[^\\s]*|[\\d]+\\s+\\d+)$");
+			Pattern p = regexCache.getPattern("([^\\d]*)\\s([\\d]+[^\\s]*\\s*-\\s*[^\\s]*|[\\d]+[^\\s]*|[\\d]+\\s+\\d+)$");
 			m = p.matcher(zusammen);
 			if (m.find()) {
 				strasse = m.group(1);
@@ -267,7 +268,7 @@
 		strasse = StringUtils.trimToNull(strasse);
 		if (strasse == null || strasse.length() < 3) {
 
-			m = regexCache.getMatcher("(.+?)\\s([\\d]+[-]?[\\d]*)(.*)$", zusammen);
+			m = regexCache.getMatcher("(.+?)\\s([\\d]+\\s*[-]?\\s*[\\d]*)(.*)$", zusammen);
 			if (m.find()) {
 				strasse = m.group(1);
 				hn = m.group(2);
@@ -295,6 +296,10 @@
 		return new String[] { strasse, StringUtils.trimToNull(hn), StringUtils.trimToNull(zusatz) };
 	}
 
+	private static String removeSpaces(String zusammen) {
+		return RegexCache.getInstance().replaceAll(zusammen, "\\s*(bis|-)\\s*", " $1 ");
+	}
+
 	/**
 	 * @param zusammen
 	 * @return

Modified: trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java
===================================================================
--- trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2012-10-09 17:55:35 UTC (rev 2106)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java	2012-10-09 18:51:53 UTC (rev 2107)
@@ -23,6 +23,7 @@
 
 	@Test
 	public void testGetHausnummernInterpreted() {
+//		checkHausnummern("10 2", "10");
 		checkHausnummern("10 - 12 ", "10", "11", "12");
 		checkHausnummern("11 - 14 ", "11", "12", "13", "14");
 		
@@ -112,8 +113,17 @@
 
 	@Test
 	public void testSplit() {
+		
+		// TODO
+//		checkSplit("Kocherstrasse", "Kocherstrasse 15 1", "15", null, "1", null);
+		
+		checkSplit("Burgstr.", "Burgstr.  153A-154   ", "153A-154", null,
+				null, null);
+		
 		checkSplit("Planken E 1", "Planken E 1 10-12", "10-12", null,
 				null, null);
+		checkSplit("Planken E 1", "Planken E 1 10", "10", null,
+				null, null);
 		
 		checkSplit("Strasse des 3. Juni", "Strasse des 3. Juni", null, null,
 				null, null);
@@ -121,6 +131,7 @@
 				null, "b", null);
 
 		checkSplit("Kocherstrasse", "Kocherstrasse ,  108 u. 109-111", "108 u. 109-111", null, null, null);
+		checkSplit("Burgstr.", "Burgstr. 108 u. 109-111", "108 u. 109-111", null, null, null);
 		checkSplit("Kocherstrasse", "Kocherstrasse ,  101/102  ", "101/102", null, null, null);
 
 		checkSplit("Kocherstrasse", "Kocherstrasse ,  15 - 19", "15 - 19", null, null, null);
@@ -232,8 +243,18 @@
 
 		checkSplit("Leypoldt Strasse", "Leypoldt Strasse 6,/10 8/1", "6", null, ",/10 8/1", null);
 		checkSplit("ander B2", "ander B2 5-6", "5-6", null, null, null);
-		
+
+		checkSplit("Burgstr.", "Burgstr.  153A-154   ", "153A-154", null,
+				null, null);
+		checkSplit("Burgstr.", "Burgstr.  153A - 154   ", "153A- 154", null,
+				null, null);
+		checkSplit("Burgstr.", "Burgstr.  153A  -  154   ", "153A- 154", null,
+				null, null);
 //		checkSplit("Burgstr.", "Burgstr. 16,16A-B", "16,16A-B", null, null, null);
+
+//		checkSplit("Planken E 1", "Planken E 1", null, null,
+//				null, null);
+				
 	}
 
 	private void checkSplit(String sollStrasse, String istStrasse, String sollHn, String istHn, String sollZusatz,



More information about the Schmitzm-commits mailing list