[Schmitzm-commits] r2106 - 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 19:55:36 CEST 2012
Author: alfonx
Date: 2012-10-09 19:55:35 +0200 (Tue, 09 Oct 2012)
New Revision: 2106
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 16:40:43 UTC (rev 2105)
+++ trunk/schmitzm-adresses/src/main/java/de/schmitzm/adresses/AddrStringUtil.java 2012-10-09 17:55:35 UTC (rev 2106)
@@ -30,10 +30,15 @@
final static Pattern REGEX_splitHnZusatz = regexCache.getPattern("(\\d+)\\s*(.*?)\\s*$");
final static Pattern REGEX_splitFullString = regexCache
- .getPattern("^(.*\\d+\\.+[^\\d]*|[^\\d,]+)"
+ .getPattern("^(" +
+ "Planken\\s*[^\\d]\\s*\\d|"+
+ ".*\\d+\\.+[^\\d]*|[^\\d,]+|" +
+ "[^\\d,]+(?:\\d+\\.)++[^\\d,]+" +
+ ")"
+ "\\s*"
- + "(\\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*$");
+ + "(\\d+ u\\. \\d+-\\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*$");
final static Pattern REGEX_hnZusatzBereich2aBis2f = regexCache
.getPattern("(\\d+)([^\\d]?)\\s*(-|bis)\\s*(\\d*)([^\\d]?).*");
@@ -185,7 +190,7 @@
origHn = stringStrHnZusatz[1];
if (stringStrHnZusatz.length == 3)
origZusatz = stringStrHnZusatz[2];
-
+
if (origStrasse == null || origStrasse.isEmpty() || !origStrasse.matches(".*[A-Za-z][A-Za-z]+.*")) {
final String[] splitHn = splitHn(origHn, origZusatz);
return new String[] { null, splitHn[0], splitHn[1] };
@@ -204,6 +209,8 @@
String zusammen = origStrasse + " " + (origHn != null ? " " + origHn : "")
+ (origZusatz != null ? " " + origZusatz : "");
+ zusammen = zusammen.replaceAll("3. Juni", "Dritten Juni");
+
zusammen = trimQuotes(zusammen);
zusammen = removeKommataAfterStreetname(zusammen);
zusammen = removeTrailingHyphens(zusammen);
@@ -237,7 +244,7 @@
if (regexCache.matches(".*\\d+.*$", zusammen))
return new String[] { null, null, null, null };
else
- return new String[] { zusammen, null, null, null };
+ return new String[] { zusammen.replaceAll("Dritten Juni", "3. Juni"), null, null, null };
}
}
warn = true;
@@ -282,6 +289,8 @@
// if (warn)
// log.debug("Aus '" + origStrasse + "' wurde Strasse='" + strasse + "', HN='" + StringUtils.trimToNull(hn)
// + "', Zusatz='" + StringUtils.trimToNull(zusatz) + "', richtig?");
+
+ strasse = strasse.replace("Dritten Juni", "3. Juni");
return new String[] { strasse, StringUtils.trimToNull(hn), StringUtils.trimToNull(zusatz) };
}
@@ -501,6 +510,9 @@
strasse = strasse.toLowerCase();
+ // http://de.wikipedia.org/wiki/Mannheimer_Planken
+ strasse = RegexCache.getInstance().replaceAll(strasse, "^planken\\b", "");
+
strasse = RegexCache.getInstance().replaceAll(strasse, "\\(.*?\\)", "");
strasse = RegexCache.getInstance().replaceAll(strasse, "x{2,}$", "");
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 16:40:43 UTC (rev 2105)
+++ trunk/schmitzm-adresses/src/test/java/de/schmitzm/adresses/AddrStringUtilTest.java 2012-10-09 17:55:35 UTC (rev 2106)
@@ -23,6 +23,9 @@
@Test
public void testGetHausnummernInterpreted() {
+ checkHausnummern("10 - 12 ", "10", "11", "12");
+ checkHausnummern("11 - 14 ", "11", "12", "13", "14");
+
checkHausnummern("102 - 104", "102", "103", "104");
checkHausnummern("102-104", "102", "103", "104");
@@ -109,8 +112,20 @@
@Test
public void testSplit() {
+ checkSplit("Planken E 1", "Planken E 1 10-12", "10-12", null,
+ null, null);
+
+ checkSplit("Strasse des 3. Juni", "Strasse des 3. Juni", null, null,
+ null, null);
+ checkSplit("Strasse des 3. Juni", "Strasse des 3. Juni 4b", "4",
+ null, "b", null);
+ checkSplit("Kocherstrasse", "Kocherstrasse , 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);
+
+ checkSplit("Kocherstrasse", "Kocherstrasse , 15 - 19", "15 - 19", null, null, null);
checkSplit("Kocherstrasse", "Kocherstrasse , 105 - 109", "105 - 109", null, null, null);
checkSplit("musterstraße", "musterstraße 23/34", "23/34", null, null, null);
@@ -144,10 +159,6 @@
checkSplit("Straße des 17. Juni", "Straße des 17. Juni 135a", "135", null, "a", null);
- 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("Bettina Strasse", "Bettina Strasse 52-54 2.OG", "52-54", null, "2.OG", null);
checkSplit("Dieselstr.", "Dieselstr .11 - 13", "11 - 13", null, null, null);
@@ -191,9 +202,6 @@
checkSplit("Marder Weg", "Marder Weg 2/4/10", "2/4/10", null, null, null);
- // checkSplit("Burgstr.", "Burgstr. 16,16A-B", "16,16A-B", null, null,
- // null);
-
checkSplit("Marder Weg", "Marder Weg 2 - 4 ", "2 - 4", null, null, null);
checkSplit("Marder Weg", "Marder Weg 2 bis 4", "2 bis 4", null, null, null);
checkSplit("Marder Weg", "Marder Weg 2\\4", "2\\4", null, null, null);
@@ -214,12 +222,6 @@
checkSplit("Marderweg", "Marderweg", "2", "2", "a", "a");
- // checkSplit("Strasse des 3. Juni", "Strasse des 3. Juni", null, null,
- // null, null);
- // checkSplit("Strasse des 3. Juni", "Strasse des 3. Juni 4b", "4",
- // null,
- // "b", null, null, null);
-
checkSplit(null, null, null, null, null, null);
checkSplit(null, null, "3", "3 aa", "aa", null);
checkSplit(null, null, "3", "3 aa ", "aa", null);
@@ -227,6 +229,11 @@
checkSplit(null, null, "3", " 3 a", "a", null);
checkSplit(null, null, "2", "2a", "a blub", "blub");
checkSplit(null, null, "2", "2", "blub", "blub");
+
+ 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. 16,16A-B", "16,16A-B", null, null, null);
}
private void checkSplit(String sollStrasse, String istStrasse, String sollHn, String istHn, String sollZusatz,
@@ -320,6 +327,8 @@
@Test
public void testNormalizeStrasse() {
+ assertEquals("a2", AddrStringUtil.normalizeStr("Planken A 2"));
+ assertEquals("a2", AddrStringUtil.normalizeStr("Planken A2"));
assertEquals("lilienthalstrasse", AddrStringUtil.normalizeStr("Lilienthalstraße (ggü. Haus 7)"));
assertEquals("triererstrasse", AddrStringUtil.normalizeStr("Trierer Str"));
assertEquals("marktstrasse", AddrStringUtil.normalizeStr("Marktstrasse"));
More information about the Schmitzm-commits
mailing list