Menu
  • HOME
  • TAGS

How to get all matched parts to regex pattern

java,regex,sequencematcher

You should have while (matcher.find()) instead of an if-statement. if (matcher.find()) { for(int matchIndex = 0; matchIndex < matcher.groupCount(); ++matchIndex) { matchedList.add(matcher.group(matchIndex)); } } I've replaced above code with this one: while (matcher.find()) { matchedList.add(matcher.group(1)); } Works fine, ty for help....

difflib.SequenceMatcher not returning unique ratio

python,gis,arcpy,difflib,sequencematcher

If you know both files always have the exact same number of lines, a simple approach like this would work: ratios = [] with open('fieldName1', 'r') as f1, open('fieldName2', 'r') as f2: for l1, l2 in zip(f1, f2): R = difflib.SequenceMatcher(None,l1,l2).ratio() ratios.append((l1, l2, R)) This will produce a list of...

Programmatically figuring out if translated names are equivalent

python,difflib,sequencematcher

You can normalize the ordering of names before comparing: def normalize(name): name_parts = name.replace("-", " ").split() return " ".join(sorted(name_parts)).lower() ...