I was glad Jan-Willem showed up. The result is a python plugin which can correct spelling from within JOSM. I just corrected 264 street names around Aarschot with it:<br><br><a href="http://www.openstreetmap.org/browse/changeset/7794020">http://www.openstreetmap.org/browse/changeset/7794020</a><br>
<br>Somebody had some trouble finding the Shift key on his/her keyboard. This spelling checker also works for French street names. It still needs some refinement. Now it asks the same question over and over again for each segment and it should be made aware of the language a correction applies for. For the moment it only checks name and not name:nl/name:fr. But the real message is that Jan-Willem helped me over the initial difficulties of scripting the JOSM API with Python.<br>
<br>So I'm really glad we met yesterday evening!<br><br>Here is the code:<br><br><blockquote style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class="gmail_quote">#!/bin/jython<br>
#<br># Helps to check spelling in 'name' fields.<br>#<br>from javax.swing import JOptionPane<br>from org.openstreetmap.josm import Main<br>import org.openstreetmap.josm.command as Command<br>import org.openstreetmap.josm.data.osm.Node as Node<br>
import org.openstreetmap.josm.data.osm.Way as Way<br>import org.openstreetmap.josm.data.osm.TagCollection as TagCollection<br>import org.openstreetmap.josm.data.osm.DataSet as DataSet<br><br>corrections = [('Dr. ', 'Docteur '),('R. ', 'Rue '), ('Av. ', 'Avenue '), ('Bd. ', 'Boulevard '),<br>
               ('Sq.', 'Square'), ('Pl.', 'Place'),<br>               (' De ', ' de '), (' La ', ' la '), (' Du ', ' du '), (' Des ', ' des '),<br>
               (' Au ', ' au '),(' Aux ', ' aux '),('Ŕ', 'ŕ'),(' Den ',' den '),<br>               (" D'"," d'"), (" L'"," l'"), ("' ","'"),<br>
               ("Ecole ","École "),<br>               (" Voor ", " voor "), (" Op ", " op "), (" Pour ", " pour ")]<br><br>logger = open("c:\debug.log", "w") #,  encoding="utf-8")<br>
commandsList = []<br><br>def getMapView():<br>    if Main.main and Main.main.map:<br>        return Main.main.map.mapView<br>    else:<br>        return None<br><br>def myOwnCapitalize(word):<br>    # JOptionPane.showMessageDialog(Main.parent, word.decode('utf-8'))<br>
    if word:<br>        return word[0].uppper() + word[1:]<br><br>mv = getMapView()<br><br>if mv and mv.editLayer and mv.editLayer.data:<br>    selectedNodes = mv.editLayer.data.getSelectedNodes()<br>    selectedWays = mv.editLayer.data.getWays()<br>
    selectedRelations = mv.editLayer.data.getSelectedRelations()<br>    logger.write("nodes: %s\n"%selectedNodes)<br>    #logger.write("ways: %s\n"%selectedWays)<br>    logger.write("relations: %s\n"%selectedRelations)<br>
    if not(selectedNodes or selectedWays or selectedRelations):<br>        JOptionPane.showMessageDialog(Main.parent, "Please select something")<br>    else:<br>        for way in selectedWays:<br>            if way.hasKey('name'):<br>
                name=str(way.get("name").encode('utf-8'))<br>                # JOptionPane.showMessageDialog(Main.parent, name.decode('utf-8'))<br>                correctedName = u''<br>                for word in name.split(u" "):<br>
                    # JOptionPane.showMessageDialog(Main.parent, word.decode('utf-8'))<br>                    if "-" in word:<br>                        dashes = word.split("-")<br>                        correctedName +=  dashes[0].capitalize()<br>
                        print(dashes)<br>                        for dash in dashes[1:]:<br>                            correctedName +=  "-" + dash[0].upper() + dash[1:]<br>                    elif "'" in word and not("." in word):<br>
                        apo=word.split("'")<br>                        correctedName +=  apo[0].capitalize() + "'" + apo[1].capitalize()<br>                    elif "." in word or len(word)>1 and word[1]==word[1].capitalize() or len(word)>2 and word[2]==word[2].capitalize():<br>
                        correctedName += word<br>                    else:<br>                        correctedName += word[0].upper() + word[1:]<br>                    correctedName += ' '<br>                for wrongspelling, correction in corrections:<br>
                    correctedName = correctedName.replace(wrongspelling, correction)<br>                correctedName = correctedName.strip()<br>                if name != correctedName:<br>                    result = JOptionPane.showInputDialog(Main.parent,<br>
                                "Previous name: " + name.decode('utf-8'),<br>                                'Change spelling?',<br>                                JOptionPane.QUESTION_MESSAGE,<br>
                                None,<br>                                None,<br>                                correctedName.decode('utf-8'))<br>                    # JOptionPane.showMessageDialog(Main.parent, result)<br>
                    if result:<br>                        # logger.write("output: %s\n"%type(name))<br>                        newWay = Way(way)<br>                        newWay.put("name", result) # .decode('utf-8'))<br>
                        commandsList.append(Command.ChangeCommand(way, newWay))<br>        if commandsList:<br>            Main.main.undoRedo.add(Command.SequenceCommand("Change spelling", commandsList))<br>        <br>
        # for primitive in selectedprimitives:<br>            # logger.write("You have selected the following : %s\r\n" % primitive)<br><br>logger.close()<br></blockquote><br><div class="gmail_quote">2011/4/6 Jan-willem De Bleser <span dir="ltr"><<a href="mailto:jw@thescrapyard.org">jw@thescrapyard.org</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">On Wed, Apr 6, 2011 at 15:52, Jo <<a href="mailto:winfixit@gmail.com">winfixit@gmail.com</a>> wrote:<br>

> I plan to go anyway. Doesn't really matter whether I sit and work there or<br>
> at home. I'm a happy camper as long as I have an internet connection... If<br>
> nobody shows up, I'll probably leave around 21h00.<br>
><br>
> Polyglot<br>
><br>
<br>
</div>I might be able to swing by for a bit. Will see when I get out of work.<br>
<br>
Cheers,<br>
Jw<br>
<br>
_______________________________________________<br>
Talk-be mailing list<br>
<a href="mailto:Talk-be@openstreetmap.org">Talk-be@openstreetmap.org</a><br>
<a href="http://lists.openstreetmap.org/listinfo/talk-be" target="_blank">http://lists.openstreetmap.org/listinfo/talk-be</a><br>
</blockquote></div><br>