For example geonames fails for "Southsea, Hampshire, UK" as even though Southsea is in geonames and falls within the regional boundary of Hampshire, geonames doesn't have that knowledge. OSM has the regional boundary data which can be used for that purpose.
Also once you have that you can do looser matching. For example if you search Geonames for "Bosten, MA, USA" it won't find anything. If you used soundex for an approximate search for "Bosten" you'll turn up lots of unrelated locations, but if you did it restricting it to places in "MA, USA" you'd have a much better chance of getting an accurate match.
While this isn't such a big issue in latin-alphabet countries, in the rest of the world latin-spelling of smaller town and city names is often completely unstandardized so using exact search often misses the town/city even though it might be listed in geonames under a slightly different spelling.
Geonames has a good dataset of locations, and OpenStreetMaps has the regional boundary data.
So given something like "Boston, Massachusetts, USA" would take all the locations within the boundary box of "USA" and find the closest match to "Massachusetts" (using something like soundex), and then within Massachusetts find the closest match to "Boston" and return the long/lat.