|
From: Zach D. <zs...@um...> - 2007-03-01 03:37:19
|
Nice. Will apply patch to HEAD -- and thanks for the diff. Zach Roger Gammans wrote: > Hi > > I don't know if anyone else as noticed but with the standard variant > if and order specifies the 'Ionian Sea' province using the string > 'Ionian' the parse reports this as being ambigous between the provinces > ( London , Livonia , Ionian Sea ) as these all have the same levenstien > distance. > > I've attached a patch (or a can send thesf.net tracker) which fixes > this by changing map.getProvincesMatchingCloset() to use the > same algorithm as map.GetProvinceMatching() . > > It also and is requried to fix my gripe fixes a coding error > in findPartialProvinceMatch() . > > Any chance the can be applied to HEAD? > > TTFN > > ------------------------------------------------------------------------ > > Index: src/dip/world/Map.java > =================================================================== > RCS file: /cvsroot/jdip/jdip_168r1/src/dip/world/Map.java,v > retrieving revision 1.2 > diff -u -r1.2 Map.java > --- src/dip/world/Map.java 6 Jul 2005 10:43:40 -0000 1.2 > +++ src/dip/world/Map.java 15 Feb 2007 21:49:25 -0000 > @@ -483,31 +483,29 @@ > Set ties = new HashSet(); > > // if 2 or less, do no processing > - if(input.length() <= 2) > + if(input.length() < 3) > { > return new ArrayList(1); > } > - else if(input.length() == 3) > + > + > + // if we are only 3 chars, do a partial-first match > + // against provinces and return that tie list (or, > + // if no tie, return the province) > + // > + // This works better than Levenshtein > + // which can return some very odd results. > + // for short strings... > + // > + List list = findPartialProvinceMatch(input); > + if(list.size() == 1) > { > - // if we are only 3 chars, do a partial-first match > - // against provinces and return that tie list (or, > - // if no tie, return the province) > - // > - // This works better than Levenshtein > - // which can return some very odd results. > - // for short strings... > - // > - for(int i=0; i<names.length; i++) > - { > - String name = names[i]; > - if(name.startsWith(input)) > - { > - ties.add(getProvince(name)); > - } > - } > + return list; > } > - else > + > + if (input.length() > 3 ) > { > + ties.clear(); > // compute Levenshteins on the match > // if there are ties, keep them.. for now > int bestDist = Integer.MAX_VALUE; > @@ -530,7 +528,7 @@ > } > } > } > - > + > return ties; > }// getProvincesMatchingClosest() > > @@ -928,9 +926,9 @@ > { > HashSet ties = new HashSet(41); > > - for(int i=0; i<lcPowerNames.length; i++) > + for(int i=0; i<names.length; i++) > { > - String provName = names[i]; > + String provName = names[i].toLowerCase(); > > if(provName.startsWith(input)) > { > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > ------------------------------------------------------------------------ > > _______________________________________________ > jdip-developer mailing list > jdi...@li... > https://lists.sourceforge.net/lists/listinfo/jdip-developer > |