Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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