User:Xybot/FixPotlatchDiacritc

From OpenStreetMap Wiki
Jump to: navigation, search

This is the Ruleset FixPotlatchDiacritic of the Xybot script

some of the characters could not be inserted into this wiki!

<source lang=perl> sub begin {

 my $me = shift;
 Data::Primitive->setCreator("FixPotlatchDiacritic");
 Data::Primitive->setComment('Fixing false diacritic characters generated by Potlatch');

}

sub process {

 my ($me, $obj) = @_;
 my $resultstr = "";
 my $work = $obj;
 my $clone = undef;
 foreach $k ("name", "addr:street") {
   my $v=$work->{"tags"}->{$k};
   if (defined($v)) {
     my $gotcha=0;
     if( $v =~ /(Ã|Ä|Å)./) { # irgendwie ist mir da kein kürzerer code eingefallen... tut, aber unschön
       $gotcha++ if ($v =~ s/À/À/g);          # Morbus Potlatch c380 À
       $gotcha++ if ($v =~ s/Ã�/Á/g);          # Morbus Potlatch c381 Á
       $gotcha++ if ($v =~ s/Â/Â/g);          # Morbus Potlatch c382 Â
                                               # c383 see below
       $gotcha++ if ($v =~ s/Ä/Ä/g);          # Morbus Potlatch c384 Ä
       $gotcha++ if ($v =~ s/Ã…/Å/g);          # Morbus Potlatch c385 Å
       $gotcha++ if ($v =~ s/Æ/Æ/g);          # Morbus Potlatch c386 Æ
       $gotcha++ if ($v =~ s/Ç/Ç/g);          # Morbus Potlatch c387 Ç
       $gotcha++ if ($v =~ s/È/È/g);          # Morbus Potlatch c388 È
       $gotcha++ if ($v =~ s/É/É/g);          # Morbus Potlatch c389 É
       $gotcha++ if ($v =~ s/Ê/Ê/g);          # Morbus Potlatch c38a Ê
       $gotcha++ if ($v =~ s/Ë/Ë/g);          # Morbus Potlatch c38b Ë
       $gotcha++ if ($v =~ s/ÃŒ/Ì/g);          # Morbus Potlatch c38c Ì
       $gotcha++ if ($v =~ s/Ã�/Í/g);          # Morbus Potlatch c38d Í
       $gotcha++ if ($v =~ s/ÃŽ/Î/g);          # Morbus Potlatch c38e Î
       $gotcha++ if ($v =~ s/Ã�/Ï/g);          # Morbus Potlatch c38f Ï
       $gotcha++ if ($v =~ s/Ã�/Ð/g);          # Morbus Potlatch c390 Ð
       $gotcha++ if ($v =~ s/Ñ/Ñ/g);          # Morbus Potlatch c391 Ñ
       $gotcha++ if ($v =~ s/Ã’/Ò/g);          # Morbus Potlatch c392 Ò
       $gotcha++ if ($v =~ s/Ó/Ó/g);          # Morbus Potlatch c393 Ó
       $gotcha++ if ($v =~ s/Ô/Ô/g);          # Morbus Potlatch c394 Ô
       $gotcha++ if ($v =~ s/Õ/Õ/g);          # Morbus Potlatch c395 Õ
       $gotcha++ if ($v =~ s/Ö/Ö/g);          # Morbus Potlatch c396 Ö
       $gotcha++ if ($v =~ s/×/×/g);          # Morbus Potlatch c397 ×
       $gotcha++ if ($v =~ s/Ø/Ø/g);          # Morbus Potlatch c398 Ø
       $gotcha++ if ($v =~ s/Ù/Ù/g);          # Morbus Potlatch c399 Ù
       $gotcha++ if ($v =~ s/Ú/Ú/g);          # Morbus Potlatch c39a Ú
       $gotcha++ if ($v =~ s/Û/Û/g);          # Morbus Potlatch c39b Û
       $gotcha++ if ($v =~ s/Ãœ/Ü/g);          # Morbus Potlatch c39c Ü
       $gotcha++ if ($v =~ s/Ã�/Ý/g);          # Morbus Potlatch c39d Ý
       $gotcha++ if ($v =~ s/Þ/Þ/g);          # Morbus Potlatch c39e Þ
       $gotcha++ if ($v =~ s/ß/ß/g);          # Morbus Potlatch c39f ß
       $gotcha++ if ($v =~ s/à/à/g);          # Morbus Potlatch c3a0 à
       $gotcha++ if ($v =~ s/á/á/g);          # Morbus Potlatch c3a1 á
       $gotcha++ if ($v =~ s/â/â/g);          # Morbus Potlatch c3a2 â
       $gotcha++ if ($v =~ s/ã/ã/g);          # Morbus Potlatch c3a3 ã
       $gotcha++ if ($v =~ s/ä/ä/g);          # Morbus Potlatch c3a4 ä
       $gotcha++ if ($v =~ s/Ã¥/å/g);          # Morbus Potlatch c3a5 å
       $gotcha++ if ($v =~ s/æ/æ/g);          # Morbus Potlatch c3a6 æ
       $gotcha++ if ($v =~ s/ç/ç/g);          # Morbus Potlatch c3a7 ç
       $gotcha++ if ($v =~ s/è/è/g);          # Morbus Potlatch c3a8 è
       $gotcha++ if ($v =~ s/é/é/g);          # Morbus Potlatch c3a9 é
       $gotcha++ if ($v =~ s/ê/ê/g);          # Morbus Potlatch c3aa ê
       $gotcha++ if ($v =~ s/ë/ë/g);          # Morbus Potlatch c3ab ë
       $gotcha++ if ($v =~ s/ì/ì/g);          # Morbus Potlatch c3ac ì
       $gotcha++ if ($v =~ s/í/í/g);          # Morbus Potlatch c3ad í
       $gotcha++ if ($v =~ s/î/î/g);          # Morbus Potlatch c3ae î
       $gotcha++ if ($v =~ s/ï/ï/g);          # Morbus Potlatch c3af ï
       $gotcha++ if ($v =~ s/ð/ð/g);          # Morbus Potlatch c3b0 ð
       $gotcha++ if ($v =~ s/ñ/ñ/g);          # Morbus Potlatch c3b1 ñ
       $gotcha++ if ($v =~ s/ò/ò/g);          # Morbus Potlatch c3b2 ò
       $gotcha++ if ($v =~ s/ó/ó/g);          # Morbus Potlatch c3b3 ó
       $gotcha++ if ($v =~ s/ô/ô/g);          # Morbus Potlatch c3b4 ô
       $gotcha++ if ($v =~ s/õ/õ/g);          # Morbus Potlatch c3b5 õ
       $gotcha++ if ($v =~ s/ö/ö/g);          # Morbus Potlatch c3b6 ö
       $gotcha++ if ($v =~ s/÷/÷/g);          # Morbus Potlatch c3b7 ÷
       $gotcha++ if ($v =~ s/ø/ø/g);          # Morbus Potlatch c3b8 ø
       $gotcha++ if ($v =~ s/ù/ù/g);          # Morbus Potlatch c3b9 ù
       $gotcha++ if ($v =~ s/ú/ú/g);          # Morbus Potlatch c3ba ú
       $gotcha++ if ($v =~ s/û/û/g);          # Morbus Potlatch c3bb û
       $gotcha++ if ($v =~ s/ü/ü/g);          # Morbus Potlatch c3bc ü
       $gotcha++ if ($v =~ s/ý/ý/g);          # Morbus Potlatch c3bd ý
       $gotcha++ if ($v =~ s/þ/þ/g);          # Morbus Potlatch c3be þ
       $gotcha++ if ($v =~ s/ÿ/ÿ/g);          # Morbus Potlatch c3bf ÿ
       $gotcha++ if ($v =~ s/Ã/Ã/g);          # Morbus Potlatch c383 à ##
       $gotcha++ if ($v =~ s/Ä€/Ā/g);          # Morbus Potlatch c480 Ā
       $gotcha++ if ($v =~ s/Ä�/ā/g);          # Morbus Potlatch c481 ā
       $gotcha++ if ($v =~ s/Ä‚/Ă/g);          # Morbus Potlatch c482 Ă
       $gotcha++ if ($v =~ s/Ã/ă/g);          # Morbus Potlatch c383 ă
       $gotcha++ if ($v =~ s/Ä„/Ą/g);          # Morbus Potlatch c484 Ą
       $gotcha++ if ($v =~ s/Ä…/ą/g);          # Morbus Potlatch c485 ą
       $gotcha++ if ($v =~ s/Ć/Ć/g);          # Morbus Potlatch c486 Ć
       $gotcha++ if ($v =~ s/ć/ć/g);          # Morbus Potlatch c487 ć
       $gotcha++ if ($v =~ s/Ĉ/Ĉ/g);          # Morbus Potlatch c488 Ĉ
       $gotcha++ if ($v =~ s/ĉ/ĉ/g);          # Morbus Potlatch c489 ĉ
       $gotcha++ if ($v =~ s/ÄŠ/Ċ/g);          # Morbus Potlatch c48a Ċ
       $gotcha++ if ($v =~ s/Ä‹/ċ/g);          # Morbus Potlatch c48b ċ
       $gotcha++ if ($v =~ s/ÄŒ/Č/g);          # Morbus Potlatch c48c Č
       $gotcha++ if ($v =~ s/Ä�/č/g);          # Morbus Potlatch c48d č
       $gotcha++ if ($v =~ s/ÄŽ/Ď/g);          # Morbus Potlatch c48e Ď
       $gotcha++ if ($v =~ s/Ä�/ď/g);          # Morbus Potlatch c48f ď
       $gotcha++ if ($v =~ s/Ä�/Đ/g);          # Morbus Potlatch c490 Đ
       $gotcha++ if ($v =~ s/Ä‘/đ/g);          # Morbus Potlatch c491 đ
       $gotcha++ if ($v =~ s/Ä’/Ē/g);          # Morbus Potlatch c492 Ē
       $gotcha++ if ($v =~ s/Ä“/ē/g);          # Morbus Potlatch c493 ē
       $gotcha++ if ($v =~ s/Ä”/Ĕ/g);          # Morbus Potlatch c494 Ĕ
       $gotcha++ if ($v =~ s/Ä•/ĕ/g);          # Morbus Potlatch c495 ĕ
       $gotcha++ if ($v =~ s/Ä–/Ė/g);          # Morbus Potlatch c496 Ė
       $gotcha++ if ($v =~ s/Ä—/ė/g);          # Morbus Potlatch c497 ė
       $gotcha++ if ($v =~ s/Ę/Ę/g);          # Morbus Potlatch c498 Ę
       $gotcha++ if ($v =~ s/Ä™/ę/g);          # Morbus Potlatch c499 ę
       $gotcha++ if ($v =~ s/Äš/Ě/g);          # Morbus Potlatch c49a Ě
       $gotcha++ if ($v =~ s/Ä›/ě/g);          # Morbus Potlatch c49b ě
       $gotcha++ if ($v =~ s/Äœ/Ĝ/g);          # Morbus Potlatch c49c Ĝ
       $gotcha++ if ($v =~ s/Ä�/ĝ/g);          # Morbus Potlatch c49d ĝ
       $gotcha++ if ($v =~ s/Äž/Ğ/g);          # Morbus Potlatch c49e Ğ
       $gotcha++ if ($v =~ s/ÄŸ/ğ/g);          # Morbus Potlatch c49f ğ
       $gotcha++ if ($v =~ s/Ä /Ġ/g);          # Morbus Potlatch c4a0 Ġ
       $gotcha++ if ($v =~ s/Ä¡/ġ/g);          # Morbus Potlatch c4a1 ġ
       $gotcha++ if ($v =~ s/Ä¢/Ģ/g);          # Morbus Potlatch c4a2 Ģ
       $gotcha++ if ($v =~ s/Ä£/ģ/g);          # Morbus Potlatch c3a3 ģ
       $gotcha++ if ($v =~ s/Ĥ/Ĥ/g);          # Morbus Potlatch c4a4 Ĥ
       $gotcha++ if ($v =~ s/Ä¥/ĥ/g);          # Morbus Potlatch c4a5 ĥ
       $gotcha++ if ($v =~ s/Ħ/Ħ/g);          # Morbus Potlatch c4a6 Ħ
       $gotcha++ if ($v =~ s/ħ/ħ/g);          # Morbus Potlatch c4a7 ħ
       $gotcha++ if ($v =~ s/Ĩ/Ĩ/g);          # Morbus Potlatch c4a8 Ĩ
       $gotcha++ if ($v =~ s/Ä©/ĩ/g);          # Morbus Potlatch c4a9 ĩ
       $gotcha++ if ($v =~ s/Ī/Ī/g);          # Morbus Potlatch c4aa Ī
       $gotcha++ if ($v =~ s/Ä«/ī/g);          # Morbus Potlatch c4ab ī
       $gotcha++ if ($v =~ s/Ĭ/Ĭ/g);          # Morbus Potlatch c4ac Ĭ
       $gotcha++ if ($v =~ s/Ä­/ĭ/g);          # Morbus Potlatch c4ad ĭ
       $gotcha++ if ($v =~ s/Ä®/Į/g);          # Morbus Potlatch c4ae Į
       $gotcha++ if ($v =~ s/į/į/g);          # Morbus Potlatch c4af į
       $gotcha++ if ($v =~ s/Ä°/İ/g);          # Morbus Potlatch c4b0 İ
       $gotcha++ if ($v =~ s/ı/ı/g);          # Morbus Potlatch c4b1 ı
       $gotcha++ if ($v =~ s/IJ/IJ/g);          # Morbus Potlatch c4b2 IJ
       $gotcha++ if ($v =~ s/ij/ij/g);          # Morbus Potlatch c4b3 ij
       $gotcha++ if ($v =~ s/Ä´/Ĵ/g);          # Morbus Potlatch c4b4 Ĵ
       $gotcha++ if ($v =~ s/ĵ/ĵ/g);          # Morbus Potlatch c4b5 ĵ
       $gotcha++ if ($v =~ s/Ķ/Ķ/g);          # Morbus Potlatch c4b6 Ķ
       $gotcha++ if ($v =~ s/Ä·/ķ/g);          # Morbus Potlatch c4b7 ķ
       $gotcha++ if ($v =~ s/ĸ/ĸ/g);          # Morbus Potlatch c4b8 ĸ
       $gotcha++ if ($v =~ s/Ĺ/Ĺ/g);          # Morbus Potlatch c4b9 Ĺ
       $gotcha++ if ($v =~ s/ĺ/ĺ/g);          # Morbus Potlatch c4ba ĺ
       $gotcha++ if ($v =~ s/Ä»/ļ/g);          # Morbus Potlatch c4bb ļ
       $gotcha++ if ($v =~ s/ļ/Ļ/g);          # Morbus Potlatch c4bc Ļ
       $gotcha++ if ($v =~ s/Ľ/Ľ/g);          # Morbus Potlatch c4bd Ľ
       $gotcha++ if ($v =~ s/ľ/ľ/g);          # Morbus Potlatch c4be ľ
       $gotcha++ if ($v =~ s/Ä¿/Ŀ/g);          # Morbus Potlatch c4bf Ŀ
       $gotcha++ if ($v =~ s/Å€/ŀ/g);          # Morbus Potlatch c580 ŀ
       $gotcha++ if ($v =~ s/Å�/Ł/g);          # Morbus Potlatch c581 Ł
       $gotcha++ if ($v =~ s/Å‚/ł/g);          # Morbus Potlatch c582 ł
       $gotcha++ if ($v =~ s/Ń/Ń/g);          # Morbus Potlatch c383 Ń #
       $gotcha++ if ($v =~ s/Å„/ń/g);          # Morbus Potlatch c584 ń
       $gotcha++ if ($v =~ s/Å…/Ņ/g);          # Morbus Potlatch c585 Ņ
       $gotcha++ if ($v =~ s/ņ/ņ/g);          # Morbus Potlatch c586 ņ
       $gotcha++ if ($v =~ s/Ň/Ň/g);          # Morbus Potlatch c587 Ň
       $gotcha++ if ($v =~ s/ň/ň/g);          # Morbus Potlatch c588 ň
       $gotcha++ if ($v =~ s/ʼn/ʼn/g);          # Morbus Potlatch c589 ʼn
       $gotcha++ if ($v =~ s/ÅŠ/Ŋ/g);          # Morbus Potlatch c58a Ŋ #
       $gotcha++ if ($v =~ s/Å‹/ŋ/g);          # Morbus Potlatch c58b ŋ
       $gotcha++ if ($v =~ s/ÅŒ/Ō/g);          # Morbus Potlatch c58c Ō ##
       $gotcha++ if ($v =~ s/Å�/ō/g);          # Morbus Potlatch c58d ō
       $gotcha++ if ($v =~ s/ÅŽ/Ŏ/g);          # Morbus Potlatch c58e Ŏ
       $gotcha++ if ($v =~ s/Å�/ŏ/g);          # Morbus Potlatch c58f ŏ
       $gotcha++ if ($v =~ s/Å�/Ő/g);          # Morbus Potlatch c590 Ő
       $gotcha++ if ($v =~ s/Å‘/ő/g);          # Morbus Potlatch c591 ő
       $gotcha++ if ($v =~ s/Å’/Œ/g);          # Morbus Potlatch c592 Œ
       $gotcha++ if ($v =~ s/Å“/œ/g);          # Morbus Potlatch c593 œ
       $gotcha++ if ($v =~ s/Å”/Ŕ/g);          # Morbus Potlatch c594 Ŕ
       $gotcha++ if ($v =~ s/Å•/ŕ/g);          # Morbus Potlatch c595 ŕ
       $gotcha++ if ($v =~ s/Å–/Ŗ/g);          # Morbus Potlatch c596 Ŗ
       $gotcha++ if ($v =~ s/Å—/ŗ/g);          # Morbus Potlatch c597 ŗ
       $gotcha++ if ($v =~ s/Ř/Ř/g);          # Morbus Potlatch c598 Ř
       $gotcha++ if ($v =~ s/Å™/ř/g);          # Morbus Potlatch c599 ř
       $gotcha++ if ($v =~ s/Åš/Ś/g);          # Morbus Potlatch c59a Ś #
       $gotcha++ if ($v =~ s/Å›/ś/g);          # Morbus Potlatch c59b ś
       $gotcha++ if ($v =~ s/Åœ/Ŝ/g);          # Morbus Potlatch c59c Ŝ ##
       $gotcha++ if ($v =~ s/Å�/ŝ/g);          # Morbus Potlatch c59d ŝ
       $gotcha++ if ($v =~ s/Åž/Ş/g);          # Morbus Potlatch c59e Ş #
       $gotcha++ if ($v =~ s/ÅŸ/ş/g);          # Morbus Potlatch c59f ş #
       $gotcha++ if ($v =~ s/Å /Š/g);          # Morbus Potlatch c5a0 Š
       $gotcha++ if ($v =~ s/Å¡/š/g);          # Morbus Potlatch c5a1 š
       $gotcha++ if ($v =~ s/Å¢/Ţ/g);          # Morbus Potlatch c5a2 Ţ
       $gotcha++ if ($v =~ s/Å£/ţ/g);          # Morbus Potlatch c3a3 ţ
       $gotcha++ if ($v =~ s/Ť/Ť/g);          # Morbus Potlatch c5a4 Ť
       $gotcha++ if ($v =~ s/Å¥/ť/g);          # Morbus Potlatch c5a5 ť
       $gotcha++ if ($v =~ s/Ŧ/Ŧ/g);          # Morbus Potlatch c5a6 Ŧ
       $gotcha++ if ($v =~ s/ŧ/ŧ/g);          # Morbus Potlatch c5a7 ŧ
       $gotcha++ if ($v =~ s/Ũ/Ũ/g);          # Morbus Potlatch c5a8 Ũ
       $gotcha++ if ($v =~ s/Å©/ũ/g);          # Morbus Potlatch c5a9 ũ
       $gotcha++ if ($v =~ s/Ū/Ū/g);          # Morbus Potlatch c5aa Ū
       $gotcha++ if ($v =~ s/Å«/ū/g);          # Morbus Potlatch c5ab ū
       $gotcha++ if ($v =~ s/Ŭ/Ŭ/g);          # Morbus Potlatch c5ac Ŭ
       $gotcha++ if ($v =~ s/Å­/ŭ/g);          # Morbus Potlatch c5ad ŭ
       $gotcha++ if ($v =~ s/Å®/Ů/g);          # Morbus Potlatch c5ae Ů
       $gotcha++ if ($v =~ s/ů/ů/g);          # Morbus Potlatch c5af ů
       $gotcha++ if ($v =~ s/Å°/Ű/g);          # Morbus Potlatch c5b0 Ű
       $gotcha++ if ($v =~ s/ű/ű/g);          # Morbus Potlatch c5b1 ű
       $gotcha++ if ($v =~ s/Ų/Ų/g);          # Morbus Potlatch c5b2 Ų
       $gotcha++ if ($v =~ s/ų/ų/g);          # Morbus Potlatch c5b3 ų
       $gotcha++ if ($v =~ s/Å´/Ŵ/g);          # Morbus Potlatch c5b4 Ŵ
       $gotcha++ if ($v =~ s/ŵ/ŵ/g);          # Morbus Potlatch c5b5 ŵ #
       $gotcha++ if ($v =~ s/Ŷ/Ŷ/g);          # Morbus Potlatch c5b6 Ŷ
       $gotcha++ if ($v =~ s/Å·/ŷ/g);          # Morbus Potlatch c5b7 ŷ
       $gotcha++ if ($v =~ s/Ÿ/Ÿ/g);          # Morbus Potlatch c5b8 Ÿ
       $gotcha++ if ($v =~ s/Ź/Ź/g);          # Morbus Potlatch c5b9 Ź
       $gotcha++ if ($v =~ s/ź/ź/g);          # Morbus Potlatch c5ba ź
       $gotcha++ if ($v =~ s/Å»/Ż/g);          # Morbus Potlatch c5bb Ż
       $gotcha++ if ($v =~ s/ż/ż/g);          # Morbus Potlatch c5bc ż
       $gotcha++ if ($v =~ s/Ž/Ž/g);          # Morbus Potlatch c5bd Ž
       $gotcha++ if ($v =~ s/ž/ž/g);          # Morbus Potlatch c5be ž
       $gotcha++ if ($v =~ s/Å¿/ſ/g);          # Morbus Potlatch c5bf ſ
     }
     if ($gotcha) {
       $resultstr .= sprintf " - key '%s' modifying value '%s' to '%s'", $k, $work->{"tags"}->{$k}, $v;
       $clone=$work->clone() unless defined($clone);
       $clone->{"tags"}->{$k} = $v;
       $work=$clone;
     }
   }
 }
 $obj->log(ref($obj), $work->{"id"}, $resultstr, $obj->update($clone, $me)) if (defined($clone));

}