1

I need some help with this:

First of all, I wanted to "Compare strings from two fields", and asking before at gis.stackexchange, in this post someone help me with this topic, referring me to a Python code, but, unfortunately, from the deepest ignorance of this kind of issues, I wanted to know if it is possible to run this code within ArcGIS 10 (field calculator).

The code: PyLevenshtein ,

Thanks in advance, and sorry if I wasted your time.

4

First, you need to install it and it can be installed like any other Python module.

  • Python setup.py install
  • easy_install or pip install

But it is a Python C extension module (.so or .dll) and in Windows, there is no native compilers (as in Linux or Mac OS X). You can download and install a version "ready" from Christopher Gohlke's Unofficial Windows Binaries for Python Extension Packages

After:

import Levenshtein
# absolute Levenshtein distance of two strings.
Levenshtein.distance('GIS StackExchange','StackExchange')
4
# similarity of two strings.
Levenshtein.ratio('GIS StackExchange','StackExchange')
0.8666666666666667
etc.

You can also use the standard difflib module (Good Python modules for fuzzy string comparison?)

import difflib
difflib.SequenceMatcher(None, 'GIS StackExchange','StackExchange').ratio()
0.8666666666666667

and others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.